From 9e798e26cba7926451adafd9e395db1fbf2a8d60 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 8 Dec 2021 21:03:27 -0800 Subject: [PATCH 1/2] tests/int: ability to specify binary This can be used to specify a different runc binary, for example: sudo -E RUNC=$PWD/runc.mine tests/integration/cwd.bats A different (but compatible enough) runtime also works: sudo -E RUNC=/usr/local/bin/crun tests/integration/cwd.bats Signed-off-by: Kir Kolyshkin --- tests/integration/helpers.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 91d4606aa..8627861d1 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -14,7 +14,7 @@ IMAGES=$("${INTEGRATION_ROOT}"/get-images.sh) eval "$IMAGES" unset IMAGES -RUNC="${INTEGRATION_ROOT}/../../runc" +: "${RUNC:="${INTEGRATION_ROOT}/../../runc"}" RECVTTY="${INTEGRATION_ROOT}/../../contrib/cmd/recvtty/recvtty" SD_HELPER="${INTEGRATION_ROOT}/../../contrib/cmd/sd-helper/sd-helper" SECCOMP_AGENT="${INTEGRATION_ROOT}/../../contrib/cmd/seccompagent/seccompagent" @@ -47,7 +47,7 @@ function runc() { # Some debug information to make life easier. bats will only print it if the # test failed, in which case the output is useful. # shellcheck disable=SC2154 - echo "runc $* (status=$status):" >&2 + echo "$(basename "$RUNC") $* (status=$status):" >&2 # shellcheck disable=SC2154 echo "$output" >&2 } From 5d779620996e00f8a9a404e21e5ac3570d7be648 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 8 Dec 2021 21:06:05 -0800 Subject: [PATCH 2/2] tests/int: use update_config in hooks test Using "$@" instead of $1 in update_config() allows us to use it from hooks.bats, where jq is used with more options than usual. We need to disable SC2016 as otherwise shellcheck sees $something inside single quotes and think we are losing the shell expansion (we are not). Signed-off-by: Kir Kolyshkin --- tests/integration/helpers.bash | 2 +- tests/integration/hooks.bats | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 8627861d1..aaa68dd7c 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -74,7 +74,7 @@ function runc_spec() { # Helper function to reformat config.json file. Input uses jq syntax. function update_config() { - jq "$1" "./config.json" | awk 'BEGIN{RS="";getline<"-";print>ARGV[1]}' "./config.json" + jq "$@" "./config.json" | awk 'BEGIN{RS="";getline<"-";print>ARGV[1]}' "./config.json" } # Shortcut to add additional uids and gids, based on the values set as part of diff --git a/tests/integration/hooks.bats b/tests/integration/hooks.bats index 01c1280eb..25c08aa8b 100644 --- a/tests/integration/hooks.bats +++ b/tests/integration/hooks.bats @@ -39,13 +39,13 @@ function teardown() { create_container_hook="touch ./lib/$HOOKLIBCC.1.0.0 && mount --bind $bundle/$HOOKLIBCC.1.0.0 ./lib/$HOOKLIBCC.1.0.0" - CONFIG=$(jq --arg create_runtime_hook "$create_runtime_hook" --arg create_container_hook "$create_container_hook" ' + # shellcheck disable=SC2016 + update_config --arg create_runtime_hook "$create_runtime_hook" --arg create_container_hook "$create_container_hook" ' .hooks |= . + {"createRuntime": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", $create_runtime_hook]}]} | .hooks |= . + {"createContainer": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", $create_container_hook]}]} | .hooks |= . + {"startContainer": [{"path": "/bin/sh", "args": ["/bin/sh", "-c", "ldconfig"]}]} | .root.readonly |= false | - .process.args = ["/bin/sh", "-c", "ldconfig -p | grep librunc"]' "$bundle"/config.json) - echo "${CONFIG}" >config.json + .process.args = ["/bin/sh", "-c", "ldconfig -p | grep librunc"]' runc run test_debian [ "$status" -eq 0 ]