You've already forked runc
mirror of
https://github.com/opencontainers/runc.git
synced 2025-11-03 15:33:15 +03:00
Currently, the id verification in integration test failed on arm platform due to the inconsistent /etc/group in the busybox images for arm and x86. To be specific, the nogroup id in x86 is 99 while that in arm is 65534. 99 is old id for nogroup, and no longer be used in recent system, so sync the busybox image for arm and x86 to the image in busybox github. Also change the id verification rule in integration test. Signed-off-by: Howard Zhang <howard.zhang@arm.com>
141 lines
3.4 KiB
Bash
141 lines
3.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
function setup() {
|
|
teardown_busybox
|
|
setup_busybox
|
|
}
|
|
|
|
function teardown() {
|
|
teardown_busybox
|
|
}
|
|
|
|
@test "runc exec" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec test_busybox echo Hello from exec
|
|
[ "$status" -eq 0 ]
|
|
echo text echoed = "'""${output}""'"
|
|
[[ "${output}" == *"Hello from exec"* ]]
|
|
}
|
|
|
|
@test "runc exec --pid-file" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec --pid-file pid.txt test_busybox echo Hello from exec
|
|
[ "$status" -eq 0 ]
|
|
echo text echoed = "'""${output}""'"
|
|
[[ "${output}" == *"Hello from exec"* ]]
|
|
|
|
# check pid.txt was generated
|
|
[ -e pid.txt ]
|
|
|
|
run cat pid.txt
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ [0-9]+ ]]
|
|
[[ ${lines[0]} != $(__runc state test_busybox | jq '.pid') ]]
|
|
}
|
|
|
|
@test "runc exec --pid-file with new CWD" {
|
|
# create pid_file directory as the CWD
|
|
run mkdir pid_file
|
|
[ "$status" -eq 0 ]
|
|
run cd pid_file
|
|
[ "$status" -eq 0 ]
|
|
|
|
# run busybox detached
|
|
runc run -d -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec --pid-file pid.txt test_busybox echo Hello from exec
|
|
[ "$status" -eq 0 ]
|
|
echo text echoed = "'""${output}""'"
|
|
[[ "${output}" == *"Hello from exec"* ]]
|
|
|
|
# check pid.txt was generated
|
|
[ -e pid.txt ]
|
|
|
|
run cat pid.txt
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ [0-9]+ ]]
|
|
[[ ${lines[0]} != $(__runc state test_busybox | jq '.pid') ]]
|
|
}
|
|
|
|
@test "runc exec ls -la" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec test_busybox ls -la
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} == *"total"* ]]
|
|
[[ ${lines[1]} == *"."* ]]
|
|
[[ ${lines[2]} == *".."* ]]
|
|
}
|
|
|
|
@test "runc exec ls -la with --cwd" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec --cwd /bin test_busybox pwd
|
|
[ "$status" -eq 0 ]
|
|
[[ ${output} == "/bin"* ]]
|
|
}
|
|
|
|
@test "runc exec --env" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec --env RUNC_EXEC_TEST=true test_busybox env
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${output} == *"RUNC_EXEC_TEST=true"* ]]
|
|
}
|
|
|
|
@test "runc exec --user" {
|
|
# --user can't work in rootless containers that don't have idmap.
|
|
[[ "$ROOTLESS" -ne 0 ]] && requires rootless_idmap
|
|
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
runc exec --user 1000:1000 test_busybox id
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" == "uid=1000 gid=1000"* ]]
|
|
}
|
|
|
|
@test "runc exec --additional-gids" {
|
|
requires root
|
|
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
wait_for_container 15 1 test_busybox
|
|
|
|
runc exec --user 1000:1000 --additional-gids 100 --additional-gids 65534 test_busybox id
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${output} == "uid=1000 gid=1000 groups=100(users),65534(nogroup)" ]]
|
|
}
|
|
|
|
@test "runc exec --preserve-fds" {
|
|
# run busybox detached
|
|
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
run bash -c "cat hello > preserve-fds.test; exec 3<preserve-fds.test; $RUNC ${RUNC_USE_SYSTEMD:+--systemd-cgroup} --log /proc/self/fd/2 --root $ROOT exec --preserve-fds=1 test_busybox cat /proc/self/fd/3"
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" == *"hello"* ]]
|
|
}
|