platform_build_soong/finder
Colin Cross 2f5a484ee1 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
2019-06-20 15:24:05 -07:00
..
cmd Move android/soong/fs to android/soong/finder/fs 2017-12-22 13:56:17 -08:00
fs Fix `go vet` issues 2018-07-22 21:18:45 -07:00
Android.bp Move android/soong/fs to android/soong/finder/fs 2017-12-22 13:56:17 -08:00
finder.go Add a DirEntryInfo interface that is a subset of os.FileInfo 2017-12-22 13:56:17 -08:00
finder_test.go Fix data races in finder_test.go 2019-06-20 15:24:05 -07:00