Make more cc tests parallel

Test: go test soong cc tests
Change-Id: I5ade33b1579ae46571728e051471147e627a7d38
This commit is contained in:
Liz Kammer 2022-10-31 16:27:38 -04:00
parent c03724c442
commit 7c5d1591bc
7 changed files with 88 additions and 3 deletions

View file

@ -38,6 +38,7 @@ func hasDirectDep(ctx visitDirectDepsInterface, m android.Module, wantDep androi
}
func TestAfdoDeps(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "libTest",
@ -93,6 +94,7 @@ func TestAfdoDeps(t *testing.T) {
}
func TestAfdoEnabledOnStaticDepNoAfdo(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "libTest",

View file

@ -22,6 +22,7 @@ import (
)
func TestCcBinaryWithBazel(t *testing.T) {
t.Parallel()
bp := `
cc_binary {
name: "foo",
@ -55,6 +56,7 @@ cc_binary {
}
func TestBinaryLinkerScripts(t *testing.T) {
t.Parallel()
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
cc_binary {
name: "foo",

View file

@ -154,6 +154,7 @@ func TestPrepareForTestWithCcDefaultModules(t *testing.T) {
}
func TestVendorSrc(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library {
name: "libTest",
@ -220,6 +221,7 @@ func checkInstallPartition(t *testing.T, ctx *android.TestContext, name, variant
}
func TestInstallPartition(t *testing.T) {
t.Parallel()
t.Helper()
ctx := prepareForCcTest.RunTestWithBp(t, `
cc_library {
@ -352,6 +354,7 @@ func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module str
}
func TestVndk(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libvndk",
@ -569,6 +572,7 @@ func TestVndk(t *testing.T) {
}
func TestVndkWithHostSupported(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library {
name: "libvndk_host_supported",
@ -605,6 +609,7 @@ func TestVndkWithHostSupported(t *testing.T) {
}
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
t.Parallel()
bp := `
llndk_libraries_txt {
name: "llndk.libraries.txt",
@ -621,6 +626,7 @@ func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
}
func TestVndkUsingCoreVariant(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libvndk",
@ -673,6 +679,7 @@ func TestVndkUsingCoreVariant(t *testing.T) {
}
func TestDataLibs(t *testing.T) {
t.Parallel()
bp := `
cc_test_library {
name: "test_lib",
@ -723,6 +730,7 @@ func TestDataLibs(t *testing.T) {
}
func TestDataLibsRelativeInstallPath(t *testing.T) {
t.Parallel()
bp := `
cc_test_library {
name: "test_lib",
@ -781,6 +789,7 @@ func TestDataLibsRelativeInstallPath(t *testing.T) {
}
func TestTestBinaryTestSuites(t *testing.T) {
t.Parallel()
bp := `
cc_test {
name: "main_test",
@ -812,6 +821,7 @@ func TestTestBinaryTestSuites(t *testing.T) {
}
func TestTestLibraryTestSuites(t *testing.T) {
t.Parallel()
bp := `
cc_test_library {
name: "main_test_lib",
@ -843,6 +853,7 @@ func TestTestLibraryTestSuites(t *testing.T) {
}
func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
t.Parallel()
ctx := testCcNoVndk(t, `
cc_library {
name: "libvndk",
@ -899,6 +910,7 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
}
func TestVndkModuleError(t *testing.T) {
t.Parallel()
// Check the error message for vendor_available and product_available properties.
testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`", `
cc_library {
@ -940,6 +952,7 @@ func TestVndkModuleError(t *testing.T) {
}
func TestVndkDepError(t *testing.T) {
t.Parallel()
// Check whether an error is emitted when a VNDK lib depends on a system lib.
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
cc_library {
@ -1131,6 +1144,7 @@ func TestVndkDepError(t *testing.T) {
}
func TestDoubleLoadbleDep(t *testing.T) {
t.Parallel()
// okay to link : LLNDK -> double_loadable VNDK
testCc(t, `
cc_library {
@ -1235,6 +1249,7 @@ func TestDoubleLoadbleDep(t *testing.T) {
}
func TestDoubleLoadableDepError(t *testing.T) {
t.Parallel()
// Check whether an error is emitted when a LLNDK depends on a non-double_loadable VNDK lib.
testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double_loadable", `
cc_library {
@ -1317,6 +1332,7 @@ func TestDoubleLoadableDepError(t *testing.T) {
}
func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
t.Parallel()
testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", `
cc_library {
name: "libvndksp",
@ -1342,6 +1358,7 @@ func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
}
func TestVndkExt(t *testing.T) {
t.Parallel()
// This test checks the VNDK-Ext properties.
bp := `
cc_library {
@ -1429,6 +1446,7 @@ func TestVndkExt(t *testing.T) {
}
func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
t.Parallel()
// This test checks the VNDK-Ext properties when BOARD_VNDK_VERSION is not set.
ctx := testCcNoVndk(t, `
cc_library {
@ -1460,6 +1478,7 @@ func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
}
func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
t.Parallel()
// This test checks the VNDK-Ext properties when PRODUCT_PRODUCT_VNDK_VERSION is not set.
ctx := testCcNoProductVndk(t, `
cc_library {
@ -1491,6 +1510,7 @@ func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
}
func TestVndkExtError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted in ill-formed vndk-ext definition.
testCcError(t, "must set `vendor: true` or `product_specific: true` to set `extends: \".*\"`", `
cc_library {
@ -1581,6 +1601,7 @@ func TestVndkExtError(t *testing.T) {
}
func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted for inconsistent support_system_process.
testCcError(t, "module \".*\" with mismatched support_system_process", `
cc_library {
@ -1630,6 +1651,7 @@ func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
}
func TestVndkExtVendorAvailableFalseError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted when a VNDK-Ext library extends a VNDK library
// with `private: true`.
testCcError(t, "`extends` refers module \".*\" which has `private: true`", `
@ -1680,6 +1702,7 @@ func TestVndkExtVendorAvailableFalseError(t *testing.T) {
}
func TestVendorModuleUseVndkExt(t *testing.T) {
t.Parallel()
// This test ensures a vendor module can depend on a VNDK-Ext library.
testCc(t, `
cc_library {
@ -1734,6 +1757,7 @@ func TestVendorModuleUseVndkExt(t *testing.T) {
}
func TestVndkExtUseVendorLib(t *testing.T) {
t.Parallel()
// This test ensures a VNDK-Ext library can depend on a vendor library.
testCc(t, `
cc_library {
@ -1798,6 +1822,7 @@ func TestVndkExtUseVendorLib(t *testing.T) {
}
func TestProductVndkExtDependency(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libvndk",
@ -1865,6 +1890,7 @@ func TestProductVndkExtDependency(t *testing.T) {
}
func TestVndkSpExtUseVndkError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted if a VNDK-SP-Ext library depends on a VNDK
// library.
testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
@ -1951,6 +1977,7 @@ func TestVndkSpExtUseVndkError(t *testing.T) {
}
func TestVndkUseVndkExtError(t *testing.T) {
t.Parallel()
// This test ensures an error is emitted if a VNDK/VNDK-SP library depends on a
// VNDK-Ext/VNDK-SP-Ext library.
testCcError(t, "dependency \".*\" of \".*\" missing variant", `
@ -2096,6 +2123,7 @@ func TestVndkUseVndkExtError(t *testing.T) {
}
func TestEnforceProductVndkVersion(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libllndk",
@ -2221,6 +2249,7 @@ func TestEnforceProductVndkVersion(t *testing.T) {
}
func TestEnforceProductVndkVersionErrors(t *testing.T) {
t.Parallel()
testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
cc_library {
name: "libprod",
@ -2318,6 +2347,7 @@ func TestEnforceProductVndkVersionErrors(t *testing.T) {
}
func TestMakeLinkType(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libvndk",
@ -2609,6 +2639,7 @@ func parseModuleDeps(text string) (modulesInOrder []android.Path, allDeps map[an
}
func TestStaticLibDepReordering(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library {
name: "a",
@ -2648,6 +2679,7 @@ func TestStaticLibDepReordering(t *testing.T) {
}
func TestStaticLibDepReorderingWithShared(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library {
name: "a",
@ -2695,6 +2727,7 @@ func checkEquals(t *testing.T, message string, expected, actual interface{}) {
}
func TestLlndkLibrary(t *testing.T) {
t.Parallel()
result := prepareForCcTest.RunTestWithBp(t, `
cc_library {
name: "libllndk",
@ -2782,6 +2815,7 @@ func TestLlndkLibrary(t *testing.T) {
}
func TestLlndkHeaders(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_headers {
name: "libllndk_headers",
@ -2914,6 +2948,7 @@ const runtimeLibAndroidBp = `
`
func TestRuntimeLibs(t *testing.T) {
t.Parallel()
ctx := testCc(t, runtimeLibAndroidBp)
// runtime_libs for core variants use the module names without suffixes.
@ -2950,6 +2985,7 @@ func TestRuntimeLibs(t *testing.T) {
}
func TestExcludeRuntimeLibs(t *testing.T) {
t.Parallel()
ctx := testCc(t, runtimeLibAndroidBp)
variant := "android_arm64_armv8-a_shared"
@ -2962,6 +2998,7 @@ func TestExcludeRuntimeLibs(t *testing.T) {
}
func TestRuntimeLibsNoVndk(t *testing.T) {
t.Parallel()
ctx := testCcNoVndk(t, runtimeLibAndroidBp)
// If DeviceVndkVersion is not defined, then runtime_libs are copied as-is.
@ -3002,6 +3039,7 @@ const staticLibAndroidBp = `
`
func TestStaticLibDepExport(t *testing.T) {
t.Parallel()
ctx := testCc(t, staticLibAndroidBp)
// Check the shared version of lib2.
@ -3089,6 +3127,7 @@ func (ctx *mockContext) PropertyErrorf(property, format string, args ...interfac
}
func TestCompilerFlags(t *testing.T) {
t.Parallel()
for _, testCase := range compilerFlagsTestCases {
ctx := &mockContext{result: true}
CheckBadCompilerFlags(ctx, "", []string{testCase.in})
@ -3102,6 +3141,7 @@ func TestCompilerFlags(t *testing.T) {
}
func TestRecovery(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_shared {
name: "librecovery",
@ -3137,6 +3177,7 @@ func TestRecovery(t *testing.T) {
}
func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
t.Parallel()
bp := `
cc_prebuilt_test_library_shared {
name: "test_lib",
@ -3183,6 +3224,7 @@ func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
}
func TestVersionedStubs(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_shared {
name: "libFoo",
@ -3249,6 +3291,7 @@ func TestVersionedStubs(t *testing.T) {
}
func TestVersioningMacro(t *testing.T) {
t.Parallel()
for _, tc := range []struct{ moduleName, expected string }{
{"libc", "__LIBC_API__"},
{"libfoo", "__LIBFOO_API__"},
@ -3269,6 +3312,7 @@ func pathsToBase(paths android.Paths) []string {
}
func TestStaticLibArchiveArgs(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_static {
name: "foo",
@ -3309,6 +3353,7 @@ func TestStaticLibArchiveArgs(t *testing.T) {
}
func TestSharedLibLinkingArgs(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_static {
name: "foo",
@ -3357,6 +3402,7 @@ func TestSharedLibLinkingArgs(t *testing.T) {
}
func TestStaticExecutable(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_binary {
name: "static_test",
@ -3382,6 +3428,7 @@ func TestStaticExecutable(t *testing.T) {
}
func TestStaticDepsOrderWithStubs(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_binary {
name: "mybin",
@ -3422,6 +3469,7 @@ func TestStaticDepsOrderWithStubs(t *testing.T) {
}
func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) {
t.Parallel()
testCcError(t, `module "libA" .* depends on disabled module "libB"`, `
cc_library {
name: "libA",
@ -3549,10 +3597,12 @@ func VerifyAFLFuzzTargetVariant(t *testing.T, variant string) {
}
func TestAFLFuzzTargetForDevice(t *testing.T) {
t.Parallel()
VerifyAFLFuzzTargetVariant(t, "android_arm64_armv8-a")
}
func TestAFLFuzzTargetForLinuxHost(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("requires linux")
}
@ -3563,6 +3613,7 @@ func TestAFLFuzzTargetForLinuxHost(t *testing.T) {
// Simple smoke test for the cc_fuzz target that ensures the rule compiles
// correctly.
func TestFuzzTarget(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_fuzz {
name: "fuzz_smoke_test",
@ -3573,9 +3624,6 @@ func TestFuzzTarget(t *testing.T) {
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
}
func TestAidl(t *testing.T) {
}
func assertString(t *testing.T, got, expected string) {
t.Helper()
if got != expected {
@ -3604,6 +3652,7 @@ func assertMapKeys(t *testing.T, m map[string]string, expected []string) {
}
func TestDefaults(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_defaults {
name: "defaults",
@ -3663,6 +3712,7 @@ func TestDefaults(t *testing.T) {
}
func TestProductVariableDefaults(t *testing.T) {
t.Parallel()
bp := `
cc_defaults {
name: "libfoo_defaults",
@ -3724,6 +3774,7 @@ func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) {
}
func TestInstallSharedLibs(t *testing.T) {
t.Parallel()
bp := `
cc_binary {
name: "bin",
@ -3819,6 +3870,7 @@ func TestInstallSharedLibs(t *testing.T) {
}
func TestStubsLibReexportsHeaders(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_shared {
name: "libclient",
@ -3851,6 +3903,7 @@ func TestStubsLibReexportsHeaders(t *testing.T) {
}
func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library {
name: "libfoo",
@ -3869,6 +3922,7 @@ func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
}
func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
sdkVersion string
@ -3921,6 +3975,7 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
}
func TestMinSdkVersionInClangTriple(t *testing.T) {
t.Parallel()
ctx := testCc(t, `
cc_library_shared {
name: "libfoo",
@ -3933,6 +3988,7 @@ func TestMinSdkVersionInClangTriple(t *testing.T) {
}
func TestNonDigitMinSdkVersionInClangTriple(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "libfoo",
@ -3952,6 +4008,7 @@ func TestNonDigitMinSdkVersionInClangTriple(t *testing.T) {
}
func TestIncludeDirsExporting(t *testing.T) {
t.Parallel()
// Trim spaces from the beginning, end and immediately after any newline characters. Leaves
// embedded newline characters alone.
@ -4223,6 +4280,7 @@ func TestIncludeDirsExporting(t *testing.T) {
}
func TestIncludeDirectoryOrdering(t *testing.T) {
t.Parallel()
baseExpectedFlags := []string{
"${config.ArmThumbCflags}",
"${config.ArmCflags}",
@ -4426,6 +4484,7 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
}
func TestCcBuildBrokenClangProperty(t *testing.T) {
t.Parallel()
tests := []struct {
name string
clang bool
@ -4476,6 +4535,7 @@ func TestCcBuildBrokenClangProperty(t *testing.T) {
}
func TestCcBuildBrokenClangAsFlags(t *testing.T) {
t.Parallel()
tests := []struct {
name string
clangAsFlags []string
@ -4521,6 +4581,7 @@ func TestCcBuildBrokenClangAsFlags(t *testing.T) {
}
func TestCcBuildBrokenClangCFlags(t *testing.T) {
t.Parallel()
tests := []struct {
name string
clangCFlags []string

View file

@ -59,6 +59,7 @@ func TestLibraryHeaders(t *testing.T) {
}
func TestPrebuiltLibraryHeadersPreferred(t *testing.T) {
t.Parallel()
bp := `
cc_library_headers {
name: "headers",

View file

@ -23,6 +23,7 @@ import (
)
func TestLibraryReuse(t *testing.T) {
t.Parallel()
t.Run("simple", func(t *testing.T) {
ctx := testCc(t, `
cc_library {
@ -191,6 +192,7 @@ func TestLibraryReuse(t *testing.T) {
}
func TestStubsVersions(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libfoo",
@ -214,6 +216,7 @@ func TestStubsVersions(t *testing.T) {
}
func TestStubsVersions_NotSorted(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libfoo",
@ -229,6 +232,7 @@ func TestStubsVersions_NotSorted(t *testing.T) {
}
func TestStubsVersions_ParseError(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "libfoo",
@ -243,6 +247,7 @@ func TestStubsVersions_ParseError(t *testing.T) {
}
func TestCcLibraryWithBazel(t *testing.T) {
t.Parallel()
bp := `
cc_library {
name: "foo",
@ -304,6 +309,7 @@ cc_library {
}
func TestLibraryVersionScript(t *testing.T) {
t.Parallel()
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
cc_library {
name: "libfoo",
@ -321,6 +327,7 @@ func TestLibraryVersionScript(t *testing.T) {
}
func TestLibraryDynamicList(t *testing.T) {
t.Parallel()
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
cc_library {
name: "libfoo",
@ -338,6 +345,7 @@ func TestLibraryDynamicList(t *testing.T) {
}
func TestCcLibrarySharedWithBazel(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "foo",
@ -383,6 +391,7 @@ cc_library_shared {
}
func TestWholeStaticLibPrebuilts(t *testing.T) {
t.Parallel()
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
cc_prebuilt_library_static {
name: "libprebuilt",

View file

@ -23,6 +23,7 @@ import (
)
func TestThinLtoDeps(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "lto_enabled",
@ -106,6 +107,7 @@ func TestThinLtoDeps(t *testing.T) {
}
func TestThinLtoOnlyOnStaticDep(t *testing.T) {
t.Parallel()
bp := `
cc_library_shared {
name: "root",

View file

@ -86,6 +86,7 @@ func expectInstallDep(t *testing.T, from, to android.TestingModule) {
}
func TestAsan(t *testing.T) {
t.Parallel()
bp := `
cc_binary {
name: "bin_with_asan",
@ -233,6 +234,7 @@ func TestAsan(t *testing.T) {
}
func TestTsan(t *testing.T) {
t.Parallel()
bp := `
cc_binary {
name: "bin_with_tsan",
@ -318,6 +320,7 @@ func TestMiscUndefined(t *testing.T) {
t.Skip("requires linux")
}
t.Parallel()
bp := `
cc_binary {
name: "bin_with_ubsan",
@ -417,6 +420,7 @@ func TestMiscUndefined(t *testing.T) {
}
func TestFuzz(t *testing.T) {
t.Parallel()
bp := `
cc_binary {
name: "bin_with_fuzzer",
@ -551,6 +555,7 @@ func TestFuzz(t *testing.T) {
}
func TestUbsan(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("requires linux")
}
@ -794,6 +799,7 @@ var prepareForTestWithMemtagHeap = android.GroupFixturePreparers(
)
func TestSanitizeMemtagHeap(t *testing.T) {
t.Parallel()
variant := "android_arm64_armv8-a"
result := android.GroupFixturePreparers(
@ -866,6 +872,7 @@ func TestSanitizeMemtagHeap(t *testing.T) {
}
func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) {
t.Parallel()
variant := "android_arm64_armv8-a"
result := android.GroupFixturePreparers(
@ -940,6 +947,7 @@ func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) {
}
func TestSanitizeMemtagHeapWithSanitizeDeviceDiag(t *testing.T) {
t.Parallel()
variant := "android_arm64_armv8-a"
result := android.GroupFixturePreparers(