...

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

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

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

View as plain text