diff options
author | Eyal Soha <eyalsoha@google.com> | 2020-02-05 11:17:14 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-05 11:18:02 -0800 |
commit | 37abbbc547d9d78e0bf42f192403c8eca30593d8 (patch) | |
tree | 3d0e58e37ca49ee01f2c5e7bbaa595db17591ea8 /test/packetdrill/packetdrill_test.sh | |
parent | 665b614e4a6e715bac25bea15c5c29184016e549 (diff) |
Add packetdrill tests to presubmit and CI testing
PiperOrigin-RevId: 293409718
Diffstat (limited to 'test/packetdrill/packetdrill_test.sh')
-rwxr-xr-x | test/packetdrill/packetdrill_test.sh | 20 |
1 files changed, 16 insertions, 4 deletions
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}" \ |