github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/tests/integration/ps.bats (about) 1 #!/usr/bin/env bats 2 3 load helpers 4 5 function setup() { 6 teardown_busybox 7 setup_busybox 8 } 9 10 function teardown() { 11 teardown_busybox 12 } 13 14 @test "ps" { 15 # start busybox detached 16 runc run -d --console /dev/pts/ptmx test_busybox 17 [ "$status" -eq 0 ] 18 19 # check state 20 wait_for_container 15 1 test_busybox 21 22 testcontainer test_busybox running 23 24 runc ps test_busybox 25 [ "$status" -eq 0 ] 26 [[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] 27 [[ "${lines[1]}" == *"root"*[0-9]* ]] 28 } 29 30 @test "ps -f json" { 31 # start busybox detached 32 runc run -d --console /dev/pts/ptmx test_busybox 33 [ "$status" -eq 0 ] 34 35 # check state 36 wait_for_container 15 1 test_busybox 37 38 testcontainer test_busybox running 39 40 runc ps -f json test_busybox 41 [ "$status" -eq 0 ] 42 [[ ${lines[0]} =~ [0-9]+ ]] 43 } 44 45 @test "ps -e -x" { 46 # start busybox detached 47 runc run -d --console /dev/pts/ptmx test_busybox 48 [ "$status" -eq 0 ] 49 50 # check state 51 wait_for_container 15 1 test_busybox 52 53 testcontainer test_busybox running 54 55 runc ps test_busybox -e -x 56 [ "$status" -eq 0 ] 57 [[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] 58 [[ "${lines[1]}" =~ [0-9]+ ]] 59 }