Skip to content

Commit

Permalink
tests: kern: add some tests for recently added logsigexit
Browse files Browse the repository at this point in the history
We don't bother tweaking the sysctl in these tests, we'll just try with
it forced both on and off via proccontrol(1).  This could be problematic
in the face of pid wrapping if we got really unfortunate, but the
potential solutions need careful consideration- you probably don't want
to assume a certain velocity of messages into syslog, so just checking
the last N lines is probably similarly flakey.
  • Loading branch information
kevans91 committed Dec 14, 2024
1 parent dabf006 commit 9647bf2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/sys/kern/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ATF_TESTS_C+= sigsys
TEST_METADATA.sigsys+= is_exclusive="true"

ATF_TESTS_SH+= coredump_phnum_test
ATF_TESTS_SH+= logsigexit_test
ATF_TESTS_SH+= sonewconn_overflow
TEST_METADATA.sonewconn_overflow+= required_programs="python"
TEST_METADATA.sonewconn_overflow+= required_user="root"
Expand Down
36 changes: 36 additions & 0 deletions tests/sys/kern/logsigexit_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright (c) 2024 Kyle Evans <[email protected]>
#
# SPDX-License-Identifier: BSD-2-Clause
#

atf_test_case basic
basic_body()
{

# SIGABRT carefully chosen to avoid issues when run under Kyua. No
# matter the value of the global kern.logsigexit, these should force
# the messages as appropriate and we'll all be happy.
proccontrol -m logsigexit -s enable \
sh -c 'echo $$ > enabled.out; kill -ABRT $$'
proccontrol -m logsigexit -s disable \
sh -c 'echo $$ > disabled.out; kill -ABRT $$'

atf_check test -s enabled.out
atf_check test -s disabled.out

read enpid < enabled.out
read dispid < disabled.out

1>&2 echo "$enpid"
1>&2 echo "$dispid"

atf_check grep -Eq "$enpid.+exited on signal" /var/log/messages
atf_check -s not-exit:0 \
grep -Eq "$dispid.+exited on signal" /var/log/messages
}

atf_init_test_cases()
{
atf_add_test_case basic
}

0 comments on commit 9647bf2

Please sign in to comment.