Fix data race in snapshot singletons when running parallel tests
Singleton objects need to be created in the singleton factory rather than as a global variable so that they have a unique object per context in order to allow multiple tests to run in parallel. Test: go test -race ./... Change-Id: Ib6912849e1b849ffe8646882cfb476ddea6c6b55
This commit is contained in:
parent
744a2a6b7d
commit
6c7e8ff86f
2 changed files with 21 additions and 27 deletions
|
@ -22,16 +22,14 @@ type RecoverySnapshotModuleInterface interface {
|
|||
ExcludeFromRecoverySnapshot() bool
|
||||
}
|
||||
|
||||
var recoverySnapshotSingleton = SnapshotSingleton{
|
||||
"recovery", // name
|
||||
"SOONG_RECOVERY_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
RecoverySnapshotImageSingleton, // Image
|
||||
false, // Fake
|
||||
}
|
||||
|
||||
func RecoverySnapshotSingleton() android.Singleton {
|
||||
return &recoverySnapshotSingleton
|
||||
return &SnapshotSingleton{
|
||||
"recovery", // name
|
||||
"SOONG_RECOVERY_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
RecoverySnapshotImageSingleton, // Image
|
||||
false, // Fake
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
||||
|
|
|
@ -22,28 +22,24 @@ type VendorSnapshotModuleInterface interface {
|
|||
ExcludeFromVendorSnapshot() bool
|
||||
}
|
||||
|
||||
var vendorSnapshotSingleton = SnapshotSingleton{
|
||||
"vendor", // name
|
||||
"SOONG_VENDOR_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
VendorSnapshotImageSingleton, // Image
|
||||
false, // Fake
|
||||
}
|
||||
|
||||
var vendorFakeSnapshotSingleton = SnapshotSingleton{
|
||||
"vendor", // name
|
||||
"SOONG_VENDOR_FAKE_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
VendorSnapshotImageSingleton, // Image
|
||||
true, // Fake
|
||||
}
|
||||
|
||||
func VendorSnapshotSingleton() android.Singleton {
|
||||
return &vendorSnapshotSingleton
|
||||
return &SnapshotSingleton{
|
||||
"vendor", // name
|
||||
"SOONG_VENDOR_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
VendorSnapshotImageSingleton, // Image
|
||||
false, // Fake
|
||||
}
|
||||
}
|
||||
|
||||
func VendorFakeSnapshotSingleton() android.Singleton {
|
||||
return &vendorFakeSnapshotSingleton
|
||||
return &SnapshotSingleton{
|
||||
"vendor", // name
|
||||
"SOONG_VENDOR_FAKE_SNAPSHOT_ZIP", // makeVar
|
||||
android.OptionalPath{}, // snapshotZipFile
|
||||
VendorSnapshotImageSingleton, // Image
|
||||
true, // Fake
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
||||
|
|
Loading…
Reference in a new issue