mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
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:
@@ -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='* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user