Commit 56005722 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

os/exec: deflake a test on Linux

Work around buggy(?) Linux /proc filesystem.

Fixes #7808

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews
https://golang.org/cl/90400044
parent 7ff8e90e
...@@ -224,11 +224,22 @@ func TestPipeLookPathLeak(t *testing.T) { ...@@ -224,11 +224,22 @@ func TestPipeLookPathLeak(t *testing.T) {
t.Fatal("unexpected success") t.Fatal("unexpected success")
} }
} }
for triesLeft := 3; triesLeft >= 0; triesLeft-- {
open, lsof := numOpenFDS(t) open, lsof := numOpenFDS(t)
fdGrowth := open - fd0 fdGrowth := open - fd0
if fdGrowth > 2 { if fdGrowth > 2 {
if triesLeft > 0 {
// Work around what appears to be a race with Linux's
// proc filesystem (as used by lsof). It seems to only
// be eventually consistent. Give it awhile to settle.
// See golang.org/issue/7808
time.Sleep(100 * time.Millisecond)
continue
}
t.Errorf("leaked %d fds; want ~0; have:\n%s\noriginally:\n%s", fdGrowth, lsof, lsof0) t.Errorf("leaked %d fds; want ~0; have:\n%s\noriginally:\n%s", fdGrowth, lsof, lsof0)
} }
break
}
} }
func numOpenFDS(t *testing.T) (n int, lsof []byte) { func numOpenFDS(t *testing.T) (n int, lsof []byte) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment