sysklogd/test/remote.sh
Joachim Wiberg 13b1fd0aa0 test: minor, shellcheck fixes
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2022-03-06 01:10:32 +01:00

47 lines
1001 B
Bash
Executable File

#!/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
srcdir=.
fi
. ${srcdir}/lib.sh
setup
export MSG="kilroy"
# Only needed for verifying correct RFC3164 parsing
cat <<-EOF >"${CONFD2}/50-default.conf"
*.* ${LOG2}
EOF
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 &
TPID="$!"
echo "$TPID" >> "$DIR/PIDs"
# Wait for tshark to start up properly
sleep 3
../src/logger -u "${SOCK}" ${MSG}
# Wait for any OS delays, in particular on Travis
sleep 1
# Stop tshark collector
kill -TERM ${TPID}
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