libct/int/TestExecInTTY: repeat the test 300 times

This is to increase the chance to hit the recently fixed race.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-01-07 13:21:38 -08:00
parent fedaa2abed
commit 06a684d6a7

View File

@@ -291,13 +291,16 @@ func TestExecInTTY(t *testing.T) {
Args: []string{"ps"},
Env: standardEnvironment,
}
// Repeat to increase chances to catch a race; see
// https://github.com/opencontainers/runc/issues/2425.
for i := 0; i < 300; i++ {
parent, child, err := utils.NewSockPair("console")
if err != nil {
ok(t, err)
}
defer parent.Close()
defer child.Close()
ps.ConsoleSocket = child
done := make(chan (error))
go func() {
f, err := utils.RecvFd(parent)
@@ -315,15 +318,20 @@ func TestExecInTTY(t *testing.T) {
_, _ = io.Copy(&stdout, c)
done <- nil
}()
err = container.Run(ps)
ok(t, err)
select {
case <-time.After(5 * time.Second):
t.Fatal("Waiting for copy timed out")
case err := <-done:
ok(t, err)
}
waitProcess(ps, t)
parent.Close()
child.Close()
out := stdout.String()
if !strings.Contains(out, "cat") || !strings.Contains(out, "ps") {
@@ -332,6 +340,7 @@ func TestExecInTTY(t *testing.T) {
if strings.Contains(out, "\r") {
t.Fatalf("unexpected carriage-return in output %q", out)
}
}
}
func TestExecInEnvironment(t *testing.T) {