diff --git a/test/api.sh b/test/api.sh index 409b019..e16b6b2 100755 --- a/test/api.sh +++ b/test/api.sh @@ -1,4 +1,5 @@ #!/bin/sh +# shellcheck disable=SC1090 if [ x"${srcdir}" = x ]; then srcdir=. fi @@ -9,16 +10,16 @@ export MSG="no-openlog-apitest" print "Phase 1 - simple syslog(), no openlog()" ./api -grep "api: ${MSG}" ${LOG} +grep "api: ${MSG}" "${LOG}" print "Phase 2 - syslog() with openlog() & custom facility" -cat <${CONFD}/console.conf +cat <"${CONFD}/console.conf" console.* -${LOGCONS} EOF reload ./api -i foo -grep "foo: ${MSG}" ${LOGCONS} +grep "foo: ${MSG}" "${LOGCONS}" print "Phase 3 - Verify setlogmask() filters out LOG_INFO" ./api -i xyzzy -l @@ -26,7 +27,7 @@ grep "xyzzy: ${MSG}" "${LOGCONS}" && FAIL "Filtering w/ setlogmask() broken" echo "Filtering w/ setlogmask() Works fine" print "Phase 4 - Verify RFC5424 API with syslogp()" -cat <${CONFD}/v1.conf +cat <"${CONFD}/v1.conf" ftp.* -${LOGV1} ;RFC5424 EOF reload @@ -34,11 +35,11 @@ reload ./api -i troglobit -p sleep 2 ps fax |grep -A2 syslogd -grep "troglobit - MSGID - ${MSG}" ${LOGV1} || (echo "== ${LOGV1}"; tail -10 ${LOGV1}; echo "== ${LOG}"; tail -10 ${LOG}; cat ${CONFD}/v1.conf; FAIL "Cannot find troglobit") +grep "troglobit - MSGID - ${MSG}" "${LOGV1}" || (echo "== ${LOGV1}"; tail -10 "${LOGV1}"; echo "== ${LOG}"; tail -10 "${LOG}"; cat "${CONFD}/v1.conf"; FAIL "Cannot find troglobit") print "Phase 4 - Verify RFC5424 API with logger(1)" -../src/logger -p ftp.notice -u ${SOCK} -m "MSDSD" -d '[exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"]' "waldo" +../src/logger -p ftp.notice -u "${SOCK}" -m "MSDSD" -d '[exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"]' "waldo" sleep 2 -grep "exampleSDID@32473" ${LOGV1} || (echo "== ${LOGV1}"; tail -10 ${LOGV1}; FAIL "Cannot find exampleSDID@32473") +grep "exampleSDID@32473" "${LOGV1}" || (echo "== ${LOGV1}"; tail -10 "${LOGV1}"; FAIL "Cannot find exampleSDID@32473") OK diff --git a/test/fwd.sh b/test/fwd.sh index 0f8b8c3..9ad0ba3 100755 --- a/test/fwd.sh +++ b/test/fwd.sh @@ -9,14 +9,14 @@ setup -m0 MSG="fwd and allow" -cat <${CONFD}/fwd.conf +cat <"${CONFD}/fwd.conf" kern.* /dev/null ntp.* @127.0.0.2:${PORT2} ;RFC5424 EOF reload -cat <${CONFD2}/50-default.conf +cat <"${CONFD2}/50-default.conf" kern.* /dev/null *.*;kern.none ${LOG2} ;RFC5424 EOF @@ -25,9 +25,8 @@ setup2 -m0 -a 127.0.0.2:* -b ":${PORT2}" print "TEST: Starting" - -../src/logger -t fwd -p ntp.notice -u ${SOCK} -m "NTP123" ${MSG} +../src/logger -t fwd -p ntp.notice -u "${SOCK}" -m "NTP123" "${MSG}" sleep 3 -grep "fwd - NTP123 - ${MSG}" ${LOG2} || FAIL "Nothing forwarded." +grep "fwd - NTP123 - ${MSG}" "${LOG2}" || FAIL "Nothing forwarded." OK diff --git a/test/lib.sh b/test/lib.sh index 80112dd..9ff0bc3 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -59,7 +59,7 @@ OK() exit 0 } -# shellcheck disable=SC2068 +# shellcheck disable=SC2068,SC2086 tenacious() { timeout=$1 @@ -193,7 +193,7 @@ trapit() { func="$1" ; shift for sig ; do - trap "$func $sig" "$sig" + trap '$func $sig' "$sig" done } diff --git a/test/local.sh b/test/local.sh index 98c1cbb..ff2666c 100755 --- a/test/local.sh +++ b/test/local.sh @@ -10,9 +10,10 @@ print "TEST: Starting" MSG="foobar" MSG2="xyzzy" -../src/logger -u ${SOCK} ${MSG} -grep ${MSG} ${LOG} || FAIL "Cannot find: ${MSG}" +../src/logger -u "${SOCK}" ${MSG} +grep ${MSG} "${LOG}" || FAIL "Cannot find: ${MSG}" + +../src/logger -u "${ALTSOCK}" ${MSG2} +grep ${MSG2} "${LOG}" || FAIL "Cannot find: ${MSG2}" -../src/logger -u ${ALTSOCK} ${MSG2} -grep ${MSG2} ${LOG} || FAIL "Cannot find: ${MSG2}" OK diff --git a/test/mark.sh b/test/mark.sh index 0abfd6f..470dca1 100755 --- a/test/mark.sh +++ b/test/mark.sh @@ -1,5 +1,6 @@ #!/bin/sh -e # Test '-- MARK --' in log, depends on fwd.sh +# shellcheck disable=SC1090 if [ x"${srcdir}" = x ]; then srcdir=. fi diff --git a/test/opts.sh b/test/opts.sh index ae9f6c9..7b50cdd 100755 --- a/test/opts.sh +++ b/test/opts.sh @@ -1,16 +1,17 @@ #!/bin/sh +# shellcheck disable=SC1090 if [ x"${srcdir}" = x ]; then srcdir=. fi . ${srcdir}/lib.sh -cat < ${CONF} +cat < "${CONF}" # Match all log messages, store in RC5424 format and rotate every 10 MiB *.* -${LOG} ;rotate=10M:5,RFC5424 EOF setup -m0 >"${LOG2}" -grep ';RFC5424,rotate=10000000:5' ${LOG2} || FAIL "Failed parsing RFC542 .conf" +grep ';RFC5424,rotate=10000000:5' "${LOG2}" || FAIL "Failed parsing RFC5424 .conf" OK diff --git a/test/remote.sh b/test/remote.sh index 194b595..f7f5b84 100755 --- a/test/remote.sh +++ b/test/remote.sh @@ -1,6 +1,7 @@ #!/bin/sh # Verify that the sending to a remote IP:PORT works, note not receiving, # there's a test fwd.sh that verifies that. +# shellcheck disable=SC1090 set -x if [ x"${srcdir}" = x ]; then @@ -12,7 +13,7 @@ setup export MSG="kilroy" # Only needed for verifying correct RFC3164 parsing -cat <<-EOF >${CONFD2}/50-default.conf +cat <<-EOF >"${CONFD2}/50-default.conf" *.* ${LOG2} EOF @@ -22,14 +23,14 @@ print "TEST: Starting" # Start collector in background, note: might need sudo! #tshark -Qni lo -w ${CAP} port ${PORT} & -tshark -Qni lo -w ${CAP} port 514 2>/dev/null & +tshark -Qni lo -w "${CAP}" port 514 2>/dev/null & TPID="$!" echo "$TPID" >> "$DIR/PIDs" # Wait for tshark to start up properly sleep 3 -../src/logger -u ${SOCK} ${MSG} +../src/logger -u "${SOCK}" ${MSG} # Wait for any OS delays, in particular on Travis sleep 1 @@ -40,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