]> go.fuhry.dev Git - fsnotify.git/commitdiff
Fix TestInotifyOverflow (#265)
authorMatthias Stone <matthias@bellstone.ca>
Thu, 30 Aug 2018 20:03:37 +0000 (14:03 -0600)
committerNathan Youngman <git@nathany.com>
Thu, 30 Aug 2018 20:03:37 +0000 (14:03 -0600)
* Queued inotify events could have been read by the test before max_queued_events was hit

inotify_test.go

index 54f3f00eba9ab8fc326989511540faee19b20dc8..2c11d2ed9c807ab1c27e33b7a832bea96e5e5acd 100644 (file)
@@ -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