test: minor aesthetic, slightly improve test logging

Conforming tests should use SKIP/FAIL/OK, so let existing tests follow
that better.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-03-06 01:02:03 +01:00
parent f29f31340c
commit 0a99c7f386
5 changed files with 21 additions and 6 deletions

View File

@ -7,11 +7,11 @@ setup
export MSG="no-openlog-apitest"
echo "= Phase 1 - simple syslog(), no openlog() ==============="
print "Phase 1 - simple syslog(), no openlog()"
./api
grep "api: ${MSG}" ${LOG}
echo "= Phase 2 - syslog() with openlog() & custom facility ==="
print "Phase 2 - syslog() with openlog() & custom facility"
cat <<EOF >${CONFD}/console.conf
console.* -${LOGCONS}
EOF
@ -20,11 +20,12 @@ reload
./api -i foo
grep "foo: ${MSG}" ${LOGCONS}
echo "= Phase 3 - Verify setlogmask() filters out LOG_INFO ===="
print "Phase 3 - Verify setlogmask() filters out LOG_INFO"
./api -i xyzzy -l
grep "xyzzy: ${MSG}" ${LOGCONS} || true
grep "xyzzy: ${MSG}" "${LOGCONS}" && FAIL "Filtering w/ setlogmask() broken"
echo "Filtering w/ setlogmask() Works fine"
echo "= Phase 4 - Verify RFC5424 API with syslogp() ==========="
print "Phase 4 - Verify RFC5424 API with syslogp()"
cat <<EOF >${CONFD}/v1.conf
ftp.* -${LOGV1} ;RFC5424
EOF
@ -35,7 +36,9 @@ 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")
echo "= Phase 4 - Verify RFC5424 API with logger(1) ==========="
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"
sleep 2
grep "exampleSDID@32473" ${LOGV1} || (echo "== ${LOGV1}"; tail -10 ${LOGV1}; FAIL "Cannot find exampleSDID@32473")
OK

View File

@ -23,8 +23,11 @@ EOF
setup2 -m0 -a 127.0.0.2:* -b ":${PORT2}"
print "TEST: Starting"
../src/logger -t fwd -p ntp.notice -u ${SOCK} -m "NTP123" ${MSG}
sleep 3
grep "fwd - NTP123 - ${MSG}" ${LOG2} || FAIL "Nothing forwarded."
OK

View File

@ -5,6 +5,8 @@ fi
. ${srcdir}/lib.sh
setup
print "TEST: Starting"
MSG="foobar"
MSG2="xyzzy"
@ -13,3 +15,4 @@ grep ${MSG} ${LOG} || FAIL "Cannot find: ${MSG}"
../src/logger -u ${ALTSOCK} ${MSG2}
grep ${MSG2} ${LOG} || FAIL "Cannot find: ${MSG2}"
OK

View File

@ -12,3 +12,5 @@ EOF
setup -m0 >"${LOG2}"
grep ';RFC5424,rotate=10000000:5' ${LOG2} || FAIL "Failed parsing RFC542 .conf"
OK

View File

@ -18,6 +18,8 @@ cat <<-EOF >${CONFD2}/50-default.conf
setup2 -m0 -a 127.0.0.2:* -b ":${PORT2}"
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 &
@ -39,3 +41,5 @@ 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}"
OK