github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/system/055-rm.bats (about) 1 #!/usr/bin/env bats -*- bats -*- 2 # 3 # tests for podman rm 4 # 5 6 load helpers 7 8 @test "podman rm" { 9 rand=$(random_string 30) 10 run_podman run --name $rand $IMAGE /bin/true 11 12 # Don't care about output, just check exit status (it should exist) 13 run_podman 0 inspect $rand 14 15 # container should be in output of 'ps -a' 16 run_podman ps -a 17 is "$output" ".* $IMAGE .*/true .* $rand" "Container present in 'ps -a'" 18 19 # Remove container; now 'inspect' should fail 20 run_podman rm $rand 21 run_podman 125 inspect $rand 22 } 23 24 # I'm sorry! This test takes 13 seconds. There's not much I can do about it, 25 # please know that I think it's justified: podman 1.5.0 had a strange bug 26 # in with exit status was not preserved on some code paths with 'rm -f' 27 # or 'podman run --rm' (see also 030-run.bats). The test below is a bit 28 # kludgy: what we care about is the exit status of the killed container, 29 # not 'podman rm', but BATS has no provision (that I know of) for forking, 30 # so what we do is start the 'rm' beforehand and monitor the exit status 31 # of the 'sleep' container. 32 # 33 # See https://github.com/containers/libpod/issues/3795 34 @test "podman rm -f" { 35 rand=$(random_string 30) 36 ( sleep 3; run_podman rm -f $rand ) & 37 run_podman 137 run --name $rand $IMAGE sleep 30 38 } 39 40 # vim: filetype=sh