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

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  function setup() {
     6    teardown_busybox
     7    setup_busybox
     8  }
     9  
    10  function teardown() {
    11    teardown_busybox
    12  }
    13  
    14  @test "runc create" {
    15    runc create --console /dev/pts/ptmx test_busybox
    16    [ "$status" -eq 0 ]
    17  
    18    testcontainer test_busybox created
    19  
    20    # start the command
    21    runc start test_busybox
    22    [ "$status" -eq 0 ]
    23  
    24    testcontainer test_busybox running
    25  }
    26  
    27  @test "runc create exec" {
    28    runc create --console /dev/pts/ptmx test_busybox
    29    [ "$status" -eq 0 ]
    30  
    31    testcontainer test_busybox created
    32  
    33    runc exec test_busybox true
    34    [ "$status" -eq 0 ]
    35  
    36    # start the command
    37    runc start test_busybox
    38    [ "$status" -eq 0 ]
    39  
    40    testcontainer test_busybox running
    41  }
    42  
    43  @test "runc create --pid-file" {
    44    runc create --pid-file pid.txt --console /dev/pts/ptmx test_busybox
    45    [ "$status" -eq 0 ]
    46  
    47    testcontainer test_busybox created
    48  
    49    # check pid.txt was generated
    50    [ -e pid.txt ]
    51  
    52    run cat pid.txt
    53    [ "$status" -eq 0 ]
    54    [[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]]
    55  
    56    # start the command
    57    runc start test_busybox
    58    [ "$status" -eq 0 ]
    59  
    60    testcontainer test_busybox running
    61  }