From: Matthias Stone Date: Thu, 30 Aug 2018 20:03:37 +0000 (-0600) Subject: Fix TestInotifyOverflow (#265) X-Git-Tag: v1.7.2~169 X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=70cc4a11de4adb99aa24da1e7b1782da5535beaa;p=fsnotify.git Fix TestInotifyOverflow (#265) * Queued inotify events could have been read by the test before max_queued_events was hit --- diff --git a/inotify_test.go b/inotify_test.go index 54f3f00..2c11d2e 100644 --- a/inotify_test.go +++ b/inotify_test.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "strings" + "sync" "testing" "time" ) @@ -390,9 +391,12 @@ func TestInotifyOverflow(t *testing.T) { errChan := make(chan error, numDirs*numFiles) + // All events need to be in the inotify queue before pulling events off it to trigger this error. + wg := sync.WaitGroup{} for dn := 0; dn < numDirs; dn++ { testSubdir := fmt.Sprintf("%s/%d", testDir, dn) + wg.Add(1) go func() { for fn := 0; fn < numFiles; fn++ { testFile := fmt.Sprintf("%s/%d", testSubdir, fn) @@ -409,8 +413,10 @@ func TestInotifyOverflow(t *testing.T) { continue } } + wg.Done() }() } + wg.Wait() creates := 0 overflows := 0