|
3 | 3 | load helpers |
4 | 4 |
|
5 | 5 | function setup() { |
| 6 | + # ps requires cgroups |
| 7 | + [ $EUID -ne 0 ] && requires rootless_cgroup |
| 8 | + |
6 | 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 |
7 | 17 | } |
8 | 18 |
|
9 | 19 | function teardown() { |
10 | 20 | teardown_bundle |
11 | 21 | } |
12 | 22 |
|
13 | 23 | @test "ps" { |
14 | | - # ps is not supported, it requires cgroups |
15 | | - requires root |
16 | | - |
17 | | - # start busybox detached |
18 | | - runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox |
19 | | - [ "$status" -eq 0 ] |
20 | | - |
21 | | - # check state |
22 | | - testcontainer test_busybox running |
23 | | - |
24 | 24 | runc ps test_busybox |
25 | 25 | [ "$status" -eq 0 ] |
26 | | - [[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] |
27 | | - [[ "${lines[1]}" == *"$(id -un 2>/dev/null)"*[0-9]* ]] |
| 26 | + [[ "$output" =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] |
| 27 | + [[ "$output" == *"$(id -un 2>/dev/null)"*[0-9]* ]] |
28 | 28 | } |
29 | 29 |
|
30 | 30 | @test "ps -f json" { |
31 | | - # ps is not supported, it requires cgroups |
32 | | - requires root |
33 | | - |
34 | | - # start busybox detached |
35 | | - runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox |
36 | | - [ "$status" -eq 0 ] |
37 | | - |
38 | | - # check state |
39 | | - testcontainer test_busybox running |
40 | | - |
41 | 31 | runc ps -f json test_busybox |
42 | 32 | [ "$status" -eq 0 ] |
43 | | - [[ ${lines[0]} =~ [0-9]+ ]] |
| 33 | + [[ "$output" =~ [0-9]+ ]] |
44 | 34 | } |
45 | 35 |
|
46 | 36 | @test "ps -e -x" { |
47 | | - # ps is not supported, it requires cgroups |
48 | | - requires root |
49 | | - |
50 | | - # start busybox detached |
51 | | - runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox |
52 | | - [ "$status" -eq 0 ] |
53 | | - |
54 | | - # check state |
55 | | - testcontainer test_busybox running |
56 | | - |
57 | 37 | runc ps test_busybox -e -x |
58 | 38 | [ "$status" -eq 0 ] |
59 | | - [[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] |
60 | | - [[ "${lines[1]}" =~ [0-9]+ ]] |
| 39 | + [[ "$output" =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] |
| 40 | + [[ "$output" =~ [0-9]+ ]] |
61 | 41 | } |
62 | 42 |
|
63 | 43 | @test "ps after the container stopped" { |
64 | | - # ps requires cgroups |
65 | | - [ $EUID -ne 0 ] && requires rootless_cgroup |
66 | | - set_cgroups_path |
67 | | - |
68 | | - # start busybox detached |
69 | | - runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox |
70 | | - [ "$status" -eq 0 ] |
71 | | - |
72 | | - # check state |
73 | | - testcontainer test_busybox running |
74 | | - |
75 | 44 | runc ps test_busybox |
76 | 45 | [ "$status" -eq 0 ] |
77 | 46 |
|
|
0 commit comments