diff options
author | 2019-06-20 14:13:05 -0700 | |
---|---|---|
committer | 2019-06-20 15:24:05 -0700 | |
commit | 2f5a484ee1ce8d370b3ec48e904b9a6f98244ee9 (patch) | |
tree | 1164c5c20f19c24c78806d14d99b60c7fb3ee008 /finder | |
parent | 0b90833ea8f19794e6cb5205ef0cbf61bf37c5b9 (diff) |
Fix data races in finder_test.go
Fix data races by incrementing clock before starting the finder.
Fixes:
==================
WARNING: DATA RACE
Read at 0x00c0003be1c0 by goroutine 99:
android/soong/finder/fs.(*MockFs).WriteFile()
build/soong/finder/fs/fs.go:159 +0x869
android/soong/finder.(*Finder).dumpDb()
build/soong/finder/finder.go:1163 +0x296
android/soong/finder.(*Finder).goDumpDb.func1()
build/soong/finder/finder.go:337 +0x3c
Previous write at 0x00c0003be1c0 by goroutine 43:
android/soong/finder.TestDirectoryNotPermitted()
build/soong/finder/fs/fs.go:155 +0x49a
testing.tRunner()
prebuilts/go/linux-x86/src/testing/testing.go:865 +0x163
Goroutine 99 (running) created at:
android/soong/finder.(*Finder).goDumpDb()
build/soong/finder/finder.go:336 +0x8d
android/soong/finder.(*Finder).loadFromFilesystem()
build/soong/finder/finder.go:380 +0x12b
android/soong/finder.newImpl()
build/soong/finder/finder.go:197 +0x38d
android/soong/finder.newFinderAndErr()
build/soong/finder/finder_test.go:58 +0x245
android/soong/finder.newFinderWithNumThreads()
build/soong/finder/finder_test.go:42 +0xb3
android/soong/finder.TestDirectoryNotPermitted()
build/soong/finder/finder_test.go:38 +0x386
testing.tRunner()
prebuilts/go/linux-x86/src/testing/testing.go:865 +0x163
Goroutine 43 (running) created at:
testing.(*T).Run()
prebuilts/go/linux-x86/src/testing/testing.go:916 +0x65a
testing.runTests.func1()
prebuilts/go/linux-x86/src/testing/testing.go:1157 +0xa8
testing.tRunner()
prebuilts/go/linux-x86/src/testing/testing.go:865 +0x163
testing.runTests()
prebuilts/go/linux-x86/src/testing/testing.go:1155 +0x523
testing.(*M).Run()
prebuilts/go/linux-x86/src/testing/testing.go:1072 +0x2eb
main.main()
out/soong/.bootstrap/soong-finder/test/test.go:157 +0x1dc
==================
Test: run finder_test.go with race detector enabled
Change-Id: Ia77090dabaf8b14a80ac9ce938fef75f1d382574
Diffstat (limited to 'finder')
-rw-r--r-- | finder/finder_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/finder/finder_test.go b/finder/finder_test.go index 29711fc2a..f6d0aa9e8 100644 --- a/finder/finder_test.go +++ b/finder/finder_test.go @@ -891,8 +891,8 @@ func TestFileAdded(t *testing.T) { IncludeFiles: []string{"findme.txt"}, }, ) - foundPaths := finder.FindNamedAt("/tmp", "findme.txt") filesystem.Clock.Tick() + foundPaths := finder.FindNamedAt("/tmp", "findme.txt") finder.Shutdown() // check the response of the first finder assertSameResponse(t, foundPaths, []string{"/tmp/a/findme.txt"}) @@ -1522,8 +1522,8 @@ func TestUpdatingDbIffChanged(t *testing.T) { IncludeFiles: []string{"hi.txt"}, }, ) - foundPaths := finder.FindAll() filesystem.Clock.Tick() + foundPaths := finder.FindAll() finder.Shutdown() // check results assertSameResponse(t, foundPaths, []string{"/tmp/a/hi.txt"}) @@ -1583,8 +1583,8 @@ func TestDirectoryNotPermitted(t *testing.T) { IncludeFiles: []string{"hi.txt"}, }, ) - foundPaths := finder.FindAll() filesystem.Clock.Tick() + foundPaths := finder.FindAll() finder.Shutdown() allPaths := []string{"/tmp/hi.txt", "/tmp/a/hi.txt", "/tmp/a/a/hi.txt", "/tmp/b/hi.txt"} // check results @@ -1629,8 +1629,8 @@ func TestFileNotPermitted(t *testing.T) { IncludeFiles: []string{"hi.txt"}, }, ) - foundPaths := finder.FindAll() filesystem.Clock.Tick() + foundPaths := finder.FindAll() finder.Shutdown() // check results assertSameResponse(t, foundPaths, []string{"/tmp/hi.txt"}) @@ -1650,8 +1650,8 @@ func TestCacheEntryPathUnexpectedError(t *testing.T) { IncludeFiles: []string{"hi.txt"}, }, ) - foundPaths := finder.FindAll() filesystem.Clock.Tick() + foundPaths := finder.FindAll() finder.Shutdown() // check results assertSameResponse(t, foundPaths, []string{"/tmp/a/hi.txt"}) |