summaryrefslogtreecommitdiffhomepage
path: root/test/packetdrill
diff options
context:
space:
mode:
authorEyal Soha <eyalsoha@google.com>2020-02-05 11:17:14 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-05 11:18:02 -0800
commit37abbbc547d9d78e0bf42f192403c8eca30593d8 (patch)
tree3d0e58e37ca49ee01f2c5e7bbaa595db17591ea8 /test/packetdrill
parent665b614e4a6e715bac25bea15c5c29184016e549 (diff)
Add packetdrill tests to presubmit and CI testing
PiperOrigin-RevId: 293409718
Diffstat (limited to 'test/packetdrill')
-rw-r--r--test/packetdrill/defs.bzl6
-rwxr-xr-xtest/packetdrill/packetdrill_test.sh20
2 files changed, 20 insertions, 6 deletions
diff --git a/test/packetdrill/defs.bzl b/test/packetdrill/defs.bzl
index 582f97e0c..8623ce7b1 100644
--- a/test/packetdrill/defs.bzl
+++ b/test/packetdrill/defs.bzl
@@ -15,7 +15,7 @@ def _packetdrill_test_impl(ctx):
# Make sure that everything is readable here.
"find . -type f -exec chmod a+rx {} \\;",
"find . -type d -exec chmod a+rx {} \\;",
- "%s %s --init_script %s -- %s\n" % (
+ "%s %s --init_script %s $@ -- %s\n" % (
test_runner.short_path,
" ".join(ctx.attr.flags),
ctx.files._init_script[0].short_path,
@@ -76,7 +76,9 @@ def packetdrill_netstack_test(name, **kwargs):
kwargs["tags"] = _PACKETDRILL_TAGS
_packetdrill_test(
name = name + "_netstack_test",
- flags = ["--dut_platform", "netstack"],
+ # This is the default runtime unless
+ # "--test_arg=--runtime=OTHER_RUNTIME" is used to override the value.
+ flags = ["--dut_platform", "netstack", "--runtime", "runsc-d"],
**kwargs
)
diff --git a/test/packetdrill/packetdrill_test.sh b/test/packetdrill/packetdrill_test.sh
index 614d94d74..0b22dfd5c 100755
--- a/test/packetdrill/packetdrill_test.sh
+++ b/test/packetdrill/packetdrill_test.sh
@@ -29,7 +29,7 @@ function failure() {
}
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
-declare -r LONGOPTS="dut_platform:,init_script:"
+declare -r LONGOPTS="dut_platform:,init_script:,runtime:"
# Don't use declare below so that the error from getopt will end the script.
PARSED=$(getopt --options "" --longoptions=$LONGOPTS --name "$0" -- "$@")
@@ -39,6 +39,7 @@ eval set -- "$PARSED"
while true; do
case "$1" in
--dut_platform)
+ # Either "linux" or "netstack".
declare -r DUT_PLATFORM="$2"
shift 2
;;
@@ -46,6 +47,13 @@ while true; do
declare -r INIT_SCRIPT="$2"
shift 2
;;
+ --runtime)
+ # Not readonly because there might be multiple --runtime arguments and we
+ # want to use just the last one. Only used if --dut_platform is
+ # "netstack".
+ declare RUNTIME="$2"
+ shift 2
+ ;;
--)
shift
break
@@ -61,9 +69,13 @@ declare -r scripts="$@"
# Check that the required flags are defined in a way that is safe for "set -u".
if [[ "${DUT_PLATFORM-}" == "netstack" ]]; then
- declare -r RUNTIME="--runtime runsc-d"
+ if [[ -z "${RUNTIME-}" ]]; then
+ echo "FAIL: Missing --runtime argument: ${RUNTIME-}"
+ exit 2
+ fi
+ declare -r RUNTIME_ARG="--runtime ${RUNTIME}"
elif [[ "${DUT_PLATFORM-}" == "linux" ]]; then
- declare -r RUNTIME=""
+ declare -r RUNTIME_ARG=""
else
echo "FAIL: Bad or missing --dut_platform argument: ${DUT_PLATFORM-}"
exit 2
@@ -143,7 +155,7 @@ done
docker pull "${IMAGE_TAG}"
# Create the DUT container and connect to network.
-DUT=$(docker create ${RUNTIME} --privileged --rm \
+DUT=$(docker create ${RUNTIME_ARG} --privileged --rm \
--stop-timeout ${TIMEOUT} -it ${IMAGE_TAG})
docker network connect "${CTRL_NET}" \
--ip "${CTRL_NET_PREFIX}${DUT_NET_SUFFIX}" "${DUT}" \