Skip to content

Commit c283ed1

Browse files
committed
tests/int: add hooks argv[0] test
Looking into old opened runc issues, I noticed #1663 is there without any resolution, and wrote this simple test checking if we mangle hook's argv[0] in any way. Apparently we're good, but the test actually makes sense to have. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 35b3c16 commit c283ed1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/integration/hooks.bats

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,20 @@ function teardown() {
6363
runc run ct1
6464
[ "$status" -eq 0 ]
6565
}
66+
67+
# https://github.com/opencontainers/runc/issues/1663
68+
@test "runc run [hook's argv is preserved]" {
69+
# Check that argv[0] and argv[1] passed to the hook's binary
70+
# exactly as set in config.json.
71+
update_config '.hooks |= {"startContainer": [{"path": "/bin/busybox", "args": ["cat", "/nosuchfile"]}]}'
72+
runc run ct1
73+
[ "$status" -ne 0 ]
74+
[[ "$output" == *"cat: can't open"*"/nosuchfile"* ]]
75+
76+
# Busybox also accepts commands where argv[0] is "busybox",
77+
# and argv[1] is applet name. Test this as well.
78+
update_config '.hooks |= {"startContainer": [{"path": "/bin/busybox", "args": ["busybox", "cat", "/nosuchfile"]}]}'
79+
runc run ct1
80+
[ "$status" -ne 0 ]
81+
[[ "$output" == *"cat: can't open"*"/nosuchfile"* ]]
82+
}

0 commit comments

Comments
 (0)