summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Scherpelz <jscherpelz@google.com>2017-02-24 01:54:36 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-02-24 01:54:36 +0000
commit2c4349fa61a302fb8246bd36c3139742b5ba5e14 (patch)
treeff9cb26861c9b22ab471f75cbd4c7b52ce9c9e61
parent2607aafb5a2fbbe7ab5eb2ca9d2d232b8817dd85 (diff)
parentc2f49accd6434700a5196eb987f206b6878e307d (diff)
downloadtests-2c4349fa61a302fb8246bd36c3139742b5ba5e14.tar.gz
Extend run_net_test.sh to allow passing arguments to individual tests am: de316e8695
am: c2f49accd6 Change-Id: Ib481728f86fce5a860caa4f1d33984c0452eda39
-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 abd0f76..bade6de 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 cc276d8..6179b28 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