From d5307867f92f1c7bb3a394b9759238081ecbe5a5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 29 Apr 2026 23:09:40 -0700 Subject: [PATCH] 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 --- tests/integration/env.bats | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/integration/env.bats b/tests/integration/env.bats index cb984942e..4521fe735 100644 --- a/tests/integration/env.bats +++ b/tests/integration/env.bats @@ -95,3 +95,34 @@ function teardown() { # [ "$(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='* ]] +}