From 992d3a207d0a6cf4faeb835ea6a37ff33df9c87d Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Mon, 20 Sep 2021 00:28:44 +0200 Subject: dumb fuzzer: randpkt vs nDPId-test Signed-off-by: Toni Uhlig --- test/dumb_fuzzer.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 test/dumb_fuzzer.sh (limited to 'test/dumb_fuzzer.sh') diff --git a/test/dumb_fuzzer.sh b/test/dumb_fuzzer.sh new file mode 100755 index 000000000..61865b6c1 --- /dev/null +++ b/test/dumb_fuzzer.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -e + +MYDIR="$(realpath "$(dirname ${0})")" +nDPId_test_EXEC="$(realpath "${1:-"${MYDIR}/../nDPId-test"}")" +PROTOCOL="${2:-tcp}" +MAX_RUNS="${3:-100}" +MAX_COUNT="${4:-10000}" + +function usage() +{ +cat <&2 + rm -f "/tmp/randpkt_$$.pcap" + $(which pkill) -P $$ + wait + exit 2 +} +trap sighandler SIGINT SIGTERM + +test -z "$(which pkill)" && { printf '%s\n' 'pkill not found'; exit 1; } +test -z "$(which randpkt)" && { printf '%s\n' 'randpkt not found'; exit 1; } + +while (( ${MAX_RUNS} > 0 )); do + printf '.' + test $((${MAX_RUNS} % 10)) -ne 0 || printf '%s' "${MAX_RUNS}" + $(which randpkt) -c "${MAX_COUNT}" -t "${PROTOCOL}" "/tmp/randpkt_$$.pcap" + ${nDPId_test_EXEC} "/tmp/randpkt_$$.pcap" >/dev/null + MAX_RUNS=$((${MAX_RUNS} - 1)) +done + +rm -f "/tmp/randpkt_$$.pcap" +printf '\n' -- cgit v1.2.3