github.com/containers/podman/v5@v5.1.0-rc1/test/system/190-run-ipcns.bats (about)

     1  #!/usr/bin/env bats   -*- bats -*-
     2  # shellcheck disable=SC2096
     3  #
     4  # Tests for podman build
     5  #
     6  # bats file_tags=distro-integration
     7  #
     8  
     9  load helpers
    10  
    11  @test "podman --ipc=host" {
    12      hostipc="$(readlink /proc/self/ns/ipc)"
    13      run_podman run --name IPC --ipc=host $IMAGE readlink /proc/self/ns/ipc
    14      is "$output" "$hostipc" "HostIPC and container IPC should be same"
    15      run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}'
    16      is "$output" "host" "host mode should be selected"
    17      run_podman rm IPC
    18  }
    19  
    20  @test "podman --ipc=none" {
    21      hostipc="$(readlink /proc/self/ns/ipc)"
    22      run_podman run --ipc=none --name IPC $IMAGE readlink /proc/self/ns/ipc
    23      assert "$output" != "$hostipc" "containeripc should != hostipc"
    24      run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}'
    25      is "$output" "none" "none mode should be selected"
    26      run_podman rm IPC
    27  
    28      run_podman 1 run --rm --ipc=none $IMAGE ls /dev/shm
    29      is "$output" "ls: /dev/shm: No such file or directory" "Should fail with missing /dev/shm"
    30  }
    31  
    32  @test "podman --ipc=private" {
    33      hostipc="$(readlink /proc/self/ns/ipc)"
    34      run_podman run -d --ipc=private --name test $IMAGE sleep 100
    35      assert "$output" != "$hostipc" "containeripc should != hostipc"
    36      run_podman inspect test --format '{{ .HostConfig.IpcMode }}'
    37      is "$output" "private" "private mode should be selected"
    38  
    39      run_podman 125 run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc
    40      is "$output" ".*is not allowed: non-shareable IPC (hint: use IpcMode:shareable for the donor container)" "Containers should not share private ipc namespace"
    41      run_podman stop -t 0 test
    42      run_podman rm test
    43  }
    44  
    45  @test "podman --ipc=shareable" {
    46      hostipc="$(readlink /proc/self/ns/ipc)"
    47      run_podman run -d --ipc=shareable --name test $IMAGE sleep 100
    48      assert "$output" != "$hostipc" "containeripc(shareable) should != hostipc"
    49      run_podman inspect test --format '{{ .HostConfig.IpcMode }}'
    50      is "$output" "shareable" "shareable mode should be selected"
    51  
    52      run_podman run --ipc=container:test --rm $IMAGE readlink /proc/self/ns/ipc
    53      assert "$output" != "$hostipc" "containeripc(:test) should != hostipc"
    54  
    55      run_podman stop -t 0 test
    56      run_podman rm test
    57  }
    58  
    59  @test "podman --ipc=container@test" {
    60      hostipc="$(readlink /proc/self/ns/ipc)"
    61      run_podman run -d --name test $IMAGE sleep 100
    62      containerid=$output
    63      run_podman inspect test --format '{{ .HostConfig.IpcMode }}'
    64      is "$output" "shareable" "shareable mode should be selected"
    65      run_podman exec test readlink /proc/self/ns/ipc
    66      assert "$output" != "$hostipc" "containeripc(exec) should != hostipc"
    67  
    68      testipc=$output
    69      run_podman run --name IPC --ipc=container:test $IMAGE readlink /proc/self/ns/ipc
    70      assert "$output" = "$testipc" "Containers should share ipc namespace"
    71      run_podman inspect IPC --format '{{ .HostConfig.IpcMode }}'
    72      is "$output" "container:$containerid" "ipc mode should be selected"
    73      run_podman rm IPC
    74  
    75      run_podman stop -t 0 test
    76      run_podman rm test
    77  }
    78  
    79  # vim: filetype=sh