From 905958ea659bf7cbbbccdc31aae77886bcdf49d6 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Sat, 18 Apr 2026 15:42:24 -0700 Subject: [PATCH 1/2] tests/int: show stderr if command failed part II This adds a few cases missed by commit bf4fcc30. Fixes: bf4fcc30 Signed-off-by: Kir Kolyshkin --- libcontainer/integration/exec_test.go | 1 + libcontainer/integration/execin_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index e1f209008bf..cd0df282be4 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -784,6 +784,7 @@ func TestPassExtraFiles(t *testing.T) { ExtraFiles: []*os.File{pipein1, pipein2}, Stdin: nil, Stdout: &stdout, + Stderr: new(strings.Builder), Init: true, } err = container.Run(&process) diff --git a/libcontainer/integration/execin_test.go b/libcontainer/integration/execin_test.go index 707d842c122..eaf6144e3cd 100644 --- a/libcontainer/integration/execin_test.go +++ b/libcontainer/integration/execin_test.go @@ -421,6 +421,7 @@ func TestExecinPassExtraFiles(t *testing.T) { ExtraFiles: []*os.File{pipein1, pipein2}, Stdin: nil, Stdout: &stdout, + Stderr: new(strings.Builder), } err = container.Run(inprocess) ok(t, err) From 1d12f98f85e3bd7eac732e6e099050bd3a37eabb Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Sat, 18 Apr 2026 15:46:35 -0700 Subject: [PATCH 2/2] tests/int: fix TestHook flakiness Since commit 3cdda46 the poststart hooks runs after the container process start, and so they race. Move the poststart hook check to a separate step after the container process has exited. Fixes 5245. Signed-off-by: Kir Kolyshkin --- libcontainer/integration/exec_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index cd0df282be4..e1cb8151c40 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -1075,11 +1075,14 @@ func TestHook(t *testing.T) { container, err := newContainer(t, config) ok(t, err) - // e.g: 'ls /prestart ...' var cmd strings.Builder cmd.WriteString("ls ") for _, hook := range hookFiles { - cmd.WriteString("/" + hook + " ") + // The poststart hook is racing with this ls command (run as the + // container init), so we don't check that hook worked here yet. + if hook != "poststart" { + cmd.WriteString("/" + hook + " ") + } } var stdout strings.Builder @@ -1098,6 +1101,13 @@ func TestHook(t *testing.T) { // Wait for process waitProcess(&pconfig, t) + // Check that poststart hook worked. + f, err = os.Open(config.Rootfs + "/poststart") + if err != nil { + t.Fatalf("poststart hook failed: %s", err) + } + f.Close() + if err := container.Destroy(); err != nil { t.Fatalf("container destroy %s", err) }