diff --git a/inotify_test.go b/inotify_test.go
index <HASH>..<HASH> 100644
--- a/inotify_test.go
+++ b/inotify_test.go
@@ -332,6 +332,8 @@ func TestInotifyInnerMapLength(t *testing.T) {
 	_ = <-w.Events                      // consume Remove event
 	<-time.After(50 * time.Millisecond) // wait IN_IGNORE propagated
 
+	w.mu.Lock()
+	defer w.mu.Unlock()
 	if len(w.watches) != 0 {
 		t.Fatalf("Expected watches len is 0, but got: %d, %v", len(w.watches), w.watches)
 	}
inotify: fix race in test