diff options
author | Ed Santiago <santiago@redhat.com> | 2020-05-11 08:51:05 -0600 |
---|---|---|
committer | Ed Santiago <santiago@redhat.com> | 2020-05-11 09:30:09 -0600 |
commit | a82de0e3a039bb23d3a9bdb0a1cb9a56d5cec5df (patch) | |
tree | 03688e466ca937aad387585d3b2ea17452809431 /test/system/030-run.bats | |
parent | 18b273b72ba76d485eb1b4d5df48bff1685953ff (diff) | |
download | podman-a82de0e3a039bb23d3a9bdb0a1cb9a56d5cec5df.tar.gz podman-a82de0e3a039bb23d3a9bdb0a1cb9a56d5cec5df.tar.bz2 podman-a82de0e3a039bb23d3a9bdb0a1cb9a56d5cec5df.zip |
Some BATS cleanup: run and systemd tests
run test: run positive test before negative; and actually
implement real negative tests. Also, add confirmation tests for
cidfile/pidfile, not just 'exit status is good'.
systemd test: enable rootless, and again add actual content
testing.
Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/system/030-run.bats')
-rw-r--r-- | test/system/030-run.bats | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats index d5d5121f8..ae2e39d6b 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -161,17 +161,31 @@ echo $rand | 0 | $rand # 'run --conmon-pidfile --cid-file' makes sure we don't regress on these flags. # Both are critical for systemd units. @test "podman run --conmon-pidfile --cidfile" { - pid=$(mktemp) - cid=$(mktemp) - - # CID file exists -> expected to fail. - run_podman 125 run --rm --conmon-pidfile=$pid --cidfile=$cid $IMAGE ls - - rm $pid $cid - run_podman run --name keepme --conmon-pidfile=$pid --cidfile=$cid --detach $IMAGE sleep infinity - stat $pid $cid - run_podman rm -f keepme - rm $pid $cid + pidfile=${PODMAN_TMPDIR}/pidfile + cidfile=${PODMAN_TMPDIR}/cidfile + + cname=$(random_string) + run_podman run --name $cname \ + --conmon-pidfile=$pidfile \ + --cidfile=$cidfile \ + --detach \ + $IMAGE sleep infinity + cid="$output" + + is "$(< $cidfile)" "$cid" "contents of cidfile == container ID" + + conmon_pid=$(< $pidfile) + is "$(readlink /proc/$conmon_pid/exe)" ".*/conmon" \ + "conmon pidfile (= PID $conmon_pid) points to conmon process" + + # All OK. Kill container. + run_podman rm -f $cid + + # Podman must not overwrite existing cid file. + # (overwriting conmon-pidfile is OK, so don't test that) + run_podman 125 run --cidfile=$cidfile $IMAGE true + is "$output" "Error: container id file exists. .* delete $cidfile" \ + "podman will not overwrite existing cidfile" } # vim: filetype=sh |