tests/int/env.bats: add test for runc exec -p

All existing tests check runc run, and there is no single runc exec
environment test except for one in exec.bats.

Add it (no new issues found).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2026-04-29 23:09:40 -07:00
parent 6210ceb856
commit d5307867f9
+31
View File
@@ -95,3 +95,34 @@ function teardown() {
# #
[ "$(wc -l <<<"$output")" -eq 4 ] [ "$(wc -l <<<"$output")" -eq 4 ]
} }
# Check that runc exec -p process.json takes env from
# process.json only, not from config.json, and that HOME
# is always set.
@test "env [runc exec -p]" {
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]
cat <<_EOF_ >process.json
{
"terminal": false,
"args": [
"/bin/env"
],
"cwd": "/",
"env": [
"FOO=bar"
]
}
_EOF_
runc exec -p process.json test_busybox
[ "$status" -eq 0 ]
# Env should have entries from process.json.
[[ "$output" == *'FOO=bar'* ]]
# ...and HOME set from container's /etc/passwd.
[[ "$output" == *'HOME=/root'* ]]
# Env should NOT contain entries from config.json.
[[ "$output" != *'TERM='* ]]
[[ "$output" != *'PATH='* ]]
}