summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-02-05 16:39:18 -0800
committer Colin Cross <ccross@android.com> 2025-02-06 23:43:51 +0000
commitaba8cd956a1f0cca137f6ab02b9791aac9435efd (patch)
treec5bd44db386b2f00d7e97af41999677e65f22e1b
parente4762bac43777e5a3f0472ed37342c59bf29d626 (diff)
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
-rw-r--r--sdk/bootclasspath_fragment_sdk_test.go12
-rw-r--r--sdk/bp_test.go12
-rw-r--r--sdk/cc_sdk_test.go35
-rw-r--r--sdk/compat_config_sdk_test.go2
-rw-r--r--sdk/exports_test.go1
-rw-r--r--sdk/java_sdk_test.go27
-rw-r--r--sdk/license_sdk_test.go1
-rw-r--r--sdk/member_trait_test.go3
-rw-r--r--sdk/sdk_test.go6
-rw-r--r--sdk/systemserverclasspath_fragment_sdk_test.go8
-rw-r--r--sdk/testing.go47
11 files changed, 142 insertions, 12 deletions
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 34e11f0da..36f001065 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -73,6 +73,7 @@ func fixtureAddPrebuiltApexForBootclasspathFragment(apex, fragment string) andro
}
func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithDexpreopt,
@@ -514,7 +515,9 @@ java_sdk_library_import {
}
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 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
.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 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
})
t.Run("added-directly-and-indirectly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -599,6 +604,7 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
// 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 @@ java_sdk_library_import {
// Test that bootclasspath_fragment works with sdk.
func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForSdkTestWithApex,
prepareForSdkTestWithJava,
@@ -802,6 +809,7 @@ func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
}
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -1127,7 +1135,9 @@ func testSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T, targetBui
}
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 @@ java_sdk_library_import {
})
t.Run("target-Tiramisu-build", func(t *testing.T) {
+ t.Parallel()
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
@@ -1268,6 +1279,7 @@ java_sdk_library_import {
}
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 c620ac2b8..d3eaafeba 100644
--- a/sdk/bp_test.go
+++ b/sdk/bp_test.go
@@ -73,6 +73,7 @@ func checkPropertySetFixture(t *testing.T, val interface{}, hasTags bool) {
}
func TestAddPropertySimple(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
for name, val := range map[string]interface{}{
"x": "taxi",
@@ -91,14 +92,17 @@ func TestAddPropertySimple(t *testing.T) {
}
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 @@ func TestAddPropertySubset(t *testing.T) {
})
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 @@ func TestAddPropertySubset(t *testing.T) {
})
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 TestAddPropertySubset(t *testing.T) {
}
func TestAddPropertySetNew(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -144,6 +153,7 @@ func TestAddPropertySetNew(t *testing.T) {
}
func TestAddPropertySetExisting(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -176,6 +186,7 @@ func (t removeFredTransformation) transformPropertySetAfterContents(name string,
}
func TestTransformRemoveProperty(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddProperty("fred", "12")
@@ -188,6 +199,7 @@ func TestTransformRemoveProperty(t *testing.T) {
}
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 25839b8a1..939477f61 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -58,6 +58,7 @@ func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
// 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 TestSingleDeviceOsAssumption(t *testing.T) {
}
func TestSdkIsCompileMultilibBoth(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -102,6 +104,7 @@ func TestSdkIsCompileMultilibBoth(t *testing.T) {
}
func TestSdkCompileMultilibOverride(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -161,6 +164,7 @@ cc_prebuilt_library_shared {
// 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 @@ func TestHostSdkWithCc(t *testing.T) {
// 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 TestSdkWithCc(t *testing.T) {
}
func TestSnapshotWithObject(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -268,6 +274,7 @@ cc_prebuilt_object {
}
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -305,6 +312,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -393,6 +401,7 @@ myinclude/Test.h -> include/myinclude/Test.h
// 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 @@ arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h
}
func TestSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "mymodule_exports",
@@ -523,6 +533,7 @@ cc_prebuilt_binary {
}
func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -604,6 +615,7 @@ cc_prebuilt_binary {
}
func TestSnapshotWithSingleHostOsType(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTest,
ccTestFs.AddToFixture(),
@@ -721,6 +733,7 @@ cc_prebuilt_library_shared {
// 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 @@ cc_prebuilt_binary {
}
func TestSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -856,6 +870,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1005,6 +1020,7 @@ cc_prebuilt_library_shared {
}
func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1085,6 +1101,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1168,6 +1185,7 @@ cc_prebuilt_library_shared {
}
func TestSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1232,6 +1250,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1307,6 +1326,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotWithCcLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1376,6 +1396,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1477,6 +1498,7 @@ cc_prebuilt_library {
}
func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1578,6 +1600,7 @@ cc_prebuilt_library {
}
func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
testSdkError(t, "Incompatible member types", `
module_exports {
host_supported: true,
@@ -1609,6 +1632,7 @@ func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T)
}
func TestHostSnapshotWithMultiLib64(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1682,6 +1706,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1721,6 +1746,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
@@ -1778,6 +1804,7 @@ myinclude/Test.h -> include/myinclude/Test.h
// 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 TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *t
}
func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
+ t.Parallel()
testImageVariant := func(t *testing.T, property, trait string) {
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
@@ -1877,6 +1905,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1933,6 +1962,7 @@ myinclude/Test.h -> include/myinclude/Test.h
}
func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2002,6 +2032,7 @@ myinclude-host/HostTest.h -> linux_glibc/include/myinclude-host/HostTest.h
}
func TestSystemSharedLibPropagation(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2162,6 +2193,7 @@ cc_prebuilt_library_shared {
}
func TestStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2223,6 +2255,7 @@ cc_prebuilt_library_shared {
}
func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2299,6 +2332,7 @@ cc_prebuilt_library_shared {
}
func TestUniqueHostSoname(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2364,6 +2398,7 @@ cc_prebuilt_library_shared {
}
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 75b5229bf..1737b3af1 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -76,6 +76,7 @@ prebuilt_platform_compat_config {
}
func TestSnapshotWithCompatConfig(t *testing.T) {
+ t.Parallel()
testSnapshotWithCompatConfig(t, `
sdk {
name: "mysdk",
@@ -85,6 +86,7 @@ func TestSnapshotWithCompatConfig(t *testing.T) {
}
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 9d0a24210..5a7ce845a 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -20,6 +20,7 @@ import (
// 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 4db163cdf..1e545cea3 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -51,6 +51,7 @@ var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers(
// 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 TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) {
}
func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -126,6 +128,7 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
}
func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -178,6 +181,7 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
}
func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -228,6 +232,7 @@ java_import {
}
func TestSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -277,6 +282,7 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
}
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -328,6 +334,7 @@ java_import {
}
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 @@ java_import {
}
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 @@ java_import {
}
func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -509,6 +518,7 @@ java_import {
}
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -561,6 +571,7 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
}
func TestSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -603,6 +614,7 @@ java_test_import {
}
func TestHostSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -650,6 +662,7 @@ java_test_import {
}
func TestSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -853,6 +866,7 @@ java_system_modules_import {
}
func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -911,6 +925,7 @@ java_system_modules_import {
}
func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -1004,6 +1019,7 @@ java_import {
}
func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1081,6 +1097,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1136,6 +1153,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1192,6 +1210,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1246,6 +1265,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1303,6 +1323,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
@@ -1385,6 +1406,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1435,6 +1457,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1488,6 +1511,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1555,6 +1579,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1636,6 +1661,7 @@ java_sdk_library_import {
}
func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1703,6 +1729,7 @@ java_sdk_library_import {
}
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 754f01961..eb8112ba7 100644
--- a/sdk/license_sdk_test.go
+++ b/sdk/license_sdk_test.go
@@ -21,6 +21,7 @@ import (
)
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 673d6fb6e..9b41e9b7a 100644
--- a/sdk/member_trait_test.go
+++ b/sdk/member_trait_test.go
@@ -116,6 +116,7 @@ func init() {
}
func TestBasicTrait_WithoutTrait(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -154,6 +155,7 @@ java_import {
}
func TestBasicTrait_MultipleTraits(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -262,6 +264,7 @@ java_import {
}
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 2532a2581..b525eb8a3 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -40,6 +40,7 @@ func TestMain(m *testing.M) {
// 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 @@ java_import {
}
func TestSdkInstall(t *testing.T) {
+ t.Parallel()
sdk := `
sdk {
name: "mysdk",
@@ -326,6 +328,7 @@ func TestCommonValueOptimization_InvalidArchSpecificVariants(t *testing.T) {
// 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 @@ func TestSnapshot_EnvConfiguration(t *testing.T) {
}
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 @@ java_import {
})
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 @@ java_sdk_library_import {
})
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 fd6c4e7b8..60e5b9521 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -91,6 +91,7 @@ func testSnapshotWithSystemServerClasspathFragment(t *testing.T, sdk string, tar
}
func TestSnapshotWithPartialSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -185,6 +186,7 @@ prebuilt_systemserverclasspath_fragment {
}
func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -231,6 +233,7 @@ func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
}
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
sdk {
@@ -298,6 +301,7 @@ prebuilt_systemserverclasspath_fragment {
`
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 @@ java_sdk_library_import {
})
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 @@ prebuilt_systemserverclasspath_fragment {
})
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 @@ prebuilt_systemserverclasspath_fragment {
})
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 21d457c5f..f5518c46f 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -128,12 +128,11 @@ func ensureListContains(t *testing.T, result []string, expected string) {
// 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 @@ func CheckSnapshot(t *testing.T, result *android.TestResult, name string, dir st
}
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 @@ func CheckSnapshot(t *testing.T, result *android.TestResult, name string, dir st
})
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 @@ type snapshotBuildInfo struct {
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
}