From 7e1d7bcb06af50eb01307b1c5caf6c9827d92f02 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 20 May 2022 06:32:56 +0200 Subject: [PATCH] test: a few more helper functions Signed-off-by: Joachim Wiberg --- test/lib.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/lib.sh b/test/lib.sh index 9ff0bc3..ab8f7a8 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -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