summaryrefslogtreecommitdiffstats
path: root/tests/monitor/run-tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/monitor/run-tests.sh')
-rwxr-xr-xtests/monitor/run-tests.sh29
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/monitor/run-tests.sh b/tests/monitor/run-tests.sh
index ff00450b..67d3e618 100755
--- a/tests/monitor/run-tests.sh
+++ b/tests/monitor/run-tests.sh
@@ -1,7 +1,6 @@
#!/bin/bash
-cd $(dirname $0)
-nft=${NFT:-../../src/nft}
+nft=${NFT:-$(dirname $0)/../../src/nft}
debug=false
test_json=false
@@ -74,7 +73,7 @@ monitor_run_test() {
echo "command file:"
cat $command_file
}
- $nft -f $command_file || {
+ $nft -f - <$command_file || {
err "nft command failed!"
rc=1
}
@@ -103,7 +102,7 @@ echo_run_test() {
echo "command file:"
cat $command_file
}
- $nft -nn -e -f $command_file >$echo_output || {
+ $nft -nn -e -f - <$command_file >$echo_output || {
err "nft command failed!"
rc=1
}
@@ -120,6 +119,14 @@ echo_run_test() {
return $rc
}
+netns=true
+for arg in "$@"; do
+ [[ "$arg" == "--no-netns" ]] && netns=false
+done
+if $netns; then
+ exec unshare -n $0 --no-netns "$@"
+fi
+
testcases=""
while [ -n "$1" ]; do
case "$1" in
@@ -131,11 +138,14 @@ while [ -n "$1" ]; do
test_json=true
shift
;;
+ --no-netns)
+ shift
+ ;;
-H|--host)
nft=nft
shift
;;
- testcases/*.t)
+ *.t)
testcases+=" $1"
shift
;;
@@ -161,7 +171,10 @@ for variant in $variants; do
output_append=${variant}_output_append
for testcase in ${testcases:-testcases/*.t}; do
- echo "$variant: running tests from file $(basename $testcase)"
+ filename=$(basename $testcase)
+ echo "$variant: running tests from file $filename"
+ rc_start=$rc
+
# files are like this:
#
# I add table ip t
@@ -199,6 +212,10 @@ for variant in $variants; do
$run_test
let "rc += $?"
}
+
+ let "rc_diff = rc - rc_start"
+ [[ $rc_diff -ne 0 ]] && \
+ echo "$variant: $rc_diff tests from file $filename failed"
done
done
exit $rc