github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/tests/integration/root.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  function setup() {
     6    teardown_running_container_inroot test_dotbox $HELLO_BUNDLE
     7    teardown_busybox
     8    setup_busybox
     9  }
    10  
    11  function teardown() {
    12    teardown_running_container_inroot test_dotbox $HELLO_BUNDLE
    13    teardown_busybox
    14  }
    15  
    16  @test "global --root" {
    17    # run busybox detached using $HELLO_BUNDLE for state
    18    ROOT=$HELLO_BUNDLE runc run -d --console /dev/pts/ptmx test_dotbox
    19    [ "$status" -eq 0 ]
    20  
    21    # run busybox detached in default root
    22    runc run -d --console /dev/pts/ptmx test_busybox
    23    [ "$status" -eq 0 ]
    24  
    25    # check state of the busyboxes are only in their respective root path
    26    wait_for_container 15 1 test_busybox
    27    wait_for_container_inroot 15 1 test_dotbox $HELLO_BUNDLE
    28  
    29    runc state test_busybox
    30    [ "$status" -eq 0 ]
    31    [[ "${output}" == *"running"* ]]
    32  
    33    ROOT=$HELLO_BUNDLE runc state test_dotbox
    34    [ "$status" -eq 0 ]
    35    [[ "${output}" == *"running"* ]]
    36  
    37    ROOT=$HELLO_BUNDLE runc state test_busybox
    38    [ "$status" -ne 0 ]
    39  
    40    runc state test_dotbox
    41    [ "$status" -ne 0 ]
    42  
    43    runc kill test_busybox KILL
    44    [ "$status" -eq 0 ]
    45    retry 10 1 eval "__runc state test_busybox | grep -q 'stopped'"
    46    runc delete test_busybox
    47    [ "$status" -eq 0 ]
    48  
    49    ROOT=$HELLO_BUNDLE runc kill test_dotbox KILL
    50    [ "$status" -eq 0 ]
    51    retry 10 1 eval "ROOT='$HELLO_BUNDLE' __runc state test_dotbox | grep -q 'stopped'"
    52    ROOT=$HELLO_BUNDLE runc delete test_dotbox
    53    [ "$status" -eq 0 ]
    54  }