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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-12-08 21:06:05 -08:00
parent 9e798e26cb
commit 5d77962099
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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 ]