git: b872bb720630 - main - syslogd: Split up basic test case
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Nov 2024 22:27:19 UTC
The branch main has been updated by jfree: URL: https://cgit.FreeBSD.org/src/commit/?id=b872bb7206300dea5d02313985704da75ae87598 commit b872bb7206300dea5d02313985704da75ae87598 Author: Jake Freeland <jfree@FreeBSD.org> AuthorDate: 2024-11-27 22:26:16 +0000 Commit: Jake Freeland <jfree@FreeBSD.org> CommitDate: 2024-11-27 22:26:16 +0000 syslogd: Split up basic test case The basic case previously tested if messages are correctly logged over UNIX, INET, and INET6 transport. This single case can be split up into three separate cases to decrease code complexity and offer more granular results. Both INET and INET6 cases will be skipped if the kernel does not support the corresponding transport. Reviewed by: zlei, markj Differential Revision: https://reviews.freebsd.org/D47650 --- usr.sbin/syslogd/tests/syslogd_test.sh | 83 ++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/usr.sbin/syslogd/tests/syslogd_test.sh b/usr.sbin/syslogd/tests/syslogd_test.sh index aa8d48e64f5c..e75c85d5995a 100644 --- a/usr.sbin/syslogd/tests/syslogd_test.sh +++ b/usr.sbin/syslogd/tests/syslogd_test.sh @@ -118,41 +118,76 @@ syslogd_stop() fi } -atf_test_case "basic" "cleanup" -basic_head() +atf_test_case "unix" "cleanup" +unix_head() { - atf_set descr "Messages are logged via supported transports" + atf_set descr "Messages are logged over UNIX transport" } -basic_body() +unix_body() { - logfile="${PWD}/basic.log" + local logfile="${PWD}/unix.log" + printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}" syslogd_start - syslogd_log -p user.debug -t basic -h "${SYSLOGD_LOCAL_SOCKET}" \ + syslogd_log -p user.debug -t unix -h "${SYSLOGD_LOCAL_SOCKET}" \ "hello, world (unix)" - atf_check -s exit:0 -o match:"basic: hello, world \(unix\)" \ + atf_check -s exit:0 -o match:"unix: hello, world \(unix\)" \ tail -n 1 "${logfile}" +} +unix_cleanup() +{ + syslogd_stop +} - # Grab kernel configuration file. - sysctl kern.conftxt > conf.txt +atf_test_case "inet" "cleanup" +inet_head() +{ + atf_set descr "Messages are logged over INET transport" +} +inet_body() +{ + local logfile="${PWD}/inet.log" + + [ "$(sysctl -n kern.features.inet)" != "1" ] && + atf_skip "Kernel does not support INET" + + printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}" + syslogd_start # We have INET transport; make sure we can use it. - if grep -qw "INET" conf.txt; then - syslogd_log -4 -p user.debug -t basic -h 127.0.0.1 -P "${SYSLOGD_UDP_PORT}" \ - "hello, world (v4)" - atf_check -s exit:0 -o match:"basic: hello, world \(v4\)" \ - tail -n 1 "${logfile}" - fi + syslogd_log -4 -p user.debug -t inet -h 127.0.0.1 -P "${SYSLOGD_UDP_PORT}" \ + "hello, world (v4)" + atf_check -s exit:0 -o match:"inet: hello, world \(v4\)" \ + tail -n 1 "${logfile}" +} +inet_cleanup() +{ + syslogd_stop +} + +atf_test_case "inet6" "cleanup" +inet6_head() +{ + atf_set descr "Messages are logged over INET6 transport" +} +inet6_body() +{ + local logfile="${PWD}/inet6.log" + + [ "$(sysctl -n kern.features.inet6)" != "1" ] && + atf_skip "Kernel does not support INET6" + + printf "user.debug\t${logfile}\n" > "${SYSLOGD_CONFIG}" + syslogd_start + # We have INET6 transport; make sure we can use it. - if grep -qw "INET6" conf.txt; then - syslogd_log -6 -p user.debug -t basic -h ::1 -P "${SYSLOGD_UDP_PORT}" \ - "hello, world (v6)" - atf_check -s exit:0 -o match:"basic: hello, world \(v6\)" \ - tail -n 1 "${logfile}" - fi + syslogd_log -6 -p user.debug -t unix -h ::1 -P "${SYSLOGD_UDP_PORT}" \ + "hello, world (v6)" + atf_check -s exit:0 -o match:"unix: hello, world \(v6\)" \ + tail -n 1 "${logfile}" } -basic_cleanup() +inet6_cleanup() { syslogd_stop } @@ -407,7 +442,9 @@ jail_noinet_cleanup() atf_init_test_cases() { - atf_add_test_case "basic" + atf_add_test_case "unix" + atf_add_test_case "inet" + atf_add_test_case "inet6" atf_add_test_case "reload" atf_add_test_case "prog_filter" atf_add_test_case "host_filter"