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 <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-10-15 14:46:44 +02:00
parent 3fbae8e28e
commit b0f2ebbe9d
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 5 additions and 5 deletions

View File

@ -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")))
})