From c5e7bc8710c43b12b3a621e28c5fa037a3d6f653 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 27 Aug 2025 17:43:38 -0700 Subject: [PATCH 1/2] tests/int/selinux: fix for non-standard binary name The setup in selinux.bats assumes $RUNC binary name ends in runc, and thus it fails when we run it like this: sudo -E RUNC=$(pwd)/runc.patched bats tests/integration/selinux.bats Fix is easy. Fixes: b39781b06 ("tests/int: add selinux test case") Signed-off-by: Kir Kolyshkin --- tests/integration/selinux.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/selinux.bats b/tests/integration/selinux.bats index 40a122e06..66665c450 100644 --- a/tests/integration/selinux.bats +++ b/tests/integration/selinux.bats @@ -11,7 +11,7 @@ function setup() { setup_busybox # Use a copy of runc binary with proper selinux label set. - cp "$RUNC" . + cp "$RUNC" ./runc export RUNC="$PWD/runc" chcon -u system_u -r object_r -t container_runtime_exec_t "$RUNC" From a38f42ab879a28bc8150cd4214120eb0dd58591b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 27 Aug 2025 17:58:01 -0700 Subject: [PATCH 2/2] tests/int/help: simplify and fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. In case runc binary file name is not runc, the test fails like below. The fix is to get the binary name from $RUNC. ✗ runc command -h (in test file tests/integration/help.bats, line 27) `[[ ${lines[1]} =~ runc\ checkpoint+ ]]' failed runc-go1.25.0-main checkpoint -h (status=0): NAME: runc-go1.25.0-main checkpoint - checkpoint a running container 2. Simplify the test by adding a loop for all commands. While at it, add a loop for -h --help as well. 3. Add missing commands (create, ps, features). Signed-off-by: Kir Kolyshkin --- tests/integration/help.bats | 92 ++++++++++++------------------------- 1 file changed, 30 insertions(+), 62 deletions(-) diff --git a/tests/integration/help.bats b/tests/integration/help.bats index 04bbc80cf..64cc66f67 100644 --- a/tests/integration/help.bats +++ b/tests/integration/help.bats @@ -22,69 +22,37 @@ function setup() { } @test "runc command -h" { - runc checkpoint -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ checkpoint+ ]] - - runc delete -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ delete+ ]] - - runc events -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ events+ ]] - - runc exec -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ exec+ ]] - - runc kill -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ kill+ ]] - - runc list -h - [ "$status" -eq 0 ] - [[ ${lines[0]} =~ NAME:+ ]] - [[ ${lines[1]} =~ runc\ list+ ]] - - runc list --help - [ "$status" -eq 0 ] - [[ ${lines[0]} =~ NAME:+ ]] - [[ ${lines[1]} =~ runc\ list+ ]] - - runc pause -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ pause+ ]] - - runc restore -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ restore+ ]] - - runc resume -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ resume+ ]] - - # We don't use runc_spec here, because we're just testing the help page. - runc spec -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ spec+ ]] - - runc start -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ start+ ]] - - runc run -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ run+ ]] - - runc state -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ state+ ]] - - runc update -h - [ "$status" -eq 0 ] - [[ ${lines[1]} =~ runc\ update+ ]] + local runc + # shellcheck disable=SC2153 + runc="$(basename "$RUNC")" + local cmds=( + checkpoint + create + delete + events + exec + kill + list + pause + ps + restore + resume + run + spec + start + state + update + features + ) + for cmd in "${cmds[@]}"; do + for arg in "-h" "--help"; do + runc "$cmd" "$arg" + [ "$status" -eq 0 ] + [[ ${lines[0]} =~ NAME:+ ]] + [[ ${lines[1]} =~ $runc\ $cmd+ ]] + done + done } @test "runc foo -h" {