test: minor, shellcheck fixes

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-03-06 01:06:38 +01:00
parent 0a99c7f386
commit 13b1fd0aa0
7 changed files with 28 additions and 24 deletions

View File

@ -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 <<EOF >${CONFD}/console.conf
cat <<EOF >"${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 <<EOF >${CONFD}/v1.conf
cat <<EOF >"${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

View File

@ -9,14 +9,14 @@ setup -m0
MSG="fwd and allow"
cat <<EOF >${CONFD}/fwd.conf
cat <<EOF >"${CONFD}/fwd.conf"
kern.* /dev/null
ntp.* @127.0.0.2:${PORT2} ;RFC5424
EOF
reload
cat <<EOF >${CONFD2}/50-default.conf
cat <<EOF >"${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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -1,16 +1,17 @@
#!/bin/sh
# shellcheck disable=SC1090
if [ x"${srcdir}" = x ]; then
srcdir=.
fi
. ${srcdir}/lib.sh
cat <<EOF > ${CONF}
cat <<EOF > "${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

View File

@ -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