-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3804 from edsantiago/bats
tests for exit status on podman run --rm
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# tests for podman rm | ||
# | ||
|
||
load helpers | ||
|
||
@test "podman rm" { | ||
rand=$(random_string 30) | ||
run_podman run --name $rand $IMAGE /bin/true | ||
|
||
# Don't care about output, just check exit status (it should exist) | ||
run_podman 0 inspect $rand | ||
|
||
# container should be in output of 'ps -a' | ||
run_podman ps -a | ||
is "$output" ".* $IMAGE .*/true .* $rand" "Container present in 'ps -a'" | ||
|
||
# Remove container; now 'inspect' should fail | ||
run_podman rm $rand | ||
run_podman 125 inspect $rand | ||
} | ||
|
||
# I'm sorry! This test takes 13 seconds. There's not much I can do about it, | ||
# please know that I think it's justified: podman 1.5.0 had a strange bug | ||
# in with exit status was not preserved on some code paths with 'rm -f' | ||
# or 'podman run --rm' (see also 030-run.bats). The test below is a bit | ||
# kludgy: what we care about is the exit status of the killed container, | ||
# not 'podman rm', but BATS has no provision (that I know of) for forking, | ||
# so what we do is start the 'rm' beforehand and monitor the exit status | ||
# of the 'sleep' container. | ||
# | ||
# See https://github.com/containers/libpod/issues/3795 | ||
@test "podman rm -f" { | ||
skip_if_remote "podman-remote does not handle exit codes" | ||
|
||
rand=$(random_string 30) | ||
( sleep 3; run_podman rm -f $rand ) & | ||
run_podman 137 run --name $rand $IMAGE sleep 30 | ||
} | ||
|
||
# vim: filetype=sh |