diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2014-04-22 17:13:38 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2014-04-22 17:13:38 -0700 |
| commit | 56005722493b044109103d0ebb867561f1c71e3c (patch) | |
| tree | 160174063e24bf90830ad20b305228336848fdf4 /src/pkg/os/exec/exec_test.go | |
| parent | 7ff8e90eb7ceb2016aa9fc736febd8a5902ec65e (diff) | |
| download | go-56005722493b044109103d0ebb867561f1c71e3c.tar.xz | |
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
Diffstat (limited to 'src/pkg/os/exec/exec_test.go')
| -rw-r--r-- | src/pkg/os/exec/exec_test.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/pkg/os/exec/exec_test.go b/src/pkg/os/exec/exec_test.go index ca19fe9bee..7a95579f15 100644 --- a/src/pkg/os/exec/exec_test.go +++ b/src/pkg/os/exec/exec_test.go @@ -224,10 +224,21 @@ func TestPipeLookPathLeak(t *testing.T) { t.Fatal("unexpected success") } } - open, lsof := numOpenFDS(t) - fdGrowth := open - fd0 - if fdGrowth > 2 { - t.Errorf("leaked %d fds; want ~0; have:\n%s\noriginally:\n%s", fdGrowth, lsof, lsof0) + for triesLeft := 3; triesLeft >= 0; triesLeft-- { + open, lsof := numOpenFDS(t) + fdGrowth := open - fd0 + 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) + } + break } } |
