github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/tests/integration/pause.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 pause and resume" {
    15    # run busybox detached
    16    runc run -d --console /dev/pts/ptmx test_busybox
    17    [ "$status" -eq 0 ]
    18  
    19    wait_for_container 15 1 test_busybox
    20  
    21    # pause busybox
    22    runc pause test_busybox
    23    [ "$status" -eq 0 ]
    24  
    25    # test state of busybox is paused
    26    testcontainer test_busybox paused
    27  
    28    # resume busybox
    29    runc resume test_busybox
    30    [ "$status" -eq 0 ]
    31  
    32    # test state of busybox is back to running
    33    testcontainer test_busybox running
    34  }
    35  
    36  @test "runc pause and resume with multi-container" {
    37    # run test_busybox1 detached
    38    runc run -d --console /dev/pts/ptmx test_busybox1
    39    [ "$status" -eq 0 ]
    40  
    41    wait_for_container 15 1 test_busybox1
    42  
    43    # run test_busybox2 detached
    44    runc run -d --console /dev/pts/ptmx test_busybox2
    45    [ "$status" -eq 0 ]
    46  
    47    wait_for_container 15 1 test_busybox2
    48  
    49    # pause test_busybox1 and test_busybox2
    50    runc pause test_busybox1 test_busybox2
    51    [ "$status" -eq 0 ]
    52  
    53    # test state of test_busybox1 and test_busybox2 is paused
    54    testcontainer test_busybox1 paused
    55    testcontainer test_busybox2 paused
    56  
    57    # resume test_busybox1 and test_busybox2
    58    runc resume test_busybox1 test_busybox2
    59    [ "$status" -eq 0 ]
    60  
    61    # test state of two containers is back to running
    62    testcontainer test_busybox1 running
    63    testcontainer test_busybox2 running
    64  
    65    # delete test_busybox1 and test_busybox2
    66    runc delete --force test_busybox1 test_busybox2
    67  
    68    runc state test_busybox1
    69    [ "$status" -ne 0 ]
    70  
    71    runc state test_busybox2
    72    [ "$status" -ne 0 ]
    73  }
    74  
    75  @test "runc pause and resume with nonexist container" {
    76    # run test_busybox1 detached
    77    runc run -d --console /dev/pts/ptmx test_busybox1
    78    [ "$status" -eq 0 ]
    79  
    80    wait_for_container 15 1 test_busybox1
    81  
    82    # run test_busybox2 detached
    83    runc run -d --console /dev/pts/ptmx test_busybox2
    84    [ "$status" -eq 0 ]
    85  
    86    wait_for_container 15 1 test_busybox2
    87  
    88    # pause test_busybox1, test_busybox2 and nonexistant container
    89    runc pause test_busybox1 test_busybox2 nonexistant
    90    [ "$status" -ne 0 ]
    91  
    92    # test state of test_busybox1 and test_busybox2 is paused
    93    testcontainer test_busybox1 paused
    94    testcontainer test_busybox2 paused
    95  
    96    # resume test_busybox1, test_busybox2 and nonexistant container
    97    runc resume test_busybox1 test_busybox2 nonexistant
    98    [ "$status" -ne 0 ]
    99  
   100    # test state of two containers is back to running
   101    testcontainer test_busybox1 running
   102    testcontainer test_busybox2 running
   103  
   104    # delete test_busybox1 and test_busybox2
   105    runc delete --force test_busybox1 test_busybox2
   106  
   107    runc state test_busybox1
   108    [ "$status" -ne 0 ]
   109  
   110    runc state test_busybox2
   111    [ "$status" -ne 0 ]
   112  }