github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/tests/integration/list.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  function setup() {
     6  	setup_busybox
     7  	ALT_ROOT="$ROOT/alt"
     8  	mkdir -p "$ALT_ROOT/state"
     9  }
    10  
    11  function teardown() {
    12  	ROOT="$ALT_ROOT" teardown_bundle
    13  	unset ALT_ROOT
    14  	teardown_bundle
    15  }
    16  
    17  @test "list" {
    18  	bundle=$(pwd)
    19  	# run a few busyboxes detached
    20  	ROOT=$ALT_ROOT runc run -d --console-socket "$CONSOLE_SOCKET" test_box1
    21  	[ "$status" -eq 0 ]
    22  
    23  	ROOT=$ALT_ROOT runc run -d --console-socket "$CONSOLE_SOCKET" test_box2
    24  	[ "$status" -eq 0 ]
    25  
    26  	ROOT=$ALT_ROOT runc run -d --console-socket "$CONSOLE_SOCKET" test_box3
    27  	[ "$status" -eq 0 ]
    28  
    29  	ROOT=$ALT_ROOT runc list
    30  	[ "$status" -eq 0 ]
    31  	[[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]]
    32  	[[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$bundle*[0-9]* ]]
    33  	[[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$bundle*[0-9]* ]]
    34  	[[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$bundle*[0-9]* ]]
    35  
    36  	ROOT=$ALT_ROOT runc list -q
    37  	[ "$status" -eq 0 ]
    38  	[ "${lines[0]}" = "test_box1" ]
    39  	[ "${lines[1]}" = "test_box2" ]
    40  	[ "${lines[2]}" = "test_box3" ]
    41  
    42  	ROOT=$ALT_ROOT runc list --format table
    43  	[ "$status" -eq 0 ]
    44  	[[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]]
    45  	[[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$bundle*[0-9]* ]]
    46  	[[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$bundle*[0-9]* ]]
    47  	[[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$bundle*[0-9]* ]]
    48  
    49  	ROOT=$ALT_ROOT runc list --format json
    50  	[ "$status" -eq 0 ]
    51  	[[ "${lines[0]}" == [\[][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box1\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$bundle*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]]
    52  	[[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box2\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$bundle*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]]
    53  	[[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box3\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$bundle*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}][\]] ]]
    54  }