From 577d20b8daf544bdcfa4f81d5a9a0e416d895d24 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sat, 21 May 2022 15:43:12 +0200 Subject: [PATCH] test: use new logger() function in all tests Signed-off-by: Joachim Wiberg --- test/fwd.sh | 6 ++++-- test/local.sh | 7 +++++-- test/notify.sh | 15 +++++++-------- test/remote.sh | 4 ++-- test/rotate_all.sh | 7 ++++--- test/unicode.sh | 5 +++-- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/test/fwd.sh b/test/fwd.sh index d7ec058..70fba5b 100755 --- a/test/fwd.sh +++ b/test/fwd.sh @@ -1,10 +1,12 @@ #!/bin/sh # Test FWD between two syslogd, second binds 127.0.0.2:5555 +# shellcheck disable=SC1090 + if [ x"${srcdir}" = x ]; then srcdir=. fi -. ${srcdir}/lib.sh +. ${srcdir}/lib.sh setup -m0 MSG="fwd and allow" @@ -25,7 +27,7 @@ setup2 -m0 -a 127.0.0.2:* -b ":${PORT2}" print "TEST: Starting" -../src/logger -t fwd -p ntp.notice -u "${SOCK}" -m "NTP123" "${MSG}" +logger -t fwd -p ntp.notice -m "NTP123" "${MSG}" sleep 3 # Allow message to be received, processed, and forwarded grep "fwd - NTP123 - ${MSG}" "${LOG2}" || FAIL "Nothing forwarded." diff --git a/test/local.sh b/test/local.sh index ff2666c..81a4610 100755 --- a/test/local.sh +++ b/test/local.sh @@ -1,7 +1,10 @@ #!/bin/sh +# shellcheck disable=SC1090 + if [ x"${srcdir}" = x ]; then srcdir=. fi + . ${srcdir}/lib.sh setup @@ -10,10 +13,10 @@ print "TEST: Starting" MSG="foobar" MSG2="xyzzy" -../src/logger -u "${SOCK}" ${MSG} +logger "${MSG}" grep ${MSG} "${LOG}" || FAIL "Cannot find: ${MSG}" -../src/logger -u "${ALTSOCK}" ${MSG2} +logger "${ALTSOCK}" ${MSG2} grep ${MSG2} "${LOG}" || FAIL "Cannot find: ${MSG2}" OK diff --git a/test/notify.sh b/test/notify.sh index 5c6b554..637fed7 100755 --- a/test/notify.sh +++ b/test/notify.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC1090 set -x if [ x"${srcdir}" = x ]; then @@ -6,8 +7,6 @@ if [ x"${srcdir}" = x ]; then fi . ${srcdir}/lib.sh -[ -x ../src/logger ] || SKIP 'logger missing' - NOT1=${DIR}/${NM}-1.sh NOT1STAMP=${DIR}/${NM}-1.stamp NOT2=${DIR}/${NM}-2.sh @@ -28,13 +27,13 @@ setup MSG=01234567890123456789012345678901234567890123456789 MSG=$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG -../src/logger -u ${SOCK} ${MSG} -../src/logger -u ${SOCK} 1${MSG} -../src/logger -u ${SOCK} 2${MSG} +logger ${MSG} +logger 1${MSG} +logger 2${MSG} -if [ -f ${LOG}.0 ] && - grep 'script 1' ${NOT1STAMP} && - grep 'script 2' ${NOT2STAMP}; then +if [ -f "${LOG}.0" ] && + grep 'script 1' "${NOT1STAMP}" && + grep 'script 2' "${NOT2STAMP}"; then OK else FAIL 'Notifier did not run.' diff --git a/test/remote.sh b/test/remote.sh index f7f5b84..735bd7c 100755 --- a/test/remote.sh +++ b/test/remote.sh @@ -30,7 +30,7 @@ echo "$TPID" >> "$DIR/PIDs" # Wait for tshark to start up properly sleep 3 -../src/logger -u "${SOCK}" ${MSG} +logger ${MSG} # Wait for any OS delays, in particular on Travis sleep 1 @@ -41,6 +41,6 @@ wait ${TPID} # Analyze content, should have $MSG now ... #tshark -d udp.port==${PORT},syslog -r ${CAP} | grep ${MSG} -tshark -r "${CAP}" 2>/dev/null | grep ${MSG} || FAIL "Cannot find: ${MSG}" +tshark -r "${CAP}" 2>/dev/null | grep "${MSG}" || FAIL "Cannot find: ${MSG}" OK diff --git a/test/rotate_all.sh b/test/rotate_all.sh index 40ddea1..4e33faf 100755 --- a/test/rotate_all.sh +++ b/test/rotate_all.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC1090 set -x if [ x"${srcdir}" = x ]; then @@ -26,7 +27,7 @@ EOF setup rm -f ${NOT1STAMP} -../src/logger -u ${SOCK} notrotall-1 +logger notrotall-1 kill -USR2 `cat ${PID}` sleep 3 @@ -45,7 +46,7 @@ else fi rm -f ${NOT1STAMP} -../src/logger -u ${SOCK} notrotall-2 +logger notrotall-2 kill -USR2 `cat ${PID}` sleep 3 @@ -68,7 +69,7 @@ fi cp $NOT1STAMP /tmp/ rm -f ${NOT1STAMP} -../src/logger -u ${SOCK} notrotall-3 +logger notrotall-3 kill -USR2 `cat ${PID}` sleep 3 diff --git a/test/unicode.sh b/test/unicode.sh index 0c8f8c4..2150f41 100755 --- a/test/unicode.sh +++ b/test/unicode.sh @@ -5,16 +5,17 @@ if [ x"${srcdir}" = x ]; then srcdir=. fi + . ${srcdir}/lib.sh setup -8 MSG="öäüÖÄÜ߀¢§" MSG2="…‘’•" -../src/logger -u "${SOCK}" ${MSG} +logger ${MSG} grep ${MSG} "${LOG}" || FAIL "Cannot find: ${MSG}" -../src/logger -u "${ALTSOCK}" ${MSG2} +logger "${ALTSOCK}" ${MSG2} grep ${MSG2} "${LOG}" || FAIL "Cannot find: ${MSG2}" OK