xref: /freebsd/tests/sys/kern/logsigexit_test.sh (revision 1a2a0db0a9ecf0f761eadbfe81289515a7efa5f0)
1#
2# Copyright (c) 2024 Kyle Evans <kevans@FreeBSD.org>
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6
7atf_test_case basic
8basic_body()
9{
10
11	if ! dmesg >/dev/null 2>&1; then
12		atf_skip "No dmesg(8) access"
13	fi
14
15	# SIGABRT carefully chosen to avoid issues when run under Kyua.  No
16	# matter the value of the global kern.logsigexit, these should force
17	# the messages as appropriate and we'll all be happy.
18	proccontrol -m logsigexit -s enable \
19	    sh -c 'echo $$ > enabled.out; kill -ABRT $$'
20	proccontrol -m logsigexit -s disable \
21	    sh -c 'echo $$ > disabled.out; kill -ABRT $$'
22
23	atf_check test -s enabled.out
24	atf_check test -s disabled.out
25
26	read enpid < enabled.out
27	read dispid < disabled.out
28
29	atf_check -o save:dmesg.out dmesg
30	atf_check grep -Eq "$enpid.+exited on signal" dmesg.out
31	atf_check -s not-exit:0 grep -Eq "$dispid.+exited on signal" dmesg.out
32}
33
34atf_init_test_cases()
35{
36	atf_add_test_case basic
37}
38