From b0f2ebbe9d005a13ab3d8629e3d1c1721969639f Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 15 Oct 2024 14:46:44 +0200 Subject: [PATCH] test/e2e: fix default signal exit code test By default golang programs exit 2 on special exit signals that can be cought and produce a stack trace. However this is behavior that can be modfied via GOTRACEBACK=crash[1], in that case it does not exit(2) but rather sends itself SIGABRT to the parent sees the signal exit and out test sees that es exit code 134, 128 + 6 (SIGABRT), like most shells do. As it turns out GOTRACEBACK=crash is the default mode on all fedora and RHEL rpm builds as they patch the build with a special "rpm_crashtraceback" go build tag. While that change is old and existing for a very long time it was never caught until commit 5e240ab1f5, which switched the old ExitWithError() check that accepted anything > 0, to just accept 2. And as CI only test upstream builds that are build without rpm_crashtraceback we did not catch in CI either. Only once a user actually used distro build against the source e2e test it failed. I like to highlight that running distro builds against upstream e2e tests is not something we really support or plan to support but given this is a easy fix I decided to just fix it here as any user with GOTRACEBACK=crash set would face the same issue. While I touch this test remove the unnecessary RestoreArtifact() call which is not needed at all as we do nothing with the image and just slows the test down for now reason. [1] https://pkg.go.dev/runtime#section-sourcefiles Fixes #24213 Signed-off-by: Paul Holzinger --- test/e2e/run_signal_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go index 2f1cb18ef1..c9cb0748b5 100644 --- a/test/e2e/run_signal_test.go +++ b/test/e2e/run_signal_test.go @@ -92,10 +92,6 @@ var _ = Describe("Podman run with --sig-proxy", func() { Specify("signals are not forwarded to container with sig-proxy false", func() { signal := syscall.SIGFPE - if isRootless() { - err = podmanTest.RestoreArtifact(fedoraMinimal) - Expect(err).ToNot(HaveOccurred()) - } session, pid := podmanTest.PodmanPID([]string{"run", "--name", "test2", "--sig-proxy=false", fedoraMinimal, "bash", "-c", sigCatch2}) Expect(WaitForContainer(podmanTest)).To(BeTrue(), "WaitForContainer()") @@ -112,7 +108,11 @@ var _ = Describe("Podman run with --sig-proxy", func() { Expect(killSession).Should(ExitCleanly()) session.WaitWithDefaultTimeout() - Expect(session).To(ExitWithError(2, "SIGFPE: floating-point exception")) + // Exit code is normally 2, however with GOTRACEBACK=crash (default in + // Fedora/RHEL rpm builds) it will be 134 thus allow both. + // https://github.com/containers/podman/issues/24213 + errorMsg := "SIGFPE: floating-point exception" + Expect(session).To(Or(ExitWithError(2, errorMsg), ExitWithError(134, errorMsg))) Expect(session.OutputToString()).To(Not(ContainSubstring("Received"))) })