test: a few more helper functions

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-05-20 06:32:56 +02:00
parent a453eca4be
commit 7e1d7bcb06

View File

@ -73,6 +73,44 @@ tenacious()
FAIL "Timeed out $*"
}
cap_start()
{
tshark -Qni lo -w "${CAP}" port 514 2>/dev/null &
TPID="$!"
echo "$TPID" >> "$DIR/PIDs"
sleep 1
}
cap_stop()
{
sleep 1
kill -TERM ${TPID}
wait ${TPID}
}
cap_dump()
{
tshark -r "${CAP}" 2>/dev/null
}
cap_find()
{
cap_dump | grep "$@"
}
logger()
{
[ -x ../src/logger ] || SKIP 'logger missing'
sock="${SOCK}"
if [ $# -gt 1 ] && [ -f "$1" ]; then
sock="$1"
shift
fi
../src/logger -u "$sock" "$@"
}
# shellcheck disable=SC2046,SC2086
do_setup()
{
@ -131,6 +169,11 @@ setup2()
-C "${CACHE2}" -P "${PID2}"
}
is_running()
{
kill -0 $(cat "$PID")
}
do_reload()
{
# shellcheck disable=SC2046