libct/int/TestExecInTTY: repeat the test 300 times
This is to increase the chance to hit the recently fixed race.
@@ -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") {
@@ -333,6 +341,7 @@ func TestExecInTTY(t *testing.T) {
t.Fatalf("unexpected carriage-return in output %q", out)
}
}
+}
func TestExecInEnvironment(t *testing.T) {
if testing.Short() {
