From 5b48dac64ed9afca6a05e4f09e0d81ec7bfc0571 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 8 Apr 2022 18:51:06 +0200 Subject: [PATCH] test: new test to verify facility sorting to custom log file Signed-off-by: Joachim Wiberg --- test/Makefile.am | 3 ++- test/facility.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 test/facility.sh diff --git a/test/Makefile.am b/test/Makefile.am index 3ea946b..3c4077b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = lib.sh opts.sh EXTRA_DIST += api.sh local.sh unicode.sh remote.sh fwd.sh mark.sh \ - notify.sh rotate_all.sh + facility.sh notify.sh rotate_all.sh CLEANFILES = *~ *.trs *.log TEST_EXTENSIONS = .sh TESTS_ENVIRONMENT= unshare -mrun @@ -16,6 +16,7 @@ TESTS += local.sh TESTS += unicode.sh TESTS += remote.sh TESTS += api.sh +TESTS += facility.sh TESTS += fwd.sh TESTS += mark.sh TESTS += notify.sh diff --git a/test/facility.sh b/test/facility.sh new file mode 100755 index 0000000..8d4748f --- /dev/null +++ b/test/facility.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Test message to various facilities +if [ x"${srcdir}" = x ]; then + srcdir=. +fi +. ${srcdir}/lib.sh + +setup -m0 + +MSG="hey ho here we go" + +cat <"${CONFD}/facility.conf" +auth,authpriv.* ${DIR}/auth.log +*.*;auth,authpriv.none;local7.!=notice -${DIR}/syslog +daemon.* -${DIR}/daemon.log +kern.* -${DIR}/kern.log +lpr.* -${DIR}/lpr.log +mail.* -${DIR}/mail.log +user.* -${DIR}/user.log +mail.info -${DIR}/mail.info +mail.warn -${DIR}/mail.warn +mail.err ${DIR}/mail.err +*.=debug;\ + auth,authpriv.none;\ + news.none;mail.none -${DIR}/debug +*.=info;*.=notice;*.=warn;\ + auth,authpriv.none;\ + cron,daemon.none;\ + local7.!=notice;\ + mail,news.none -${DIR}/messages +*.emerg :omusrmsg:* +local7.=notice ${DIR}/sudo.log +EOF + +reload + +print "TEST: Starting" + +../src/logger -t facility -p local7.notice -u "${SOCK}" "${MSG}" +sleep 1 +grep "${MSG}" "${DIR}/sudo.log" || FAIL "" + +OK