11.1Smartin#! /usr/bin/atf-sh
21.4Srillig# $NetBSD: t_klua_pr_52864.sh,v 1.4 2024/04/28 07:27:41 rillig Exp $
31.1Smartin#
41.1Smartin# Copyright (c) 2018 The NetBSD Foundation, Inc.
51.1Smartin# All rights reserved.
61.1Smartin#
71.1Smartin# Redistribution and use in source and binary forms, with or without
81.1Smartin# modification, are permitted provided that the following conditions
91.1Smartin# are met:
101.1Smartin# 1. Redistributions of source code must retain the above copyright
111.1Smartin#    notice, this list of conditions and the following disclaimer.
121.1Smartin# 2. Redistributions in binary form must reproduce the above copyright
131.1Smartin#    notice, this list of conditions and the following disclaimer in the
141.1Smartin#    documentation and/or other materials provided with the distribution.
151.1Smartin#
161.1Smartin# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
171.1Smartin# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
181.1Smartin# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
191.1Smartin# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
201.1Smartin# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
211.1Smartin# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
221.1Smartin# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
231.1Smartin# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
241.1Smartin# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
251.1Smartin# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
261.1Smartin# POSSIBILITY OF SUCH DAMAGE.
271.1Smartin#
281.1Smartin
291.1Smartinatf_test_case luastate cleanup
301.1Smartinluastate_head() {
311.1Smartin	atf_set "descr" "Test that once lua(4) is loaded and a state is " \
321.1Smartin			"created, system does not crash when listing states" \
331.1Smartin			"(PR port-macppc/52864)"
341.1Smartin	atf_set "require.user" "root"
351.1Smartin}
361.1Smartin
371.1Smartinluastate_body() {
381.2Smartin	err=$( modstat -e 2>&1 )
391.2Smartin	if [ $? -gt 0 ]; then
401.2Smartin		atf_skip "${err##modstat:}"
411.2Smartin	fi
421.1Smartin	sysctl -q kern.lua.verbose
431.1Smartin	if [ $? -eq 1 ]; then
441.4Srillig		atf_check -s exit:0 modload lua
451.1Smartin	fi
461.4Srillig	atf_check -s exit:0 luactl -q create atfluastate
471.4Srillig	atf_check -s exit:0 -o ignore luactl
481.1Smartin}
491.1Smartin
501.1Smartinluastate_cleanup() {
511.1Smartin	modunload lua >/dev/null 2>&1
521.1Smartin}
531.1Smartin
541.1Smartinatf_init_test_cases() {
551.1Smartin	atf_add_test_case luastate
561.1Smartin}
57