aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/checkpoint_test.go20
-rw-r--r--test/e2e/cp_test.go27
-rw-r--r--test/e2e/create_test.go2
-rw-r--r--test/e2e/e2e.coverprofile11
-rw-r--r--test/e2e/generate_systemd_test.go28
-rw-r--r--test/e2e/info_test.go2
-rw-r--r--test/e2e/inspect_test.go13
-rw-r--r--test/e2e/libpod_suite_remoteclient_test.go2
-rw-r--r--test/e2e/logs_test.go19
-rw-r--r--test/e2e/play_kube_test.go11
-rw-r--r--test/e2e/ps_test.go37
-rw-r--r--test/e2e/untag_test.go73
-rw-r--r--test/system/010-images.bats39
-rw-r--r--test/system/130-kill.bats101
-rw-r--r--test/system/helpers.bash2
15 files changed, 355 insertions, 32 deletions
diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go
index f208a4cf0..237223283 100644
--- a/test/e2e/checkpoint_test.go
+++ b/test/e2e/checkpoint_test.go
@@ -439,6 +439,18 @@ var _ = Describe("Podman checkpoint", func() {
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(0))
+ result = podmanTest.Podman([]string{"exec", "-l", "/bin/sh", "-c", "rm /etc/motd"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+
+ result = podmanTest.Podman([]string{"diff", "-l"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(result.OutputToString()).To(ContainSubstring("C /etc"))
+ Expect(result.OutputToString()).To(ContainSubstring("A /test.output"))
+ Expect(result.OutputToString()).To(ContainSubstring("D /etc/motd"))
+ Expect(len(result.OutputToStringArray())).To(Equal(3))
+
// Checkpoint the container
result = podmanTest.Podman([]string{"container", "checkpoint", "-l", "-e", fileName})
result.WaitWithDefaultTimeout()
@@ -462,6 +474,14 @@ var _ = Describe("Podman checkpoint", func() {
Expect(result.ExitCode()).To(Equal(0))
Expect(result.OutputToString()).To(ContainSubstring("test" + cid + "test"))
+ result = podmanTest.Podman([]string{"diff", "-l"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(result.OutputToString()).To(ContainSubstring("C /etc"))
+ Expect(result.OutputToString()).To(ContainSubstring("A /test.output"))
+ Expect(result.OutputToString()).To(ContainSubstring("D /etc/motd"))
+ Expect(len(result.OutputToStringArray())).To(Equal(3))
+
// Remove exported checkpoint
os.Remove(fileName)
})
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index 8d4c3dee7..b71897cfd 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -112,6 +112,33 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
+
+ testctr := "testctr"
+ setup := podmanTest.RunTopContainer(testctr)
+ setup.WaitWithDefaultTimeout()
+ Expect(setup.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"exec", testctr, "mkdir", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"cp", testDirPath + "/.", testctr + ":/foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ session = podmanTest.Podman([]string{"exec", testctr, "ls", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToString())).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"cp", testctr + ":/foo/.", testDirPath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ cmd := exec.Command("ls", testDirPath)
+ res, err := cmd.Output()
+ Expect(err).To(BeNil())
+ Expect(len(res)).To(Equal(0))
+
+ os.RemoveAll(testDirPath)
})
It("podman cp stdin/stdout", func() {
diff --git a/test/e2e/create_test.go b/test/e2e/create_test.go
index 7d977f4e3..134b7b162 100644
--- a/test/e2e/create_test.go
+++ b/test/e2e/create_test.go
@@ -285,7 +285,7 @@ var _ = Describe("Podman create", func() {
})
It("podman create using cross-arch image list instance by digest", func() {
- session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=ppc64le", "--name=foo", ALPINEARM64DIGEST})
+ session := podmanTest.PodmanNoCache([]string{"create", "--pull=always", "--override-arch=arm64", "--name=foo", ALPINEARM64DIGEST})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To((Equal(0)))
session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.Image}}", "foo"})
diff --git a/test/e2e/e2e.coverprofile b/test/e2e/e2e.coverprofile
deleted file mode 100644
index d413679ea..000000000
--- a/test/e2e/e2e.coverprofile
+++ /dev/null
@@ -1,11 +0,0 @@
-mode: atomic
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:14.46,21.20 2 3
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:32.2,32.19 1 3
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:39.2,39.53 1 3
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:66.2,66.52 1 3
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:21.20,23.17 2 6
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:26.3,29.36 4 6
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:23.17,25.4 1 0
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:32.19,37.3 3 6
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:39.53,64.3 20 3
-github.com/containers/libpod/test/e2e/pod_pod_namespaces.go:66.52,91.3 20 3 \ No newline at end of file
diff --git a/test/e2e/generate_systemd_test.go b/test/e2e/generate_systemd_test.go
index 91072b023..f0fef41a4 100644
--- a/test/e2e/generate_systemd_test.go
+++ b/test/e2e/generate_systemd_test.go
@@ -177,4 +177,32 @@ var _ = Describe("Podman generate systemd", func() {
found, _ = session.GrepString("/container-foo-1.service")
Expect(found).To(BeTrue())
})
+
+ It("podman generate systemd --new", func() {
+ n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // Grepping the output (in addition to unit tests)
+ found, _ := session.GrepString("# container-foo.service")
+ Expect(found).To(BeTrue())
+
+ found, _ = session.GrepString("stop --cidfile /%t/%n-cid -t 42")
+ Expect(found).To(BeTrue())
+ })
+
+ It("podman generate systemd --new pod", func() {
+ n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
+ n.WaitWithDefaultTimeout()
+ Expect(n.ExitCode()).To(Equal(0))
+
+ session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(125))
+ })
+
})
diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go
index d3b1b974e..d16661d5b 100644
--- a/test/e2e/info_test.go
+++ b/test/e2e/info_test.go
@@ -1,5 +1,3 @@
-// +build !remoteclient
-
package integration
import (
diff --git a/test/e2e/inspect_test.go b/test/e2e/inspect_test.go
index 7d029c52f..9d23384ea 100644
--- a/test/e2e/inspect_test.go
+++ b/test/e2e/inspect_test.go
@@ -86,6 +86,7 @@ var _ = Describe("Podman inspect", func() {
Expect(result.ExitCode()).To(Equal(0))
conData := result.InspectContainerToJSON()
Expect(conData[0].SizeRootFs).To(BeNumerically(">", 0))
+ Expect(*conData[0].SizeRw).To(BeNumerically(">=", 0))
})
It("podman inspect container and image", func() {
@@ -117,6 +118,18 @@ var _ = Describe("Podman inspect", func() {
Expect(len(result.OutputToStringArray())).To(Equal(1))
})
+ It("podman inspect container and filter for CreateCommand", func() {
+ SkipIfRemote()
+ ls, ec, _ := podmanTest.RunLsContainer("")
+ Expect(ec).To(Equal(0))
+ cid := ls.OutputToString()
+
+ result := podmanTest.Podman([]string{"inspect", "--format={{.Config.CreateCommand}}", cid})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+ Expect(len(result.OutputToStringArray())).To(Equal(1))
+ })
+
It("podman inspect -l with additional input should fail", func() {
SkipIfRemote()
result := podmanTest.Podman([]string{"inspect", "-l", "1234foobar"})
diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go
index 2cd485114..c87ff016a 100644
--- a/test/e2e/libpod_suite_remoteclient_test.go
+++ b/test/e2e/libpod_suite_remoteclient_test.go
@@ -24,7 +24,7 @@ func SkipIfRemote() {
func SkipIfRootless() {
if os.Geteuid() != 0 {
- ginkgo.Skip("This function is not enabled for remote podman")
+ ginkgo.Skip("This function is not enabled for rootless podman")
}
}
diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go
index e25364695..0438a31cb 100644
--- a/test/e2e/logs_test.go
+++ b/test/e2e/logs_test.go
@@ -1,7 +1,9 @@
package integration
import (
+ "fmt"
"os"
+ "os/exec"
"strings"
. "github.com/containers/libpod/test/utils"
@@ -153,6 +155,23 @@ var _ = Describe("Podman logs", func() {
Expect(results.ExitCode()).To(BeZero())
})
+ It("podman journald logs for container with container tag", func() {
+ Skip("need to verify images have correct packages for journald")
+ logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "--log-opt=tag={{.ImageName}}", "-d", ALPINE, "sh", "-c", "echo podman; sleep 0.1; echo podman; sleep 0.1; echo podman"})
+ logc.WaitWithDefaultTimeout()
+ Expect(logc.ExitCode()).To(Equal(0))
+ cid := logc.OutputToString()
+
+ wait := podmanTest.Podman([]string{"wait", "-l"})
+ wait.WaitWithDefaultTimeout()
+ Expect(wait.ExitCode()).To(BeZero())
+
+ cmd := exec.Command("journalctl", "--no-pager", "-o", "json", "--output-fields=CONTAINER_TAG", "-u", fmt.Sprintf("libpod-conmon-%s.scope", cid))
+ out, err := cmd.CombinedOutput()
+ Expect(err).To(BeNil())
+ Expect(string(out)).To(ContainSubstring("alpine"))
+ })
+
It("podman journald logs for container", func() {
Skip("need to verify images have correct packages for journald")
logc := podmanTest.Podman([]string{"run", "--log-driver", "journald", "-dt", ALPINE, "sh", "-c", "echo podman; echo podman; echo podman"})
diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go
index 29c60d7ac..89a5eddf4 100644
--- a/test/e2e/play_kube_test.go
+++ b/test/e2e/play_kube_test.go
@@ -358,10 +358,11 @@ var _ = Describe("Podman generate kube", func() {
ctrAnnotation := "container.seccomp.security.alpha.kubernetes.io/" + defaultCtrName
ctr := getCtr(withCmd([]string{"pwd"}))
- err = generateKubeYaml(getPod(withCtr(ctr), withAnnotation(ctrAnnotation, "localhost:"+jsonFile)), kubeYaml)
+ err = generateKubeYaml(getPod(withCtr(ctr), withAnnotation(ctrAnnotation, "localhost/"+filepath.Base(jsonFile))), kubeYaml)
Expect(err).To(BeNil())
- kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ // CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
+ kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
@@ -378,13 +379,15 @@ var _ = Describe("Podman generate kube", func() {
fmt.Println(err)
Skip("Failed to prepare seccomp.json for test.")
}
+ defer os.Remove(jsonFile)
ctr := getCtr(withCmd([]string{"pwd"}))
- err = generateKubeYaml(getPod(withCtr(ctr), withAnnotation("seccomp.security.alpha.kubernetes.io/pod", "localhost:"+jsonFile)), kubeYaml)
+ err = generateKubeYaml(getPod(withCtr(ctr), withAnnotation("seccomp.security.alpha.kubernetes.io/pod", "localhost/"+filepath.Base(jsonFile))), kubeYaml)
Expect(err).To(BeNil())
- kube := podmanTest.Podman([]string{"play", "kube", kubeYaml})
+ // CreateSeccompJson will put the profile into podmanTest.TempDir. Use --seccomp-profile-root to tell play kube where to look
+ kube := podmanTest.Podman([]string{"play", "kube", "--seccomp-profile-root", podmanTest.TempDir, kubeYaml})
kube.WaitWithDefaultTimeout()
Expect(kube.ExitCode()).To(Equal(0))
diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go
index a436d4f09..12bfdfe41 100644
--- a/test/e2e/ps_test.go
+++ b/test/e2e/ps_test.go
@@ -306,7 +306,29 @@ var _ = Describe("Podman ps", func() {
Expect(session.ExitCode()).To(Equal(0))
Expect(session.OutputToString()).To(ContainSubstring(podid))
+ })
+
+ It("podman --pod with a non-empty pod name", func() {
+ SkipIfRemote()
+
+ podName := "testPodName"
+ _, ec, podid := podmanTest.CreatePod(podName)
+ Expect(ec).To(Equal(0))
+
+ session := podmanTest.RunTopContainerInPod("", podName)
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // "--no-trunc" must be given. If not it will trunc the pod ID
+ // in the output and you will have to trunc it in the test too.
+ session = podmanTest.Podman([]string{"ps", "--pod", "--no-trunc"})
+
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ output := session.OutputToString()
+ Expect(output).To(ContainSubstring(podid))
+ Expect(output).To(ContainSubstring(podName))
})
It("podman ps test with port range", func() {
@@ -361,4 +383,19 @@ var _ = Describe("Podman ps", func() {
Expect(len(output)).To(Equal(1))
Expect(output[0]).To(Equal(fullCid))
})
+
+ It("podman ps quiet template", func() {
+ ctrName := "testCtr"
+ session := podmanTest.Podman([]string{"run", "-d", "--name", ctrName, ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ result := podmanTest.Podman([]string{"ps", "-q", "-a", "--format", "{{ .Names }}"})
+ result.WaitWithDefaultTimeout()
+ Expect(result.ExitCode()).To(Equal(0))
+
+ output := result.OutputToStringArray()
+ Expect(len(output)).To(Equal(1))
+ Expect(output[0]).To(Equal(ctrName))
+ })
})
diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go
new file mode 100644
index 000000000..17171cd41
--- /dev/null
+++ b/test/e2e/untag_test.go
@@ -0,0 +1,73 @@
+package integration
+
+import (
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman untag", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+
+ BeforeEach(func() {
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.Setup()
+ podmanTest.RestoreAllArtifacts()
+
+ for _, tag := range []string{"test", "foo", "bar"} {
+ session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tag})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ }
+
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ processTestResult(f)
+
+ })
+
+ It("podman untag all", func() {
+ session := podmanTest.PodmanNoCache([]string{"untag", ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ results := podmanTest.PodmanNoCache([]string{"images", ALPINE})
+ results.WaitWithDefaultTimeout()
+ Expect(results.ExitCode()).To(Equal(0))
+ Expect(results.OutputToStringArray()).To(HaveLen(1))
+ })
+
+ It("podman untag single", func() {
+ session := podmanTest.PodmanNoCache([]string{"untag", ALPINE, "localhost/test:latest"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ results := podmanTest.PodmanNoCache([]string{"images"})
+ results.WaitWithDefaultTimeout()
+ Expect(results.ExitCode()).To(Equal(0))
+ Expect(results.OutputToStringArray()).To(HaveLen(5))
+ Expect(results.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue())
+ Expect(results.LineInOuputStartsWith("localhost/foo")).To(BeTrue())
+ Expect(results.LineInOuputStartsWith("localhost/bar")).To(BeTrue())
+ Expect(results.LineInOuputStartsWith("localhost/test")).To(BeFalse())
+ })
+
+ It("podman untag not enough arguments", func() {
+ session := podmanTest.PodmanNoCache([]string{"untag"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).NotTo(Equal(0))
+ })
+})
diff --git a/test/system/010-images.bats b/test/system/010-images.bats
index 543876509..66ef53590 100644
--- a/test/system/010-images.bats
+++ b/test/system/010-images.bats
@@ -45,18 +45,33 @@ size | [0-9]\\\+
}
@test "podman images - history output" {
- run_podman images --format json
- actual=$(echo $output | jq -r '.[0].history | length')
- is "$actual" "0"
-
- run_podman tag $PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG test-image
- run_podman images --format json
- actual=$(echo $output | jq -r '.[1].history | length')
- is "$actual" "0"
- actual=$(echo $output | jq -r '.[0].history | length')
- is "$actual" "1"
- actual=$(echo $output | jq -r '.[0].history[0]')
- is "$actual" "$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG"
+ # podman history is persistent: it permanently alters our base image.
+ # Create a dummy image here so we leave our setup as we found it.
+ run_podman run --name my-container $IMAGE true
+ run_podman commit my-container my-test-image
+
+ run_podman images my-test-image --format '{{ .History }}'
+ is "$output" "" "Image has empty history to begin with"
+
+ # Generate two randomish tags; 'tr' because they must be all lower-case
+ rand_name1="test-image-history-$(random_string 10 | tr A-Z a-z)"
+ rand_name2="test-image-history-$(random_string 10 | tr A-Z a-z)"
+
+ # Tag once, rmi, and make sure the tag name appears in history
+ run_podman tag my-test-image $rand_name1
+ run_podman rmi $rand_name1
+ run_podman images my-test-image --format '{{ .History }}'
+ is "$output" "localhost/${rand_name1}:latest" "image history after one tag"
+
+ # Repeat with second tag. Now both tags should be in history
+ run_podman tag my-test-image $rand_name2
+ run_podman rmi $rand_name2
+ run_podman images my-test-image --format '{{ .History }}'
+ is "$output" "localhost/${rand_name2}:latest, localhost/${rand_name1}:latest" \
+ "image history after two tags"
+
+ run_podman rmi my-test-image
+ run_podman rm my-container
}
# vim: filetype=sh
diff --git a/test/system/130-kill.bats b/test/system/130-kill.bats
new file mode 100644
index 000000000..aae7f114f
--- /dev/null
+++ b/test/system/130-kill.bats
@@ -0,0 +1,101 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# tests for podman kill
+#
+
+load helpers
+
+@test "podman kill - test signal handling in containers" {
+ # 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)
+ run_podman run -d $IMAGE sh -c "for i in ${signals[*]}; do trap \"echo got: \$i\" \$i; done; echo READY; while ! test -e /stop; do sleep 0.05; done;echo DONE"
+ cid="$output"
+
+ # Run 'logs -f' on that container, but run it in the background with
+ # redirection to a named pipe from which we (foreground job) read
+ # and confirm that signals are received. We can't use run_podman here.
+ local fifo=${PODMAN_TMPDIR}/podman-kill-fifo.$(random_string 10)
+ mkfifo $fifo
+ $PODMAN logs -f $cid >$fifo </dev/null &
+ podman_log_pid=$!
+
+ # Open the FIFO for reading, and keep it open. This prevents a race
+ # condition in which the container can exit (e.g. if for some reason
+ # it doesn't handle the signal) and we (this test) try to read from
+ # the FIFO. Since there wouldn't be an active writer, the open()
+ # would hang forever. With this exec we keep the FD open, allowing
+ # 'read -t' to time out and report a useful error.
+ exec 5<$fifo
+
+ # First container emits READY when ready; wait for it.
+ read -t 10 -u 5 ready
+ is "$ready" "READY" "first log message from container"
+
+ # Helper function: send the given signal, verify that it's received.
+ kill_and_check() {
+ local signal=$1
+ local signum=${2:-$1} # e.g. if signal=HUP, we expect to see '1'
+
+ run_podman kill -s $signal $cid
+ read -t 10 -u 5 actual || die "Timed out: no ACK for kill -s $signal"
+ is "$actual" "got: $signum" "Signal $signal handled by container"
+ }
+
+ # Send signals in random order; make sure each one is received
+ for s in $(fmt --width=2 <<< "${signals[*]}" | sort --random-sort);do
+ kill_and_check $s
+ done
+
+ # Variations: with leading dash; by name, with/without dash or SIG
+ kill_and_check -1 1
+ kill_and_check -INT 2
+ kill_and_check FPE 8
+ kill_and_check -SIGUSR1 10
+ kill_and_check SIGUSR2 12
+
+ # Done. Tell the container to stop, and wait for final DONE
+ run_podman exec $cid touch /stop
+ read -t 5 -u 5 done || die "Timed out waiting for DONE from container"
+ is "$done" "DONE" "final log message from container"
+
+ # Clean up
+ run_podman wait $cid
+ run_podman rm $cid
+ wait $podman_log_pid
+}
+
+@test "podman kill - rejects invalid args" {
+ # These errors are thrown by the imported docker/signal.ParseSignal()
+ local -a bad_signal_names=(0 SIGBADSIG SIG BADSIG %% ! "''" '""' " ")
+ for s in ${bad_signal_names[@]}; do
+ # 'nosuchcontainer' is fine: podman should bail before it gets there
+ run_podman 125 kill -s $s nosuchcontainer
+ is "$output" "Error: Invalid signal: $s" "Error from kill -s $s"
+
+ run_podman 125 pod kill -s $s nosuchpod
+ is "$output" "Error: Invalid signal: $s" "Error from pod kill -s $s"
+ done
+
+ # Special case: these too are thrown by docker/signal.ParseSignal(),
+ # but the dash sign is stripped by our wrapper in utils, so the
+ # error message doesn't include the dash.
+ local -a bad_dash_signals=(-0 -SIGBADSIG -SIG -BADSIG -)
+ for s in ${bad_dash_signals[@]}; do
+ run_podman 125 kill -s $s nosuchcontainer
+ is "$output" "Error: Invalid signal: ${s##-}" "Error from kill -s $s"
+ done
+
+ # This error (signal out of range) is thrown by our wrapper
+ local -a bad_signal_nums=(65 -65 96 999 99999999)
+ for s in ${bad_signal_nums[@]}; do
+ run_podman 125 kill -s $s nosuchcontainer
+ is "$output" "Error: valid signals are 1 through 64" \
+ "Error from kill -s $s"
+ done
+
+ # 'podman create' uses the same parsing code
+ run_podman 125 create --stop-signal=99 $IMAGE
+ is "$output" "Error: valid signals are 1 through 64" "podman create"
+}
+
+# vim: filetype=sh
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 8c061d2c9..940f3f426 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -36,7 +36,7 @@ function basic_setup() {
if [ "$1" == "$PODMAN_TEST_IMAGE_FQN" ]; then
found_needed_image=1
else
- echo "# setup(): removing stray images" >&3
+ echo "# setup(): removing stray images $1 $2" >&3
run_podman rmi --force "$1" >/dev/null 2>&1 || true
run_podman rmi --force "$2" >/dev/null 2>&1 || true
fi