git: 1a2a0db0a9ec - main - tests: kern: improve logsigexit test

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Sun, 15 Dec 2024 04:40:27 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a2a0db0a9ecf0f761eadbfe81289515a7efa5f0

commit 1a2a0db0a9ecf0f761eadbfe81289515a7efa5f0
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2024-12-15 04:40:15 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-12-15 04:40:15 +0000

    tests: kern: improve logsigexit test
    
    Use dmesg(8) instead rather than relying on a particular syslogd
    configuration, and just skip the test if we can't access the msgbuf.
    
    While we're here, remove some debugging output that we don't actually
    need.
---
 tests/sys/kern/logsigexit_test.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tests/sys/kern/logsigexit_test.sh b/tests/sys/kern/logsigexit_test.sh
index c40c033bbefd..f0db02613533 100644
--- a/tests/sys/kern/logsigexit_test.sh
+++ b/tests/sys/kern/logsigexit_test.sh
@@ -8,6 +8,10 @@ atf_test_case basic
 basic_body()
 {
 
+	if ! dmesg >/dev/null 2>&1; then
+		atf_skip "No dmesg(8) access"
+	fi
+
 	# 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.
@@ -22,12 +26,9 @@ basic_body()
 	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_check -o save:dmesg.out dmesg
+	atf_check grep -Eq "$enpid.+exited on signal" dmesg.out
+	atf_check -s not-exit:0 grep -Eq "$dispid.+exited on signal" dmesg.out
 }
 
 atf_init_test_cases()