Add t.Parallel() to SDK tests
Reduces time to run go test ./sdk from 44 seconds to 22.5 seconds.
Requires moving snapshotTestCustomizations from a map to a struct
with individual fields to avoid concurrent map accesses between
subtests.
Test: go test ./sdk
Change-Id: Id6f451ba9cbace8bc7ea915033a795456b85cf3f
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 34e11f0..36f0010 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -73,6 +73,7 @@
}
func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithDexpreopt,
@@ -514,7 +515,9 @@
}
func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
+ t.Parallel()
t.Run("added-directly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -566,6 +569,7 @@
.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`
t.Run("added-via-apex", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -575,6 +579,7 @@
})
t.Run("added-directly-and-indirectly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -599,6 +604,7 @@
// TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a
// bootclasspath_fragment is correctly output to the sdk snapshot.
func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -734,6 +740,7 @@
// Test that bootclasspath_fragment works with sdk.
func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForSdkTestWithApex,
prepareForSdkTestWithJava,
@@ -802,6 +809,7 @@
}
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -1127,7 +1135,9 @@
}
func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) {
+ t.Parallel()
t.Run("target S build", func(t *testing.T) {
+ t.Parallel()
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
@@ -1184,6 +1194,7 @@
})
t.Run("target-Tiramisu-build", func(t *testing.T) {
+ t.Parallel()
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
@@ -1268,6 +1279,7 @@
}
func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
diff --git a/sdk/bp_test.go b/sdk/bp_test.go
index c620ac2..d3eaafe 100644
--- a/sdk/bp_test.go
+++ b/sdk/bp_test.go
@@ -73,6 +73,7 @@
}
func TestAddPropertySimple(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
for name, val := range map[string]interface{}{
"x": "taxi",
@@ -91,14 +92,17 @@
}
func TestAddPropertySubset(t *testing.T) {
+ t.Parallel()
getFixtureMap := map[string]func() interface{}{
"property set": propertySetFixture,
"property struct": propertyStructFixture,
}
t.Run("add new subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
set.AddProperty("new", getFixture())
checkPropertySetFixture(t, set, true)
@@ -108,8 +112,10 @@
})
t.Run("merge existing subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("flag", false)
@@ -123,12 +129,14 @@
})
t.Run("add conflicting subset", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
android.AssertPanicMessageContains(t, "adding x again should panic", `Property "x" already exists in property set`,
func() { set.AddProperty("x", propertySetFixture()) })
})
t.Run("add non-pointer struct", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
str := propertyStructFixture().(*propertyStruct)
android.AssertPanicMessageContains(t, "adding a non-pointer struct should panic", "Value is a struct, not a pointer to one:",
@@ -137,6 +145,7 @@
}
func TestAddPropertySetNew(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -144,6 +153,7 @@
}
func TestAddPropertySetExisting(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -176,6 +186,7 @@
}
func TestTransformRemoveProperty(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddProperty("fred", "12")
@@ -188,6 +199,7 @@
}
func TestTransformRemovePropertySet(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddPropertySet("fred")
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 25839b8..939477f 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -58,6 +58,7 @@
// Contains tests for SDK members provided by the cc package.
func TestSingleDeviceOsAssumption(t *testing.T) {
+ t.Parallel()
// Mock a module with DeviceSupported() == true.
s := &sdk{}
android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
@@ -72,6 +73,7 @@
}
func TestSdkIsCompileMultilibBoth(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -102,6 +104,7 @@
}
func TestSdkCompileMultilibOverride(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -161,6 +164,7 @@
// Make sure the sdk can use host specific cc libraries static/shared and both.
func TestHostSdkWithCc(t *testing.T) {
+ t.Parallel()
testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -184,6 +188,7 @@
// Make sure the sdk can use cc libraries static/shared and both.
func TestSdkWithCc(t *testing.T) {
+ t.Parallel()
testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -214,6 +219,7 @@
}
func TestSnapshotWithObject(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -268,6 +274,7 @@
}
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -305,6 +312,7 @@
}
func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -393,6 +401,7 @@
// handling is tested with the sanitize clauses (but note there's a lot of
// built-in logic in sanitize.go that can affect those flags).
func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -475,6 +484,7 @@
}
func TestSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "mymodule_exports",
@@ -523,6 +533,7 @@
}
func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -604,6 +615,7 @@
}
func TestSnapshotWithSingleHostOsType(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTest,
ccTestFs.AddToFixture(),
@@ -721,6 +733,7 @@
// Test that we support the necessary flags for the linker binary, which is
// special in several ways.
func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "mymodule_exports",
@@ -785,6 +798,7 @@
}
func TestSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -856,6 +870,7 @@
}
func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1005,6 +1020,7 @@
}
func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1085,6 +1101,7 @@
}
func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1168,6 +1185,7 @@
}
func TestSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1232,6 +1250,7 @@
}
func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1307,6 +1326,7 @@
}
func TestSnapshotWithCcLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1376,6 +1396,7 @@
}
func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1477,6 +1498,7 @@
}
func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1578,6 +1600,7 @@
}
func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
testSdkError(t, "Incompatible member types", `
module_exports {
host_supported: true,
@@ -1609,6 +1632,7 @@
}
func TestHostSnapshotWithMultiLib64(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1682,6 +1706,7 @@
}
func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1721,6 +1746,7 @@
}
func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
@@ -1778,6 +1804,7 @@
// module that has different output files for a native bridge target requests the native bridge
// variants are copied into the sdk snapshot that it reports an error.
func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
@@ -1814,6 +1841,7 @@
}
func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
+ t.Parallel()
testImageVariant := func(t *testing.T, property, trait string) {
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
@@ -1877,6 +1905,7 @@
}
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1933,6 +1962,7 @@
}
func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2002,6 +2032,7 @@
}
func TestSystemSharedLibPropagation(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2162,6 +2193,7 @@
}
func TestStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2223,6 +2255,7 @@
}
func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2299,6 +2332,7 @@
}
func TestUniqueHostSoname(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2364,6 +2398,7 @@
}
func TestNoSanitizerMembers(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
diff --git a/sdk/compat_config_sdk_test.go b/sdk/compat_config_sdk_test.go
index 75b5229..1737b3a 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -76,6 +76,7 @@
}
func TestSnapshotWithCompatConfig(t *testing.T) {
+ t.Parallel()
testSnapshotWithCompatConfig(t, `
sdk {
name: "mysdk",
@@ -85,6 +86,7 @@
}
func TestSnapshotWithCompatConfig_Apex(t *testing.T) {
+ t.Parallel()
testSnapshotWithCompatConfig(t, `
apex {
name: "myapex",
diff --git a/sdk/exports_test.go b/sdk/exports_test.go
index 9d0a242..5a7ce84 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -20,6 +20,7 @@
// Ensure that module_exports generates a module_exports_snapshot module.
func TestModuleExportsSnapshot(t *testing.T) {
+ t.Parallel()
packageBp := `
module_exports {
name: "myexports",
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 4db163c..1e545ce 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -51,6 +51,7 @@
// Contains tests for SDK members provided by the java package.
func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -77,6 +78,7 @@
}
func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -126,6 +128,7 @@
}
func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -178,6 +181,7 @@
}
func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -228,6 +232,7 @@
}
func TestSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -277,6 +282,7 @@
}
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -328,6 +334,7 @@
}
func TestSnapshotWithJavaBootLibrary_UpdatableMedia(t *testing.T) {
+ t.Parallel()
runTest := func(t *testing.T, targetBuildRelease, expectedJarPath, expectedCopyRule string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
@@ -385,6 +392,7 @@
}
func TestSnapshotWithJavaLibrary_MinSdkVersion(t *testing.T) {
+ t.Parallel()
runTest := func(t *testing.T, targetBuildRelease, minSdkVersion, expectedMinSdkVersion string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
@@ -457,6 +465,7 @@
}
func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -509,6 +518,7 @@
}
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -561,6 +571,7 @@
}
func TestSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -603,6 +614,7 @@
}
func TestHostSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -650,6 +662,7 @@
}
func TestSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -853,6 +866,7 @@
}
func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -911,6 +925,7 @@
}
func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -1004,6 +1019,7 @@
}
func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1081,6 +1097,7 @@
}
func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1136,6 +1153,7 @@
}
func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1192,6 +1210,7 @@
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1246,6 +1265,7 @@
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1303,6 +1323,7 @@
}
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
@@ -1385,6 +1406,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1435,6 +1457,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1488,6 +1511,7 @@
}
func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1555,6 +1579,7 @@
}
func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1636,6 +1661,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1703,6 +1729,7 @@
}
func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureAddFile("docs/known_doctags", nil),
diff --git a/sdk/license_sdk_test.go b/sdk/license_sdk_test.go
index 754f019..eb8112b 100644
--- a/sdk/license_sdk_test.go
+++ b/sdk/license_sdk_test.go
@@ -21,6 +21,7 @@
)
func TestSnapshotWithPackageDefaultLicense(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.PrepareForTestWithLicenses,
diff --git a/sdk/member_trait_test.go b/sdk/member_trait_test.go
index 673d6fb..9b41e9b 100644
--- a/sdk/member_trait_test.go
+++ b/sdk/member_trait_test.go
@@ -116,6 +116,7 @@
}
func TestBasicTrait_WithoutTrait(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -154,6 +155,7 @@
}
func TestBasicTrait_MultipleTraits(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -262,6 +264,7 @@
}
func TestTraitUnsupportedByMemberType(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 2532a25..b525eb8 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -40,6 +40,7 @@
// Ensure that prebuilt modules have the same effective visibility as the source
// modules.
func TestSnapshotVisibility(t *testing.T) {
+ t.Parallel()
packageBp := `
package {
default_visibility: ["//other/foo"],
@@ -160,6 +161,7 @@
}
func TestSdkInstall(t *testing.T) {
+ t.Parallel()
sdk := `
sdk {
name: "mysdk",
@@ -326,6 +328,7 @@
// Ensure that sdk snapshot related environment variables work correctly.
func TestSnapshot_EnvConfiguration(t *testing.T) {
+ t.Parallel()
bp := `
sdk {
name: "mysdk",
@@ -352,6 +355,7 @@
}
t.Run("no env variables", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip")
@@ -377,6 +381,7 @@
})
t.Run("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -468,6 +473,7 @@
})
t.Run("test replacing exportable module", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index fd6c4e7..60e5b95 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -91,6 +91,7 @@
}
func TestSnapshotWithPartialSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -185,6 +186,7 @@
}
func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -231,6 +233,7 @@
}
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
sdk {
@@ -298,6 +301,7 @@
`
t.Run("target-s", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "S", `
// This is auto-generated. DO NOT EDIT.
@@ -319,6 +323,7 @@
})
t.Run("target-t", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "Tiramisu", `
// This is auto-generated. DO NOT EDIT.
@@ -361,6 +366,7 @@
})
t.Run("target-u", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "UpsideDownCake", `
// This is auto-generated. DO NOT EDIT.
@@ -409,10 +415,12 @@
})
t.Run("added-directly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, `latest`, expectedLatestSnapshot)
})
t.Run("added-via-apex", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, `
sdk {
name: "mysdk",
diff --git a/sdk/testing.go b/sdk/testing.go
index 21d457c..f5518c4 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -128,12 +128,11 @@
// generated, etc.
func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) *snapshotBuildInfo {
info := &snapshotBuildInfo{
- t: t,
- r: result,
- androidBpContents: sdk.GetAndroidBpContentsForTests(),
- infoContents: sdk.GetInfoContentsForTests(),
- snapshotTestCustomizations: map[snapshotTest]*snapshotTestCustomization{},
- targetBuildRelease: sdk.builderForTests.targetBuildRelease,
+ t: t,
+ r: result,
+ androidBpContents: sdk.GetAndroidBpContentsForTests(),
+ infoContents: sdk.GetInfoContentsForTests(),
+ targetBuildRelease: sdk.builderForTests.targetBuildRelease,
}
buildParams := sdk.BuildParamsForTests()
@@ -293,6 +292,7 @@
}
t.Run("snapshot without source", func(t *testing.T) {
+ t.Parallel()
// Remove the source Android.bp file to make sure it works without.
removeSourceAndroidBp := android.FixtureModifyMockFS(func(fs android.MockFS) {
delete(fs, "Android.bp")
@@ -302,10 +302,12 @@
})
t.Run("snapshot with source preferred", func(t *testing.T) {
+ t.Parallel()
runSnapshotTestWithCheckers(t, checkSnapshotWithSourcePreferred, android.NullFixturePreparer)
})
t.Run("snapshot preferred with source", func(t *testing.T) {
+ t.Parallel()
// Replace the snapshot/Android.bp file with one where "prefer: false," has been replaced with
// "prefer: true,"
preferPrebuilts := android.FixtureModifyMockFS(func(fs android.MockFS) {
@@ -469,19 +471,40 @@
targetBuildRelease *buildRelease
// The test specific customizations for each snapshot test.
- snapshotTestCustomizations map[snapshotTest]*snapshotTestCustomization
+ snapshotTestCustomizations snapshotTestCustomizationSet
+}
+
+type snapshotTestCustomizationSet struct {
+ snapshotWithoutSource *snapshotTestCustomization
+ snapshotWithSourcePreferred *snapshotTestCustomization
+ snapshotPreferredWithSource *snapshotTestCustomization
+}
+
+func (s *snapshotTestCustomizationSet) customization(snapshotTest snapshotTest) **snapshotTestCustomization {
+ var customization **snapshotTestCustomization
+ switch snapshotTest {
+ case checkSnapshotWithoutSource:
+
+ customization = &s.snapshotWithoutSource
+ case checkSnapshotWithSourcePreferred:
+ customization = &s.snapshotWithSourcePreferred
+ case checkSnapshotPreferredWithSource:
+ customization = &s.snapshotPreferredWithSource
+ default:
+ panic(fmt.Errorf("unsupported snapshotTest %v", snapshotTest))
+ }
+ return customization
}
// snapshotTestCustomization gets the test specific customization for the specified snapshotTest.
//
// If no customization was created previously then it creates a default customization.
func (i *snapshotBuildInfo) snapshotTestCustomization(snapshotTest snapshotTest) *snapshotTestCustomization {
- customization := i.snapshotTestCustomizations[snapshotTest]
- if customization == nil {
- customization = &snapshotTestCustomization{
+ customization := i.snapshotTestCustomizations.customization(snapshotTest)
+ if *customization == nil {
+ *customization = &snapshotTestCustomization{
errorHandler: android.FixtureExpectsNoErrors,
}
- i.snapshotTestCustomizations[snapshotTest] = customization
}
- return customization
+ return *customization
}