summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Scherpelz <jscherpelz@google.com>2017-02-23 13:51:31 +0900
committerJoel Scherpelz <jscherpelz@google.com>2017-02-23 09:09:10 +0000
commitde316e86951d6765f7e17b0462b15e3a2fa4865b (patch)
treeff9cb26861c9b22ab471f75cbd4c7b52ce9c9e61
parentcbcfcf0835868c1f544a3eba368614d1065f0622 (diff)
downloadkernel_tests-de316e86951d6765f7e17b0462b15e3a2fa4865b.tar.gz
kernel_tests-de316e86951d6765f7e17b0462b15e3a2fa4865b.tar.bz2
kernel_tests-de316e86951d6765f7e17b0462b15e3a2fa4865b.zip
Extend run_net_test.sh to allow passing arguments to individual tests
For example "run_net_test.sh multinetwork_test.py -v RATest" would run multinetwork_test.py with the arguments "-v RATest". Test: all_tests.sh passes when run with no extra arguments Change-Id: I4f981e0a169635f90a355a1fb008d8421f8c9ec0
-rwxr-xr-xnet/test/net_test.sh4
-rwxr-xr-xnet/test/run_net_test.sh18
2 files changed, 19 insertions, 3 deletions
diff --git a/net/test/net_test.sh b/net/test/net_test.sh
index abd0f76a..bade6dee 100755
--- a/net/test/net_test.sh
+++ b/net/test/net_test.sh
@@ -19,8 +19,8 @@ if [ "$net_test_mode" != "builder" ]; then
trap "exec /bin/bash" ERR EXIT
fi
-echo -e "Running $net_test\n"
-$net_test
+echo -e "Running $net_test $net_test_args\n"
+$net_test $net_test_args
# Write exit code of net_test to /proc/exitcode so that the builder can use it
# to signal failure if any tests fail.
diff --git a/net/test/run_net_test.sh b/net/test/run_net_test.sh
index cc276d89..6179b288 100755
--- a/net/test/run_net_test.sh
+++ b/net/test/run_net_test.sh
@@ -83,10 +83,25 @@ while [ -n "$1" ]; do
shift
else
test=$1
- break # The test file must be the last argument.
+ break # Arguments after the test file are passed to the test itself.
fi
done
+# Check that test file exists and is readable
+test_file=$SCRIPT_DIR/$test
+if [[ ! -e $test_file ]]; then
+ echo "test file '${test_file}' does not exist"
+ exit 1
+fi
+
+if [[ ! -x $test_file ]]; then
+ echo "test file '${test_file}' is not executable"
+ exit 1
+fi
+
+# Collect trailing arguments to pass to $test
+test_args=${@:2}
+
function isRunningTest() {
[[ -n "$test" ]] && ! (( norun ))
}
@@ -191,4 +206,5 @@ dir=/host$SCRIPT_DIR
# Start the VM.
exec $KERNEL_BINARY umid=net_test $blockdevice=$SCRIPT_DIR/$ROOTFS \
mem=512M init=/sbin/net_test.sh net_test=$dir/$test \
+ net_test_args=\"$test_args\" \
net_test_mode=$testmode $netconfig $consolemode >&2