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

     1  #!/usr/bin/env bats
     2  
     3  load helpers
     4  
     5  function setup() {
     6    teardown_hello
     7    setup_hello
     8  }
     9  
    10  function teardown() {
    11    teardown_hello
    12  }
    13  
    14  @test "runc run" {
    15    # run hello-world
    16    runc run test_hello
    17    [ "$status" -eq 0 ]
    18  
    19    # check expected output
    20    [[ "${output}" == *"Hello"* ]]
    21  }
    22  
    23  @test "runc run ({u,g}id != 0)" {
    24    # replace "uid": 0 with "uid": 1000
    25    # and do a similar thing for gid.
    26    sed -i 's;"uid": 0;"uid": 1000;g' config.json
    27    sed -i 's;"gid": 0;"gid": 100;g' config.json
    28  
    29    # run hello-world
    30    runc run test_hello
    31    [ "$status" -eq 0 ]
    32  
    33    # check expected output
    34    [[ "${output}" == *"Hello"* ]]
    35  }
    36  
    37  @test "runc run with rootfs set to ." {
    38    cp config.json rootfs/.
    39    rm config.json
    40    cd rootfs
    41    sed -i 's;"rootfs";".";' config.json
    42  
    43    # run hello-world
    44    runc run test_hello
    45    [ "$status" -eq 0 ]
    46    [[ "${output}" == *"Hello"* ]]
    47  }
    48  
    49  @test "runc run --pid-file" {
    50    # run hello-world
    51    runc run --pid-file pid.txt test_hello
    52    [ "$status" -eq 0 ]
    53    [[ "${output}" == *"Hello"* ]]
    54  
    55    # check pid.txt was generated
    56    [ -e pid.txt ]
    57  
    58    run cat pid.txt
    59    [ "$status" -eq 0 ]
    60    [[ ${lines[0]} =~ [0-9]+ ]]
    61  }