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:
@@ -22,16 +22,14 @@ type RecoverySnapshotModuleInterface interface {
|
|||||||
ExcludeFromRecoverySnapshot() bool
|
ExcludeFromRecoverySnapshot() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var recoverySnapshotSingleton = SnapshotSingleton{
|
func RecoverySnapshotSingleton() android.Singleton {
|
||||||
|
return &SnapshotSingleton{
|
||||||
"recovery", // name
|
"recovery", // name
|
||||||
"SOONG_RECOVERY_SNAPSHOT_ZIP", // makeVar
|
"SOONG_RECOVERY_SNAPSHOT_ZIP", // makeVar
|
||||||
android.OptionalPath{}, // snapshotZipFile
|
android.OptionalPath{}, // snapshotZipFile
|
||||||
RecoverySnapshotImageSingleton, // Image
|
RecoverySnapshotImageSingleton, // Image
|
||||||
false, // Fake
|
false, // Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func RecoverySnapshotSingleton() android.Singleton {
|
|
||||||
return &recoverySnapshotSingleton
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
||||||
|
@@ -22,28 +22,24 @@ type VendorSnapshotModuleInterface interface {
|
|||||||
ExcludeFromVendorSnapshot() bool
|
ExcludeFromVendorSnapshot() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var vendorSnapshotSingleton = SnapshotSingleton{
|
func VendorSnapshotSingleton() android.Singleton {
|
||||||
|
return &SnapshotSingleton{
|
||||||
"vendor", // name
|
"vendor", // name
|
||||||
"SOONG_VENDOR_SNAPSHOT_ZIP", // makeVar
|
"SOONG_VENDOR_SNAPSHOT_ZIP", // makeVar
|
||||||
android.OptionalPath{}, // snapshotZipFile
|
android.OptionalPath{}, // snapshotZipFile
|
||||||
VendorSnapshotImageSingleton, // Image
|
VendorSnapshotImageSingleton, // Image
|
||||||
false, // Fake
|
false, // Fake
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var vendorFakeSnapshotSingleton = SnapshotSingleton{
|
func VendorFakeSnapshotSingleton() android.Singleton {
|
||||||
|
return &SnapshotSingleton{
|
||||||
"vendor", // name
|
"vendor", // name
|
||||||
"SOONG_VENDOR_FAKE_SNAPSHOT_ZIP", // makeVar
|
"SOONG_VENDOR_FAKE_SNAPSHOT_ZIP", // makeVar
|
||||||
android.OptionalPath{}, // snapshotZipFile
|
android.OptionalPath{}, // snapshotZipFile
|
||||||
VendorSnapshotImageSingleton, // Image
|
VendorSnapshotImageSingleton, // Image
|
||||||
true, // Fake
|
true, // Fake
|
||||||
}
|
}
|
||||||
|
|
||||||
func VendorSnapshotSingleton() android.Singleton {
|
|
||||||
return &vendorSnapshotSingleton
|
|
||||||
}
|
|
||||||
|
|
||||||
func VendorFakeSnapshotSingleton() android.Singleton {
|
|
||||||
return &vendorFakeSnapshotSingleton
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
// Determine if a dir under source tree is an SoC-owned proprietary directory based
|
||||||
|
Reference in New Issue
Block a user