diff options
Diffstat (limited to 'src/testzzuf/zzuf_test_runner.sh')
-rwxr-xr-x | src/testzzuf/zzuf_test_runner.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/testzzuf/zzuf_test_runner.sh b/src/testzzuf/zzuf_test_runner.sh new file mode 100755 index 00000000..aa1dfdde --- /dev/null +++ b/src/testzzuf/zzuf_test_runner.sh | |||
@@ -0,0 +1,55 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | mhd_listen_ip='127.0.0.1' | ||
4 | max_runtime_sec='300' | ||
5 | |||
6 | if test "x${ZZUF}" = "xno" ; then | ||
7 | echo "zzuf command missing" 1>&2 | ||
8 | exit 77 | ||
9 | fi | ||
10 | |||
11 | if command -v "${ZZUF}" > /dev/null 2>&1 ; then : ; else | ||
12 | echo "zzuf command missing" 1>&2 | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | # zzuf cannot pass-through the return value of checked program | ||
17 | # so try the direct dry-run first to get possibe 77 or 99 codes | ||
18 | echo "## Dry-run of the $@..." | ||
19 | if "$@" --dry-run ; then | ||
20 | echo "# Dry-run succeded." | ||
21 | else | ||
22 | res_code=$? | ||
23 | echo "Dry-run failed with exit code $res_code. $@ will not be run with zzuf." 1>&2 | ||
24 | exit $res_code | ||
25 | fi | ||
26 | |||
27 | # fuzz the input only for IP ${mhd_listen_ip}. libcurl uses another IP | ||
28 | # in this test therefore libcurl input is not fuzzed. | ||
29 | zzuf_all_params="--ratio=0.001:0.4 --autoinc --verbose --signal \ | ||
30 | --max-usertime=${max_runtime_sec} --check-exit --network \ | ||
31 | --allow=${mhd_listen_ip} --exclude=." | ||
32 | |||
33 | if test -n "${ZZUF_SEED}" ; then | ||
34 | zzuf_all_params="${zzuf_all_params} --seed=${ZZUF_SEED}" | ||
35 | fi | ||
36 | |||
37 | if test -n "${ZZUF_FLAGS}" ; then | ||
38 | zzuf_all_params="${zzuf_all_params} ${ZZUF_FLAGS}" | ||
39 | fi | ||
40 | |||
41 | # Uncomment the next line to see more data in logs | ||
42 | #zzuf_all_params="${zzuf_all_params} -dd" | ||
43 | |||
44 | echo "## Dry-run of the $@ with zzuf..." | ||
45 | if "$ZZUF" ${zzuf_all_params} "$@" --dry-run ; then | ||
46 | echo "# Dry-run with zzuf succeded." | ||
47 | else | ||
48 | res_code=$? | ||
49 | echo "$@ cannot be run with zzuf. The test is skipped." 1>&2 | ||
50 | exit 77 | ||
51 | fi | ||
52 | |||
53 | echo "## Real test of $@ with zzuf..." | ||
54 | "$ZZUF" ${zzuf_all_params} "$@" | ||
55 | exit $? | ||