...

Text file src/github.com/opencontainers/runc/tests/integration/ps.bats

Documentation: github.com/opencontainers/runc/tests/integration

     1#!/usr/bin/env bats
     2
     3load helpers
     4
     5function setup() {
     6	setup_busybox
     7}
     8
     9function teardown() {
    10	teardown_bundle
    11}
    12
    13@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	runc ps test_busybox
    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]* ]]
    28}
    29
    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	runc ps -f json test_busybox
    42	[ "$status" -eq 0 ]
    43	[[ ${lines[0]} =~ [0-9]+ ]]
    44}
    45
    46@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	runc ps test_busybox -e -x
    58	[ "$status" -eq 0 ]
    59	[[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]]
    60	[[ "${lines[1]}" =~ [0-9]+ ]]
    61}
    62
    63@test "ps after the container stopped" {
    64	# ps requires cgroups
    65	[[ "$ROOTLESS" -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	runc ps test_busybox
    76	[ "$status" -eq 0 ]
    77
    78	runc kill test_busybox KILL
    79	[ "$status" -eq 0 ]
    80	wait_for_container 10 1 test_busybox stopped
    81
    82	runc ps test_busybox
    83	[ "$status" -eq 0 ]
    84}

View as plain text