github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/tests/integration/ps.bats (about) 1 #!/usr/bin/env bats 2 3 load helpers 4 5 function setup() { 6 # ps requires cgroups 7 [ $EUID -ne 0 ] && requires rootless_cgroup 8 9 setup_busybox 10 11 # Rootless does not have default cgroup path. 12 [ $EUID -ne 0 ] && set_cgroups_path 13 14 runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox 15 [ "$status" -eq 0 ] 16 testcontainer test_busybox running 17 } 18 19 function teardown() { 20 teardown_bundle 21 } 22 23 @test "ps" { 24 runc ps test_busybox 25 [ "$status" -eq 0 ] 26 [[ "$output" =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] 27 [[ "$output" == *"$(id -un 2>/dev/null)"*[0-9]* ]] 28 } 29 30 @test "ps -f json" { 31 runc ps -f json test_busybox 32 [ "$status" -eq 0 ] 33 [[ "$output" =~ [0-9]+ ]] 34 } 35 36 @test "ps -e -x" { 37 runc ps test_busybox -e -x 38 [ "$status" -eq 0 ] 39 [[ "$output" =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] 40 [[ "$output" =~ [0-9]+ ]] 41 } 42 43 @test "ps after the container stopped" { 44 runc ps test_busybox 45 [ "$status" -eq 0 ] 46 47 runc kill test_busybox KILL 48 [ "$status" -eq 0 ] 49 wait_for_container 10 1 test_busybox stopped 50 51 runc ps test_busybox 52 [ "$status" -eq 0 ] 53 }