From ad5df4d614434e5aa526aaeea0a5ce4d02d95d0d Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 18 Mar 2012 18:29:41 -0700 Subject: [PATCH] fuse: remove 1 second pause during testing. Change-Id: I6a708907ae5881b5225c0ef944b7cda7aed0cfba --- .../code.google.com/p/rsc/fuse/fuse_test.go | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/third_party/code.google.com/p/rsc/fuse/fuse_test.go b/third_party/code.google.com/p/rsc/fuse/fuse_test.go index aa12c350c..51906847e 100644 --- a/third_party/code.google.com/p/rsc/fuse/fuse_test.go +++ b/third_party/code.google.com/p/rsc/fuse/fuse_test.go @@ -48,18 +48,7 @@ func TestFuse(t *testing.T) { } }() - // TODO: remove hard-coded 1 second here. try repeated from short - // to increasingly long timeouts here, waiting for a good Stat. - time.Sleep(1 * time.Second) - probeEntry := *fuseRun - if probeEntry == "" { - probeEntry = fuseTests[0].name - } - _, err = os.Stat(dir + "/" + probeEntry) - if err != nil { - t.Fatalf("mount did not work") - return - } + waitForMount(t, dir) for _, tt := range fuseTests { if *fuseRun == "" || *fuseRun == tt.name { @@ -69,6 +58,22 @@ func TestFuse(t *testing.T) { } } +func waitForMount(t *testing.T, dir string) { + // Filename to wait for in dir: + probeEntry := *fuseRun + if probeEntry == "" { + probeEntry = fuseTests[0].name + } + for tries := 0; tries < 100; tries++ { + _, err := os.Stat(dir + "/" + probeEntry) + if err == nil { + return + } + time.Sleep(10 * time.Millisecond) + } + t.Fatalf("mount did not work") +} + var fuseTests = []struct { name string node interface {