Skip to content

Commit 6733936

Browse files
fix: use logs instead of start -a for tty container in TestCreateWithTty
With -t, the container's output goes through a pseudoTTY. Attaching via "start -a" does not reliably forward PTY output through Tigron's subprocess pipe, causing the stty check to fail on certain containerd versions (e.g. v1.7.30). Match the original test's approach: start the container without -a, then read its output via "nerdctl logs" which goes through the log driver and is always available after the container exits. Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@hotmail.com>
1 parent b8cc2ac commit 6733936

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

cmd/nerdctl/container/container_create_linux_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,20 @@ func TestCreateWithTty(t *testing.T) {
288288
Description: "create with tty - stty succeeds",
289289
Setup: func(data test.Data, helpers test.Helpers) {
290290
helpers.Ensure("create", "-t", "--name", data.Identifier(), testutil.CommonImage, "stty")
291+
// start without -a: tty output is not forwarded over a pipe, so
292+
// capturing it via "start -a" is unreliable. Use "logs" instead,
293+
// which reads from the containerd log driver regardless of tty.
294+
helpers.Ensure("start", data.Identifier())
291295
},
292296
Cleanup: func(data test.Data, helpers test.Helpers) {
293297
helpers.Anyhow("container", "rm", "-f", data.Identifier())
294298
},
295299
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
296-
return helpers.Command("start", "-a", data.Identifier())
300+
return helpers.Command("logs", data.Identifier())
297301
},
298302
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
299303
return &test.Expected{
300-
ExitCode: 0,
301-
Output: func(stdout string, t tig.T) {
302-
assert.Assert(t, strings.Contains(stdout, "speed 38400 baud; line = 0;"),
303-
fmt.Sprintf("expected stdout to contain speed info: %q", stdout))
304-
},
304+
Output: expect.Contains("speed 38400 baud; line = 0;"),
305305
}
306306
},
307307
},

0 commit comments

Comments
 (0)