Lines Matching refs:t
47 func testCcWithConfig(t *testing.T, config android.Config) *android.TestContext {
48 t.Helper()
49 result := prepareForCcTest.RunTestWithConfig(t, config)
64 func testCc(t *testing.T, bp string) *android.TestContext {
65 t.Helper()
66 result := prepareForCcTest.RunTestWithBp(t, bp)
75 func testCcNoVndk(t *testing.T, bp string) *android.TestContext {
76 t.Helper()
77 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
80 return testCcWithConfig(t, config)
88 func testCcNoProductVndk(t *testing.T, bp string) *android.TestContext {
89 t.Helper()
90 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
94 return testCcWithConfig(t, config)
102 func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) {
103 t.Helper()
107 RunTestWithConfig(t, config)
115 func testCcError(t *testing.T, pattern string, bp string) {
116 t.Helper()
117 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
120 testCcErrorWithConfig(t, pattern, config)
129 func testCcErrorProductVndk(t *testing.T, pattern string, bp string) {
130 t.Helper()
131 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
135 testCcErrorWithConfig(t, pattern, config)
148 func TestPrepareForTestWithCcDefaultModules(t *testing.T) {
152 ).RunTest(t)
155 func TestFuchsiaDeps(t *testing.T) {
156 t.Helper()
172 ).RunTestWithBp(t, bp)
190 t.Errorf("fuchsia libs must link libcompiler_rt and libbioniccompat")
194 func TestFuchsiaTargetDecl(t *testing.T) {
195 t.Helper()
211 ).RunTestWithBp(t, bp)
217 android.AssertArrayString(t, "libTest inputs", []string{"foo.o", "bar.o"}, objs)
220 func TestVendorSrc(t *testing.T) {
221 ctx := testCc(t, `
243 t.Errorf("inputs of libTest must be []string{\"foo.o\", \"bar.o\"}, but was %#v.", objs)
247 func checkInstallPartition(t *testing.T, ctx *android.TestContext, name, variant, expected string) {
254 t.Errorf("%s variant of %q must not be installed to %s partition", variant, name, partition)
260 t.Errorf("%s variant of %q must be installed to %s partition", variant, name, partition)
281 t.Errorf("%s variant of %q is expected to be installed to %s partition,"+
286 func TestInstallPartition(t *testing.T) {
287 t.Helper()
288 ctx := prepareForCcTest.RunTestWithBp(t, `
336 checkInstallPartition(t, ctx, "libsystem", coreVariant, "system")
337 checkInstallPartition(t, ctx, "libsystem_ext", coreVariant, "system_ext")
338 checkInstallPartition(t, ctx, "libproduct", productVariant, "product")
339 checkInstallPartition(t, ctx, "libvendor", vendorVariant, "vendor")
340 checkInstallPartition(t, ctx, "libodm", vendorVariant, "odm")
342 checkInstallPartition(t, ctx, "liball_available", coreVariant, "system")
343 checkInstallPartition(t, ctx, "liball_available", productVariant, "product")
344 checkInstallPartition(t, ctx, "liball_available", vendorVariant, "vendor")
346 checkInstallPartition(t, ctx, "libsystem_ext_all_available", coreVariant, "system_ext")
347 checkInstallPartition(t, ctx, "libsystem_ext_all_available", productVariant, "product")
348 checkInstallPartition(t, ctx, "libsystem_ext_all_available", vendorVariant, "vendor")
350 checkInstallPartition(t, ctx, "liball_available_odm", coreVariant, "system")
351 checkInstallPartition(t, ctx, "liball_available_odm", productVariant, "product")
352 checkInstallPartition(t, ctx, "liball_available_odm", vendorVariant, "odm")
354 checkInstallPartition(t, ctx, "libproduct_vendoravailable", productVariant, "product")
355 checkInstallPartition(t, ctx, "libproduct_vendoravailable", vendorVariant, "vendor")
357 checkInstallPartition(t, ctx, "libproduct_odmavailable", productVariant, "product")
358 checkInstallPartition(t, ctx, "libproduct_odmavailable", vendorVariant, "odm")
361 func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string,
364 t.Helper()
371 t.Errorf("%q must have libraryDecorator", name)
373 t.Errorf("%q must use %q as subdir but it is using %q", name, subDir,
379 t.Fatalf("%q must have `vndkdep`", name)
382 t.Errorf("%q IsVndk() must equal to true", name)
385 t.Errorf("%q IsVndkSp() must equal to %t", name, isVndkSp)
391 t.Errorf("%q IsVndkExt() must equal to %t", name, isVndkExt)
395 t.Errorf("%q must extend from %q but get %q", name, extends, actualExtends)
399 func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingS…
400 t.Helper()
402 outputFiles := mod.OutputFiles(t, "")
404 t.Errorf("%q must have single output\n", moduleName)
413 t.Errorf("Missing rule for module %q output file %q", moduleName, outputFiles[0])
417 …t.Errorf("The input of snapshot %q must be %q, but %q", moduleName, out.Input.String(), outputFile…
423 t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0])
428 func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, modu…
429 t.Helper()
430 …checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true…
433 func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleto…
434 t.Helper()
435 …checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, fals…
438 func checkSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, …
439 t.Helper()
440 …checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true…
443 func checkWriteFileOutput(t *testing.T, params android.TestingBuildParams, expected []string) {
444 t.Helper()
445 content := android.ContentFromFileRuleForTests(t, params)
447 assertArrayString(t, actual, expected)
450 func checkVndkOutput(t *testing.T, ctx *android.TestContext, output string, expected []string) {
451 t.Helper()
453 checkWriteFileOutput(t, vndkSnapshot.Output(output), expected)
456 func checkVndkLibrariesOutput(t *testing.T, ctx *android.TestContext, module string, expected []str…
457 t.Helper()
459 assertArrayString(t, got, expected)
462 func TestVndk(t *testing.T) {
593 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
598 ctx := testCcWithConfig(t, config)
602 checkVndkModule(t, ctx, "libvndk", "", false, "", vendorVariant)
603 checkVndkModule(t, ctx, "libvndk_private", "", false, "", vendorVariant)
604 checkVndkModule(t, ctx, "libvndk_product", "", false, "", vendorVariant)
605 checkVndkModule(t, ctx, "libvndk_sp", "", true, "", vendorVariant)
606 checkVndkModule(t, ctx, "libvndk_sp_private", "", true, "", vendorVariant)
607 checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", vendorVariant)
609 checkVndkModule(t, ctx, "libvndk_product", "", false, "", productVariant)
610 checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", productVariant)
634 checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLibPath, variant)
635 checkSnapshot(t, ctx, snapshotSingleton, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd)
636 …checkSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLibPath,…
637 …checkSnapshot(t, ctx, snapshotSingleton, "libvndk_product", "libvndk_product.so", vndkCoreLib2ndPa…
638 checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLibPath, variant)
639 …checkSnapshot(t, ctx, snapshotSingleton, "libvndk_sp", "libvndk_sp-x.so", vndkSpLib2ndPath, varian…
640 checkSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLibPath, variant)
641 checkSnapshot(t, ctx, snapshotSingleton, "libllndk", "libllndk.so", llndkLib2ndPath, variant2nd)
644 …checkSnapshot(t, ctx, snapshotSingleton, "llndk.libraries.txt", "llndk.libraries.txt", snapshotCon…
645 …checkSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snaps…
646 …checkSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotC…
647 …checkSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt",…
648 …checkSnapshot(t, ctx, snapshotSingleton, "vndkproduct.libraries.txt", "vndkproduct.libraries.txt",…
650 checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
671 …checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libclang_rt.hwasan-ll…
672 …checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk…
673 …checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", …
674 …checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-priva…
675 …checkVndkLibrariesOutput(t, ctx, "vndkproduct.libraries.txt", []string{"libc++.so", "libvndk_produ…
676 checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil)
679 func TestVndkWithHostSupported(t *testing.T) {
680 ctx := testCc(t, `
712 checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"})
715 func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
721 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
724 ctx := testCcWithConfig(t, config)
727 entries := android.AndroidMkEntriesForTest(t, ctx, module.Module())[0]
728 assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.29.txt"})
731 func TestVndkUsingCoreVariant(t *testing.T) {
771 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
778 ctx := testCcWithConfig(t, config)
780 …checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", []string{"libc++.so", "libvndk2.…
783 func TestDataLibs(t *testing.T) {
798 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
803 ctx := testCcWithConfig(t, config)
808 t.Errorf("Expected cc_test to produce output files, error: %s", err)
812 t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
816 t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
824 t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
828 t.Errorf("expected test data file to be 'test_lib.so', but was '%s'", testBinaryPath)
833 func TestDataLibsRelativeInstallPath(t *testing.T) {
849 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
854 ctx := testCcWithConfig(t, config)
859 t.Fatalf("Expected cc_test to produce output files, error: %s", err)
862 t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
865 t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
871 t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
873 entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
875 t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
880 func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
881 ctx := testCcNoVndk(t, `
919 checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
936 func TestVndkModuleError(t *testing.T) {
938 …testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`…
948 …testCcErrorProductVndk(t, "vndk: vendor_available must be set to true when `vndk: {enabled: true}`…
959 …testCcErrorProductVndk(t, "product properties must have the same values with the vendor properties…
977 func TestVndkDepError(t *testing.T) {
979 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
998 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
1018 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
1038 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
1059 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1084 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1104 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1125 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1146 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1168 func TestDoubleLoadbleDep(t *testing.T) {
1170 testCc(t, `
1190 testCc(t, `
1210 testCc(t, `
1225 testCc(t, `
1249 testCc(t, `
1272 func TestDoubleLoadableDepError(t *testing.T) {
1274 …testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double…
1294 …testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double…
1311 …testCcError(t, "module \".*\" variant \".*\": link.* \".*\" which is not LL-NDK, VNDK-SP, .*double…
1333 testCcError(t, "module \"libllndk\".* links a library \"libnondoubleloadable\".*double_loadable", `
1354 func TestCheckVndkMembershipBeforeDoubleLoadable(t *testing.T) {
1355 testCcError(t, "module \"libvndksp\" variant .*: .*: VNDK-SP must only depend on VNDK-SP", `
1379 func TestVndkExt(t *testing.T) {
1449 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
1454 ctx := testCcWithConfig(t, config)
1456 checkVndkModule(t, ctx, "libvndk_ext", "vndk", false, "libvndk", vendorVariant)
1457 checkVndkModule(t, ctx, "libvndk_ext_product", "vndk", false, "libvndk", productVariant)
1460 assertString(t, mod_vendor.outputFile.Path().Base(), "libvndk2-suffix.so")
1463 assertString(t, mod_product.outputFile.Path().Base(), "libvndk2-suffix.so")
1466 func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {
1468 ctx := testCcNoVndk(t, `
1493 t.Errorf("\"libvndk_ext\" must extend from \"libvndk\" but get %q", extends)
1497 func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
1499 ctx := testCcNoProductVndk(t, `
1524 t.Errorf("\"libvndk_ext_product\" must extend from \"libvndk\" but get %q", extends)
1528 func TestVndkExtError(t *testing.T) {
1530 testCcError(t, "must set `vendor: true` or `product_specific: true` to set `extends: \".*\"`", `
1551 testCcError(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", `
1572 testCcErrorProductVndk(t, "must set `extends: \"\\.\\.\\.\"` to vndk extension", `
1593 testCcErrorProductVndk(t, "must not set at the same time as `vndk: {extends: \"\\.\\.\\.\"}`", `
1618 func TestVndkExtInconsistentSupportSystemProcessError(t *testing.T) {
1620 testCcError(t, "module \".*\" with mismatched support_system_process", `
1643 testCcError(t, "module \".*\" with mismatched support_system_process", `
1667 func TestVndkExtVendorAvailableFalseError(t *testing.T) {
1670 testCcError(t, "`extends` refers module \".*\" which has `private: true`", `
1693 testCcErrorProductVndk(t, "`extends` refers module \".*\" which has `private: true`", `
1717 func TestVendorModuleUseVndkExt(t *testing.T) {
1719 testCc(t, `
1771 func TestVndkExtUseVendorLib(t *testing.T) {
1773 testCc(t, `
1803 testCc(t, `
1835 func TestProductVndkExtDependency(t *testing.T) {
1894 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
1899 testCcWithConfig(t, config)
1902 func TestVndkSpExtUseVndkError(t *testing.T) {
1905 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1942 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
1988 func TestVndkUseVndkExtError(t *testing.T) {
1991 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
2024 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
2060 testCcError(t, "dependency \".*\" of \".*\" missing variant", `
2096 testCcError(t, "module \".*\" variant \".*\": \\(.*\\) should not link to \".*\"", `
2133 func TestEnforceProductVndkVersion(t *testing.T) {
2219 ctx := prepareForCcTest.RunTestWithBp(t, bp).TestContext
2221 checkVndkModule(t, ctx, "libvndk", "", false, "", productVariant)
2222 checkVndkModule(t, ctx, "libvndk_sp", "", true, "", productVariant)
2225 assertString(t, mod_vendor.outputFile.Path().Base(), "libboth_available-vendor.so")
2228 assertString(t, mod_product.outputFile.Path().Base(), "libboth_available-product.so")
2230 ensureStringContains := func(t *testing.T, str string, substr string) {
2231 t.Helper()
2233 t.Errorf("%q is not found in %v", substr, str)
2236 ensureStringNotContains := func(t *testing.T, str string, substr string) {
2237 t.Helper()
2239 t.Errorf("%q is found in %v", substr, str)
2248 ensureStringContains(t, vendor_cflags, "-D__ANDROID_VNDK__")
2249 ensureStringContains(t, vendor_cflags, "-D__ANDROID_VENDOR__")
2250 ensureStringNotContains(t, vendor_cflags, "-D__ANDROID_PRODUCT__")
2253 ensureStringContains(t, product_cflags, "-D__ANDROID_VNDK__")
2254 ensureStringContains(t, product_cflags, "-D__ANDROID_PRODUCT__")
2255 ensureStringNotContains(t, product_cflags, "-D__ANDROID_VENDOR__")
2258 func TestEnforceProductVndkVersionErrors(t *testing.T) {
2259 testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
2274 testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
2288 testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
2303 testCcErrorProductVndk(t, "non-VNDK module should not link to \".*\" which has `private: true`", `
2323 testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
2338 testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:", `
2355 func TestMakeLinkType(t *testing.T) {
2443 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
2447 ctx := testCcWithConfig(t, config)
2449 checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt",
2451 checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt",
2453 checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt",
2455 checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt",
2477 t.Run(test.name, func(t *testing.T) {
2479 assertString(t, module.makeLinkType, test.expected)
2655 func TestStaticLibDepReordering(t *testing.T) {
2656 ctx := testCc(t, `
2685 t.Errorf("staticDeps orderings were not propagated correctly"+
2694 func TestStaticLibDepReorderingWithShared(t *testing.T) {
2695 ctx := testCc(t, `
2720 t.Errorf("staticDeps orderings did not account for shared libs"+
2729 func checkEquals(t *testing.T, message string, expected, actual interface{}) {
2730 t.Helper()
2732 t.Errorf(message+
2741 func TestLlndkLibrary(t *testing.T) {
2742 result := prepareForCcTest.RunTestWithBp(t, `
2811 android.AssertArrayString(t, "variants for llndk stubs", expected, actual)
2814 android.AssertSame(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"])
2817 android.AssertSame(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
2820 t.Helper()
2823 android.AssertPathsRelativeToTopEquals(t, "exported include dirs for "+module+"["+variant+"]",
2835 func TestLlndkHeaders(t *testing.T) {
2836 ctx := testCc(t, `
2866 t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags)
2870 func checkRuntimeLibs(t *testing.T, expected []string, module *Module) {
2873 t.Errorf("incorrect runtime_libs for shared libs"+
2967 func TestRuntimeLibs(t *testing.T) {
2968 ctx := testCc(t, runtimeLibAndroidBp)
2974 checkRuntimeLibs(t, []string{"liball_available"}, module)
2977 checkRuntimeLibs(t, []string{"liball_available"}, module)
2980 checkRuntimeLibs(t, []string{"liball_available"}, module)
2987 checkRuntimeLibs(t, []string{"liball_available.vendor"}, module)
2990 …checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1", "libproduct_vendor.vendor"},…
2997 checkRuntimeLibs(t, []string{"liball_available.product"}, module)
3000 …checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1", "libproduct_vendor"}, modu…
3003 func TestExcludeRuntimeLibs(t *testing.T) {
3004 ctx := testCc(t, runtimeLibAndroidBp)
3008 checkRuntimeLibs(t, []string{"liball_available"}, module)
3012 checkRuntimeLibs(t, nil, module)
3015 func TestRuntimeLibsNoVndk(t *testing.T) {
3016 ctx := testCcNoVndk(t, runtimeLibAndroidBp)
3023 checkRuntimeLibs(t, []string{"liball_available"}, module)
3026 checkRuntimeLibs(t, []string{"liball_available", "libvendor1", "libproduct_vendor"}, module)
3029 checkRuntimeLibs(t, []string{"liball_available", "libproduct1", "libproduct_vendor"}, module)
3032 func checkStaticLibs(t *testing.T, expected []string, module *Module) {
3033 t.Helper()
3036 t.Errorf("incorrect static_libs"+
3055 func TestStaticLibDepExport(t *testing.T) {
3056 ctx := testCc(t, staticLibAndroidBp)
3061 …checkStaticLibs(t, []string{"lib1", "libc++demangle", "libclang_rt.builtins-aarch64-android"}, mod…
3067 …checkStaticLibs(t, []string{"lib1", "libc++_static", "libc++demangle", "libclang_rt.builtins-aarch…
3142 func TestCompilerFlags(t *testing.T) {
3147 t.Errorf("incorrect output:")
3148 t.Errorf(" input: %#v", testCase.in)
3149 t.Errorf(" expected: %#v", testCase.out)
3150 t.Errorf(" got: %#v", ctx.result)
3155 func TestRecovery(t *testing.T) {
3156 ctx := testCc(t, `
3176 t.Errorf("variants of librecovery must be \"%s\" only, but was %#v", arm64, variants)
3181 t.Errorf("multilib was set to 32 for librecovery32, but its variants has %s.", arm64)
3186 t.Errorf("recovery variant of libHalInRecovery must not specific to device, soc, or product")
3190 func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
3205 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
3210 ctx := testCcWithConfig(t, config)
3215 t.Fatalf("Expected cc_test to produce output files, error: %s", err)
3218 t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
3221 t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
3227 t.Errorf("expected test output file to be 'main_test', but was '%s'", outputPath)
3229 entries := android.AndroidMkEntriesForTest(t, ctx, module)[0]
3231 t.Errorf("expected LOCAL_TEST_DATA to end with `:test_lib.so:foo/bar/baz`,"+
3236 func TestVersionedStubs(t *testing.T) {
3237 ctx := testCc(t, `
3277 t.Errorf("variants of libFoo expected:\n")
3279 t.Errorf("%q\n", v)
3281 t.Errorf(", but got:\n")
3283 t.Errorf("%q\n", v)
3291 t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags)
3298 t.Errorf("%q is not found in %q", libFoo1VersioningMacro, cFlags)
3302 func TestVersioningMacro(t *testing.T) {
3310 checkEquals(t, tc.moduleName, tc.expected, versioningMacroName(tc.moduleName))
3314 func TestStaticExecutable(t *testing.T) {
3315 ctx := testCc(t, `
3328 t.Errorf("Static lib %q was not found in %q", lib, libFlags)
3334 t.Errorf("Shared lib %q was found in %q", lib, libFlags)
3339 func TestStaticDepsOrderWithStubs(t *testing.T) {
3340 ctx := testCc(t, `
3370 t.Errorf("staticDeps orderings were not propagated correctly"+
3379 func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) {
3380 testCcError(t, `module "libA" .* depends on disabled module "libB"`, `
3399 func TestFuzzTarget(t *testing.T) {
3400 ctx := testCc(t, `
3410 func TestAidl(t *testing.T) {
3413 func assertString(t *testing.T, got, expected string) {
3414 t.Helper()
3416 t.Errorf("expected %q got %q", expected, got)
3420 func assertArrayString(t *testing.T, got, expected []string) {
3421 t.Helper()
3423 t.Errorf("expected %d (%q) got (%d) %q", len(expected), expected, len(got), got)
3428 t.Errorf("expected %d-th %q (%q) got %q (%q)",
3435 func assertMapKeys(t *testing.T, m map[string]string, expected []string) {
3436 t.Helper()
3437 assertArrayString(t, android.SortedStringKeys(m), expected)
3440 func TestDefaults(t *testing.T) {
3441 ctx := testCc(t, `
3486 t.Errorf("libshared ld rule wanted %q, got %q", w, g)
3490 t.Errorf("libboth ld rule wanted %q, got %q", w, g)
3494 t.Errorf("binary ld rule wanted %q, got %q", w, g)
3499 t.Errorf("libstatic ar rule wanted %q, got %q", w, g)
3503 t.Errorf("libboth ar rule wanted %q, got %q", w, g)
3507 func TestProductVariableDefaults(t *testing.T) {
3533 ).RunTestWithBp(t, bp)
3536 android.AssertStringListContains(t, "cppflags", libfoo.flags.Local.CppFlags, "-DBAR")
3539 func TestEmptyWholeStaticLibsAllowMissingDependencies(t *testing.T) {
3540 t.Parallel()
3557 ).RunTestWithBp(t, bp)
3560 android.AssertDeepEquals(t, "libbar rule", android.ErrorRule, libbar.Rule)
3562 …android.AssertStringDoesContain(t, "libbar error", libbar.Args["error"], "missing dependencies: li…
3565 …android.AssertStringListContains(t, "libfoo.a dependencies", libfoo.Inputs.Strings(), libbar.Outpu…
3568 func TestInstallSharedLibs(t *testing.T) {
3607 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
3608 ctx := testCcWithConfig(t, config)
3617 t.Errorf("expected host bin dependency %q, got %q", w, g)
3621 t.Errorf("expected host bin dependency %q, got %q", w, g)
3625 t.Errorf("expected host bin dependency %q, got %q", w, g)
3629 t.Errorf("expected host bin dependency %q, got %q", w, g)
3633 t.Errorf("expected no host bin dependency %q, got %q", w, g)
3642 t.Errorf("expected device bin dependency %q, got %q", w, g)
3646 t.Errorf("expected device bin dependency %q, got %q", w, g)
3650 t.Errorf("expected device bin dependency %q, got %q", w, g)
3654 t.Errorf("expected device bin dependency %q, got %q", w, g)
3658 t.Errorf("expected no device bin dependency %q, got %q", w, g)
3663 func TestStubsLibReexportsHeaders(t *testing.T) {
3664 ctx := testCc(t, `
3691 t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags)
3695 func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
3696 ctx := testCc(t, `
3705 manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto"))
3709 t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
3713 func TestMinSdkVersionInClangTriple(t *testing.T) {
3714 ctx := testCc(t, `
3722 android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android29")
3733 func (t MemtagNoteType) str() string {
3734 switch t {
3746 func checkHasMemtagNote(t *testing.T, m android.TestingModule, expected MemtagNoteType) {
3763 …t.Errorf("Wrong Memtag note in target %q: found %q, expected %q", m.Module().(*Module).Name(), fou…
3843 func TestSanitizeMemtagHeap(t *testing.T) {
3849 ).RunTest(t)
3852 checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync)
3853 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None)
3854 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async)
3855 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async)
3856 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync)
3858 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), None)
3859 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None)
3860 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async)
3861 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async)
3862 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync)
3864 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync)
3865 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None)
3866 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async)
3867 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async)
3868 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync)
3870 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None)
3871 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None)
3872 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async)
3873 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async)
3874 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync)
3876 checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync)
3877 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None)
3878 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async)
3879 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async)
3880 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync)
3882 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async)
3883 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None)
3884 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async)
3885 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async)
3886 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync)
3888 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync)
3889 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None)
3890 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync)
3891 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async)
3892 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync)
3894 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync)
3895 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None)
3896 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync)
3897 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async)
3898 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync)
3901 func TestSanitizeMemtagHeapWithSanitizeDevice(t *testing.T) {
3910 ).RunTest(t)
3913 checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync)
3914 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None)
3915 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Async)
3916 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async)
3917 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync)
3919 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Async)
3920 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None)
3921 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Async)
3922 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async)
3923 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync)
3925 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync)
3926 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None)
3927 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Async)
3928 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async)
3929 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync)
3931 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None)
3932 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None)
3933 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Async)
3934 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async)
3935 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync)
3937 checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync)
3938 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None)
3939 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Async)
3940 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async)
3941 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync)
3943 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Async)
3944 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None)
3945 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Async)
3946 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async)
3947 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync)
3949 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync)
3950 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None)
3951 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync)
3952 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async)
3953 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync)
3955 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync)
3956 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None)
3957 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync)
3958 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async)
3959 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync)
3962 func TestSanitizeMemtagHeapWithSanitizeDeviceDiag(t *testing.T) {
3972 ).RunTest(t)
3975 checkHasMemtagNote(t, ctx.ModuleForTests("default_test", variant), Sync)
3976 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_false", variant), None)
3977 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true", variant), Sync)
3978 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_nodiag", variant), Async)
3979 checkHasMemtagNote(t, ctx.ModuleForTests("default_test_true_diag", variant), Sync)
3981 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary", variant), Sync)
3982 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_false", variant), None)
3983 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true", variant), Sync)
3984 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_nodiag", variant), Async)
3985 checkHasMemtagNote(t, ctx.ModuleForTests("default_binary_true_diag", variant), Sync)
3987 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test", variant), Sync)
3988 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_false", variant), None)
3989 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true", variant), Sync)
3990 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_nodiag", variant), Async)
3991 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_test_true_diag", variant), Sync)
3993 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary", variant), None)
3994 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_false", variant), None)
3995 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true", variant), Sync)
3996 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_nodiag", variant), Async)
3997 checkHasMemtagNote(t, ctx.ModuleForTests("exclude_binary_true_diag", variant), Sync)
3999 checkHasMemtagNote(t, ctx.ModuleForTests("async_test", variant), Sync)
4000 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_false", variant), None)
4001 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true", variant), Sync)
4002 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_nodiag", variant), Async)
4003 checkHasMemtagNote(t, ctx.ModuleForTests("async_test_true_diag", variant), Sync)
4005 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary", variant), Sync)
4006 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_false", variant), None)
4007 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true", variant), Sync)
4008 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_nodiag", variant), Async)
4009 checkHasMemtagNote(t, ctx.ModuleForTests("async_binary_true_diag", variant), Sync)
4011 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test", variant), Sync)
4012 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_false", variant), None)
4013 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true", variant), Sync)
4014 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_nodiag", variant), Async)
4015 checkHasMemtagNote(t, ctx.ModuleForTests("sync_test_true_diag", variant), Sync)
4017 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary", variant), Sync)
4018 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_false", variant), None)
4019 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true", variant), Sync)
4020 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_nodiag", variant), Async)
4021 checkHasMemtagNote(t, ctx.ModuleForTests("sync_binary_true_diag", variant), Sync)
4024 func TestIncludeDirsExporting(t *testing.T) {
4032 checkPaths := func(t *testing.T, message string, expected string, paths android.Paths) {
4033 t.Helper()
4037 t.Errorf("%s: expected:\n%s\n actual:\n%s\n", message, expected, actual)
4041 type exportedChecker func(t *testing.T, name string, exported FlagExporterInfo)
4043 …checkIncludeDirs := func(t *testing.T, ctx *android.TestContext, module android.Module, checkers .…
4044 t.Helper()
4049 checker(t, name, exported)
4054 return func(t *testing.T, name string, exported FlagExporterInfo) {
4055 t.Helper()
4056 checkPaths(t, fmt.Sprintf("%s: include dirs", name), expectedPaths, exported.IncludeDirs)
4061 return func(t *testing.T, name string, exported FlagExporterInfo) {
4062 t.Helper()
4063 …checkPaths(t, fmt.Sprintf("%s: system include dirs", name), expectedPaths, exported.SystemIncludeD…
4068 return func(t *testing.T, name string, exported FlagExporterInfo) {
4069 t.Helper()
4070 …checkPaths(t, fmt.Sprintf("%s: generated headers", name), expectedPaths, exported.GeneratedHeaders)
4075 return func(t *testing.T, name string, exported FlagExporterInfo) {
4076 t.Helper()
4077 checkPaths(t, fmt.Sprintf("%s: order only deps", name), expectedPaths, exported.Deps)
4105 …t.Run("ensure exported include dirs are not automatically re-exported from shared_libs", func(t *t…
4106 ctx := testCc(t, genRuleModules+`
4127 checkIncludeDirs(t, ctx, foo,
4138 checkIncludeDirs(t, ctx, bar,
4149 …t.Run("ensure exported include dirs are automatically re-exported from whole_static_libs", func(t …
4150 ctx := testCc(t, genRuleModules+`
4171 checkIncludeDirs(t, ctx, foo,
4182 checkIncludeDirs(t, ctx, bar,
4204 t.Run("ensure only aidl headers are exported", func(t *testing.T) {
4205 ctx := testCc(t, genRuleModules+`
4219 checkIncludeDirs(t, ctx, foo,
4237 t.Run("ensure only proto headers are exported", func(t *testing.T) {
4238 ctx := testCc(t, genRuleModules+`
4252 checkIncludeDirs(t, ctx, foo,
4266 t.Run("ensure only sysprop headers are exported", func(t *testing.T) {
4267 ctx := testCc(t, genRuleModules+`
4279 checkIncludeDirs(t, ctx, foo,