#!/usr/bin/env bats -*- bats -*- # # tests for podman kill # load helpers # bats test_tags=distro-integration, ci:parallel @test "podman kill - test signal handling in containers" { local cname=c-$(safename) local fifo=${PODMAN_TMPDIR}/podman-kill-fifo.$(random_string 10) mkfifo $fifo # Start a container that will handle all signals by emitting 'got: N' local -a signals=(1 2 3 4 5 6 8 10 12 13 14 15 16 20 21 22 23 24 25 26 64) $PODMAN run --name $cname $IMAGE sh -c \ "for i in ${signals[*]}; do trap \"echo got: \$i\" \$i; done; echo READY; while ! test -e /stop; do sleep 0.1; done; echo DONE" &>$fifo exit code == 0 run_podman wait $cname # Container did not start successfully -> exit code != 0 run_podman 125 start $cname # FIXME(#14873): while older Podmans return 0 on wait, Docker does not. run_podman wait $cname run_podman rm $cname } # bats test_tags=ci:parallel @test "podman kill - no restart" { ctr=c-$(safename) run_podman run -d --restart=always --name=$ctr $IMAGE \ sh -c "trap 'exit 42' SIGTERM; echo READY; while :; do sleep 0.2; done" run_podman container inspect --format "{{.State.Status}}" $ctr is "$output" "running" "make sure container is running" # Send SIGTERM and make sure the container exits. run_podman kill -s=TERM $ctr run_podman wait $ctr is "$output" "42" "container exits with 42 on receiving SIGTERM" run_podman container inspect --format "{{.State.StoppedByUser}}" $ctr is "$output" "true" "container is marked to be stopped by a user" run_podman rm $ctr } # vim: filetype=sh