• Home
  • Raw
  • Download

Lines Matching refs:t

51 func testApexError(t *testing.T, pattern, bp string, preparers ...android.FixturePreparer) {
52 t.Helper()
58 RunTestWithBp(t, bp)
61 func testApex(t *testing.T, bp string, preparers ...android.FixturePreparer) *android.TestContext {
62 t.Helper()
73 ).RunTest(t)
228 func ensureEquals(t *testing.T, result string, expected string) {
229 t.Helper()
231 t.Errorf("%q != %q", expected, result)
236 func ensureContains(t *testing.T, result string, expected string) {
237 t.Helper()
239 t.Errorf("%q is not found in %q", expected, result)
244 func ensureContainsOnce(t *testing.T, result string, expected string) {
245 t.Helper()
248 t.Errorf("%q is found %d times (expected 1 time) in %q", expected, count, result)
253 func ensureNotContains(t *testing.T, result string, notExpected string) {
254 t.Helper()
256 t.Errorf("%q is found in %q", notExpected, result)
260 func ensureMatches(t *testing.T, result string, expectedRex string) {
263t.Fatalf("regexp failure trying to match %s against `%s` expression: %s", result, expectedRex, err)
267 t.Errorf("%s does not match regular expession %s", result, expectedRex)
271 func ensureListContains(t *testing.T, result []string, expected string) {
272 t.Helper()
274 t.Errorf("%q is not found in %v", expected, result)
278 func ensureListNotContains(t *testing.T, result []string, notExpected string) {
279 t.Helper()
281 t.Errorf("%q is found in %v", notExpected, result)
285 func ensureListEmpty(t *testing.T, result []string) {
286 t.Helper()
288 t.Errorf("%q is expected to be empty", result)
292 func ensureListNotEmpty(t *testing.T, result []string) {
293 t.Helper()
295 t.Errorf("%q is expected to be not empty", result)
300 func TestBasicApex(t *testing.T) {
301 ctx := testApex(t, `
520 data := android.AndroidMkDataForTest(t, ctx, ab)
525 ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
526 ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
529 ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey")
531 …ensureContains(t, optFlags, "--assets_dir out/soong/.intermediates/myapex/android_common_myapex_im…
536 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
539 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_apex10000…
540 ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common_apex10000")
541 ensureListContains(t, ctx.ModuleVariantsForTests("myjar_dex"), "android_common_apex10000")
542 ensureListContains(t, ctx.ModuleVariantsForTests("foo.rust"), "android_arm64_armv8-a_apex10000")
543 …ensureListContains(t, ctx.ModuleVariantsForTests("libfoo.ffi"), "android_arm64_armv8-a_shared_apex…
546 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_apex1000…
547 ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common_apex10000")
548 …ensureListContains(t, ctx.ModuleVariantsForTests("libfoo.rlib.rust"), "android_arm64_armv8-a_rlib_…
549 …ensureListContains(t, ctx.ModuleVariantsForTests("libfoo.dylib.rust"), "android_arm64_armv8-a_dyli…
550 …ensureListContains(t, ctx.ModuleVariantsForTests("libbar.ffi"), "android_arm64_armv8-a_shared_apex…
551 …ensureListContains(t, ctx.ModuleVariantsForTests("libfoo.shared_from_rust"), "android_arm64_armv8-…
554 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
555 ensureContains(t, copyCmds, "image.apex/lib64/mylib2.so")
556 ensureContains(t, copyCmds, "image.apex/javalib/myjar_stem.jar")
557 ensureContains(t, copyCmds, "image.apex/javalib/myjar_dex.jar")
558 ensureContains(t, copyCmds, "image.apex/lib64/libfoo.dylib.rust.dylib.so")
559 ensureContains(t, copyCmds, "image.apex/lib64/libfoo.ffi.so")
560 ensureContains(t, copyCmds, "image.apex/lib64/libbar.ffi.so")
561 ensureContains(t, copyCmds, "image.apex/lib64/libfoo.shared_from_rust.so")
563 ensureNotContains(t, copyCmds, "image.apex/javalib/myotherjar.jar")
564 ensureNotContains(t, copyCmds, "image.apex/javalib/msharedjar.jar")
567 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared")
568 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared")
569 ensureListContains(t, ctx.ModuleVariantsForTests("myjar"), "android_common")
570 ensureListContains(t, ctx.ModuleVariantsForTests("myotherjar"), "android_common")
571 ensureListContains(t, ctx.ModuleVariantsForTests("mysharedjar"), "android_common")
574 ensureListNotContains(t, ctx.ModuleVariantsForTests("mysharedjar"), "android_common_myapex")
590t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_f…
596 t.Errorf("number of input notice files: expected = 3, actual = %q", len(noticeInputs))
598 ensureListContains(t, noticeInputs, "NOTICE")
599 ensureListContains(t, noticeInputs, "custom_notice")
600 ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")
603 ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex")
604 ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib")
605 ensureListContains(t, fullDepsInfo, " myotherjar(minSdkVersion:(no version)) <- myjar")
606 …ensureListContains(t, fullDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external) <- myjar…
609 ensureListContains(t, flatDepsInfo, "myjar(minSdkVersion:(no version))")
610 ensureListContains(t, flatDepsInfo, "mylib2(minSdkVersion:(no version))")
611 ensureListContains(t, flatDepsInfo, "myotherjar(minSdkVersion:(no version))")
612 ensureListContains(t, flatDepsInfo, "mysharedjar(minSdkVersion:(no version)) (external)")
615 func TestDefaults(t *testing.T) {
616 ctx := testApex(t, `
679 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
690 func TestApexManifest(t *testing.T) {
691 ctx := testApex(t, `
708 t.Error("manifest should be apex_manifest.pb, but " + manifest)
712 func TestBasicZipApex(t *testing.T) {
713 ctx := testApex(t, `
750 ensureContains(t, zipApexRule.Output.String(), "myapex.zipapex.unsigned")
753 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_apex10000…
756 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_apex1000…
759 ensureContains(t, copyCmds, "image.zipapex/lib64/mylib.so")
760 ensureContains(t, copyCmds, "image.zipapex/lib64/mylib2.so")
763 func TestApexWithStubs(t *testing.T) {
764 ctx := testApex(t, `
823 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
826 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
829 ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so")
834 ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so")
836 ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
839 ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_apex10000/mylib3.so")
841 ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12/mylib3.so")
845 ensureNotContains(t, mylib2Cflags, "-include ")
848 …ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_shared_3").Rule("g…
850 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
857 func TestApexWithStubsWithMinSdkVersion(t *testing.T) {
858 t.Parallel()
859 ctx := testApex(t, `
922 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
925 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
928 ensureContains(t, copyCmds, "image.apex/lib64/mylib3.so")
933 ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so")
935 ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
938 ensureContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_apex29/mylib3.so")
940 ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_29/mylib3.so")
944 ensureNotContains(t, mylib2Cflags, "-include ")
947 …ensureContains(t, "--apex", ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_shared_29").Rule("…
949 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
956 func TestApex_PlatformUsesLatestStubFromApex(t *testing.T) {
957 t.Parallel()
966 ctx := testApex(t, `
1021 ensureContains(t, mylibCflags, "-D__LIBSTUB_API__=10000 ")
1023 ensureContains(t, mylibLdflags, "libstub/android_arm64_armv8-a_shared_current/libstub.so ")
1027 ensureContains(t, libplatformCflags, "-D__LIBSTUB_API__=10000 ") // "current" maps to 10000
1029 ensureContains(t, libplatformLdflags, "libstub/android_arm64_armv8-a_shared_current/libstub.so ")
1032 func TestApexWithExplicitStubsDependency(t *testing.T) {
1033 ctx := testApex(t, `
1089 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
1092 ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so")
1095 ensureNotContains(t, copyCmds, "image.apex/lib64/libbar.so")
1100 ensureContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_shared_10/libfoo.so")
1102 ensureNotContains(t, mylibLdFlags, "libfoo/android_arm64_armv8-a_shared/libfoo.so")
1107 ensureNotContains(t, libFooStubsLdFlags, "libbar.so")
1110 ensureListContains(t, fullDepsInfo, " libfoo(minSdkVersion:(no version)) (external) <- mylib")
1113 ensureListContains(t, flatDepsInfo, "libfoo(minSdkVersion:(no version)) (external)")
1116 func TestApexWithRuntimeLibsDependency(t *testing.T) {
1125 ctx := testApex(t, `
1172 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
1175 ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.so")
1178 ensureContains(t, copyCmds, "image.apex/lib64/libbar.so")
1181 ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
1182 ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libfoo.so")
1206 func TestRuntimeApexShouldInstallHwasanIfLibcDependsOnIt(t *testing.T) {
1207 result := android.GroupFixturePreparers(prepareForTestOfRuntimeApexWithHwasan).RunTestWithBp(t, `
1237 …ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_imag…
1245 …ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-a…
1248 …ensureEquals(t, symlink.Args["fromPath"], "/apex/com.android.runtime/lib64/bionic/libclang_rt.hwas…
1249 ensureContains(t, symlink.Output.String(), "/system/lib64/libclang_rt.hwasan-aarch64-android.so")
1252 func TestRuntimeApexShouldInstallHwasanIfHwaddressSanitized(t *testing.T) {
1258 ).RunTestWithBp(t, `
1285 …ensureExactContents(t, ctx, "com.android.runtime", "android_common_hwasan_com.android.runtime_imag…
1293 …ensureContains(t, installed.Output.String(), "/system/lib64/bootstrap/libclang_rt.hwasan-aarch64-a…
1296 …ensureEquals(t, symlink.Args["fromPath"], "/apex/com.android.runtime/lib64/bionic/libclang_rt.hwas…
1297 ensureContains(t, symlink.Output.String(), "/system/lib64/libclang_rt.hwasan-aarch64-android.so")
1300 func TestApexDependsOnLLNDKTransitively(t *testing.T) {
1324 t.Run(tc.name, func(t *testing.T) {
1325 ctx := testApex(t, `
1366 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
1372 ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
1373 ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")
1376 … ensureContains(t, mylibLdFlags, "libbar/android_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
1378 ensureNotContains(t, mylibLdFlags, "libbar/android_arm64_armv8-a_shared_"+ver+"/libbar.so")
1386 ensureContains(t, mylibCFlags, "__LIBBAR_API__="+ver)
1391 func TestApexWithSystemLibsStubs(t *testing.T) {
1392 ctx := testApex(t, `
1435 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
1436 ensureContains(t, copyCmds, "image.apex/lib64/bionic/libm.so")
1437 ensureContains(t, copyCmds, "image.apex/lib64/bionic/libdl.so")
1440 ensureNotContains(t, copyCmds, "image.apex/lib64/bionic/libc.so")
1448 ensureContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared_current/libc.so")
1450 ensureNotContains(t, mylibLdFlags, "libc/android_arm64_armv8-a_shared/libc.so")
1452 ensureContains(t, mylibCFlags, "__LIBC_API__=10000")
1453 ensureContains(t, mylibSharedCFlags, "__LIBC_API__=10000")
1457 ensureContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_shared_apex10000/libm.so")
1459 ensureNotContains(t, mylibLdFlags, "libm/android_arm64_armv8-a_shared_29/libm.so")
1461 ensureNotContains(t, mylibCFlags, "__LIBM_API__=29")
1462 ensureNotContains(t, mylibSharedCFlags, "__LIBM_API__=29")
1466 ensureContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_27/libdl.so")
1468 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_28/libdl.so")
1469 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_29/libdl.so")
1471 ensureNotContains(t, mylibLdFlags, "libdl/android_arm64_armv8-a_shared_apex10000/libdl.so")
1473 ensureContains(t, mylibCFlags, "__LIBDL_API__=27")
1474 ensureContains(t, mylibSharedCFlags, "__LIBDL_API__=27")
1478 ensureContains(t, libFlags, "libc/android_arm64_armv8-a_shared/libc.so")
1479 ensureContains(t, libFlags, "libm/android_arm64_armv8-a_shared/libm.so")
1480 ensureContains(t, libFlags, "libdl/android_arm64_armv8-a_shared/libdl.so")
1483 func TestApexMinSdkVersion_NativeModulesShouldBeBuiltAgainstStubs(t *testing.T) {
1488 ctx := testApex(t, `
1551 ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1555 ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1571 func TestApexMinSdkVersion_SupportsCodeNames(t *testing.T) {
1572 ctx := testApex(t, `
1611 ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1615 ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1623 func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) {
1624 ctx := testApex(t, `
1658 ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1662 ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1670 func TestPlatformUsesLatestStubsFromApexes(t *testing.T) {
1671 ctx := testApex(t, `
1704 t.Helper()
1706 ensureContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1709 t.Helper()
1711 ensureNotContains(t, ldArgs, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1725 func TestQApexesUseLatestStubsInBundledBuildsAndHWASAN(t *testing.T) {
1726 ctx := testApex(t, `
1759 ensureContains(t, libFlags, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
1764 func TestQTargetApexUsesStaticUnwinder(t *testing.T) {
1765 ctx := testApex(t, `
1788 ensureListContains(t, cm.Properties.AndroidMkStaticLibs, "libunwind")
1791 ensureListNotContains(t, cm.Properties.AndroidMkStaticLibs, "libunwind")
1794 func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
1795 testApexError(t, `module "mylib".*: should support min_sdk_version\(29\)`, `
1821 testApexError(t, `module "libfoo.ffi".*: should support min_sdk_version\(29\)`, `
1846 testApexError(t, `module "libfoo".*: should support min_sdk_version\(29\)`, `
1871 func TestApexMinSdkVersion_Okay(t *testing.T) {
1872 testApex(t, `
1931 func TestJavaStableSdkVersion(t *testing.T) {
2042 t.Run(test.name, func(t *testing.T) {
2044 testApex(t, test.bp)
2046 testApexError(t, test.expectedError, test.bp)
2052 func TestApexMinSdkVersion_ErrorIfDepIsNewer(t *testing.T) {
2053 testApexError(t, `module "mylib2".*: should support min_sdk_version\(29\) for "myapex"`, `
2093 func TestApexMinSdkVersion_ErrorIfDepIsNewer_Java(t *testing.T) {
2094 testApexError(t, `module "bar".*: should support min_sdk_version\(29\) for "myapex"`, `
2128 func TestApexMinSdkVersion_OkayEvenWhenDepIsNewer_IfItSatisfiesApexMinSdkVersion(t *testing.T) {
2129 ctx := testApex(t, `
2175 ensureContains(t, libFlags, "android_arm64_armv8-a_"+to_variant+"/"+to+".so")
2181 func TestApexMinSdkVersion_WorksWithSdkCodename(t *testing.T) {
2188 testApexError(t, `libbar.*: should support min_sdk_version\(S\)`, `
2213 func TestApexMinSdkVersion_WorksWithActiveCodenames(t *testing.T) {
2218 ctx := testApex(t, `
2248 ensureContains(t, libFlags, "android_arm64_armv8-a_shared_current/libbar.so")
2251 func TestFilesInSubDir(t *testing.T) {
2252 ctx := testApex(t, `
2299 ensureListContains(t, dirs, "etc")
2300 ensureListContains(t, dirs, "etc/foo")
2301 ensureListContains(t, dirs, "etc/foo/bar")
2302 ensureListContains(t, dirs, "lib64")
2303 ensureListContains(t, dirs, "lib64/foo")
2304 ensureListContains(t, dirs, "lib64/foo/bar")
2305 ensureListContains(t, dirs, "lib")
2306 ensureListContains(t, dirs, "lib/foo")
2307 ensureListContains(t, dirs, "lib/foo/bar")
2309 ensureListContains(t, dirs, "bin")
2310 ensureListContains(t, dirs, "bin/foo")
2311 ensureListContains(t, dirs, "bin/foo/bar")
2314 func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) {
2315 ctx := testApex(t, `
2361 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
2373 func TestVendorApex(t *testing.T) {
2374 ctx := testApex(t, `
2398 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
2406 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
2413 ensureContains(t, androidMk, "LOCAL_MODULE_PATH := "+installPath)
2417 ensureListNotContains(t, requireNativeLibs, ":vndk")
2420 func TestVendorApex_use_vndk_as_stable(t *testing.T) {
2421 ctx := testApex(t, `
2459 ensureListContains(t, libs, "out/soong/.intermediates/libvndk/"+vendorVariant+"_shared/libvndk.so")
2460 …ensureListContains(t, libs, "out/soong/.intermediates/"+cc.DefaultCcCommonTestModulesDir+"libc++/"…
2462 …ensureListContains(t, libs, "out/soong/.intermediates/libvendor/"+vendorVariant+"_shared_apex10000…
2465 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
2472 ensureListContains(t, requireNativeLibs, ":vndk")
2475 func TestProductVariant(t *testing.T) {
2476 ctx := testApex(t, `
2504 ensureListContains(t, cflags, "-D__ANDROID_VNDK__")
2505 ensureListContains(t, cflags, "-D__ANDROID_APEX__")
2506 ensureListContains(t, cflags, "-D__ANDROID_PRODUCT__")
2507 ensureListNotContains(t, cflags, "-D__ANDROID_VENDOR__")
2510 func TestApex_withPrebuiltFirmware(t *testing.T) {
2519 t.Run(tc.name, func(t *testing.T) {
2520 ctx := testApex(t, `
2540 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
2547 func TestAndroidMk_VendorApexRequired(t *testing.T) {
2548 ctx := testApex(t, `
2570 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
2576 ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += libc.vendor libm.vendor libdl.vendor\n")
2579 func TestAndroidMkWritesCommonProperties(t *testing.T) {
2580 ctx := testApex(t, `
2599 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
2605 ensureContains(t, androidMk, "LOCAL_FULL_VINTF_FRAGMENTS := fragment.xml\n")
2606 ensureContains(t, androidMk, "LOCAL_FULL_INIT_RC := init.rc\n")
2609 func TestStaticLinking(t *testing.T) {
2610 ctx := testApex(t, `
2651 ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_static/mylib.a")
2654 func TestKeys(t *testing.T) {
2655 ctx := testApex(t, `
2695 t.Errorf("public key %q is not %q", keys.publicKeyFile.String(),
2699 t.Errorf("private key %q is not %q", keys.privateKeyFile.String(),
2706 t.Errorf("cert and private key %q are not %q", certs,
2711 func TestCertificate(t *testing.T) {
2712 t.Run("if unspecified, it defaults to DefaultAppCertificate", func(t *testing.T) {
2713 ctx := testApex(t, `
2727 t.Errorf("certificates should be %q, not %q", expected, actual)
2730 t.Run("override when unspecified", func(t *testing.T) {
2731 ctx := testApex(t, `
2750 t.Errorf("certificates should be %q, not %q", expected, actual)
2753 t.Run("if specified as :module, it respects the prop", func(t *testing.T) {
2754 ctx := testApex(t, `
2773 t.Errorf("certificates should be %q, not %q", expected, actual)
2776 t.Run("override when specifiec as <:module>", func(t *testing.T) {
2777 ctx := testApex(t, `
2797 t.Errorf("certificates should be %q, not %q", expected, actual)
2800 t.Run("if specified as name, finds it from DefaultDevKeyDir", func(t *testing.T) {
2801 ctx := testApex(t, `
2816 t.Errorf("certificates should be %q, not %q", expected, actual)
2819 t.Run("override when specified as <name>", func(t *testing.T) {
2820 ctx := testApex(t, `
2840 t.Errorf("certificates should be %q, not %q", expected, actual)
2845 func TestMacro(t *testing.T) {
2846 ctx := testApex(t, `
2909 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2910 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
2914 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2915 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=10000")
2916 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
2920 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2921 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__=29")
2922 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
2929 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2933 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2934 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
2935 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
2939 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2940 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
2941 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
2945 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2946 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
2953 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2957 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2958 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
2959 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
2963 ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2964 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MYAPEX__")
2965 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_OTHERAPEX__")
2969 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__")
2970 ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX_MIN_SDK_VERSION__")
2973 func TestHeaderLibsDependency(t *testing.T) {
2974 ctx := testApex(t, `
3021 ensureContains(t, cFlags, "-Imy_include")
3030 func getFiles(t *testing.T, ctx *android.TestContext, moduleName, variant string) []fileInApex {
3031 t.Helper()
3048 t.Fatal("copyCmds contains invalid cp command", cmd)
3056 t.Fatal("copyCmds contains invalid ln command", cmd)
3062 t.Fatalf("copyCmds should contain mkdir/cp commands only: %q", cmd)
3067 t.Fatal("copyCmds should copy a file to image.apex/", cmd)
3076 func ensureExactContents(t *testing.T, ctx *android.TestContext, moduleName, variant string, files …
3077 t.Helper()
3081 for _, file := range getFiles(t, ctx, moduleName, variant) {
3097 t.Log("surplus files", surplus)
3109 t.Log("missing files", missing)
3113 t.Fail()
3117 func TestVndkApexCurrent(t *testing.T) {
3118 ctx := testApex(t, `
3159 ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
3174 func TestVndkApexWithPrebuilt(t *testing.T) {
3175 ctx := testApex(t, `
3224 ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
3258 func TestVndkApexVersion(t *testing.T) {
3259 ctx := testApex(t, `
3320 ensureExactContents(t, ctx, "com.android.vndk.v27", "android_common_image", []string{
3327 func TestVndkApexNameRule(t *testing.T) {
3328 ctx := testApex(t, `
3352 t.Errorf("Got '%v', expected '%v'", actual, expected)
3360 func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) {
3361 ctx := testApex(t, `
3392 ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
3401 func TestVndkApexDoesntSupportNativeBridgeSupported(t *testing.T) {
3402 …testApexError(t, `module "com.android.vndk.current" .*: native_bridge_supported: .* doesn't suppor…
3432 func TestVndkApexWithBinder32(t *testing.T) {
3433 ctx := testApex(t, `
3495 ensureExactContents(t, ctx, "com.android.vndk.v27", "android_common_image", []string{
3501 func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) {
3502 ctx := testApex(t, `
3534 ensureListEmpty(t, provideNativeLibs)
3537 func TestDependenciesInApexManifest(t *testing.T) {
3538 ctx := testApex(t, `
3623 ensureListEmpty(t, provideNativeLibs)
3624 ensureListEmpty(t, requireNativeLibs)
3629 ensureListEmpty(t, provideNativeLibs)
3630 ensureListContains(t, requireNativeLibs, "libfoo.so")
3635 ensureListContains(t, provideNativeLibs, "libfoo.so")
3636 ensureListEmpty(t, requireNativeLibs)
3641 ensureListContains(t, provideNativeLibs, "libfoo.so")
3642 ensureListEmpty(t, requireNativeLibs)
3645 func TestApexName(t *testing.T) {
3646 ctx := testApex(t, `
3675 ensureContains(t, apexManifestRule.Args["opt"], "-v name com.android.myapex")
3677 ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname")
3680 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
3686 ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
3687 ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
3690 func TestNonTestApex(t *testing.T) {
3691 ctx := testApex(t, `
3722 t.Log("Apex was a test apex!")
3723 t.Fail()
3726 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
3729 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared_ap…
3732 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
3735 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared")
3738 t.Log("Found mylib_common not in any apex!")
3739 t.Fail()
3743 func TestTestApex(t *testing.T) {
3744 ctx := testApex(t, `
3776 t.Log("Apex was not a test apex!")
3777 t.Fail()
3780 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
3783 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_shar…
3786 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common_test.so")
3789 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common_test"), "android_arm64_armv8-a_shar…
3792 func TestApexWithTarget(t *testing.T) {
3793 ctx := testApex(t, `
3865 ensureContains(t, apexRule.Output.String(), "myapex.apex.unsigned")
3868 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared_apex10000…
3869 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared_ap…
3870 …ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared_apex1…
3873 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
3874 ensureContains(t, copyCmds, "image.apex/lib64/mylib_common.so")
3875 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
3878 ensureListContains(t, ctx.ModuleVariantsForTests("mylib"), "android_arm64_armv8-a_shared")
3879 ensureListContains(t, ctx.ModuleVariantsForTests("mylib_common"), "android_arm64_armv8-a_shared")
3880 ensureListContains(t, ctx.ModuleVariantsForTests("mylib2"), "android_arm64_armv8-a_shared")
3883 func TestApexWithArch(t *testing.T) {
3884 ctx := testApex(t, `
3934 …ensureListContains(t, ctx.ModuleVariantsForTests("mylib.arm64"), "android_arm64_armv8-a_shared_ape…
3935 …ensureListNotContains(t, ctx.ModuleVariantsForTests("mylib.x64"), "android_arm64_armv8-a_shared_ap…
3938 ensureContains(t, copyCmds, "image.apex/lib64/mylib.arm64.so")
3939 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib.x64.so")
3942 func TestApexWithShBinary(t *testing.T) {
3943 ctx := testApex(t, `
3968 ensureContains(t, copyCmds, "image.apex/bin/script/myscript.sh")
3971 func TestApexInVariousPartition(t *testing.T) {
3983 t.Run(tc.propName+":"+tc.parition, func(t *testing.T) {
3984 ctx := testApex(t, `
4003 t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
4010 t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
4016 func TestFileContexts_FindInDefaultLocationIfNotSet(t *testing.T) {
4017 ctx := testApex(t, `
4032 ensureContains(t, rule.RuleParams.Command, "cat system/sepolicy/apex/myapex-file_contexts")
4035 func TestFileContexts_ShouldBeUnderSystemSepolicyForSystemApexes(t *testing.T) {
4036 testApexError(t, `"myapex" .*: file_contexts: should be under system/sepolicy`, `
4054 func TestFileContexts_ProductSpecificApexes(t *testing.T) {
4055 testApexError(t, `"myapex" .*: file_contexts: cannot find`, `
4071 ctx := testApex(t, `
4090 ensureContains(t, rule.RuleParams.Command, "cat product_specific_file_contexts")
4093 func TestFileContexts_SetViaFileGroup(t *testing.T) {
4094 ctx := testApex(t, `
4118 ensureContains(t, rule.RuleParams.Command, "cat product_specific_file_contexts")
4121 func TestApexKeyFromOtherModule(t *testing.T) {
4122 ctx := testApex(t, `
4145 t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey)
4150 t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey)
4154 func TestPrebuilt(t *testing.T) {
4155 ctx := testApex(t, `
4173t.Errorf("inputApex invalid. expected: %q, actual: %q", expectedInput, prebuilt.inputApex.String())
4177 func TestPrebuiltMissingSrc(t *testing.T) {
4178 …testApexError(t, `module "myapex" variant "android_common_myapex".*: prebuilt_apex does not suppor…
4185 func TestPrebuiltFilenameOverride(t *testing.T) {
4186 ctx := testApex(t, `
4198 t.Errorf("installFilename invalid. expected: %q, actual: %q", expected, p.installFilename)
4202 func TestPrebuiltOverrides(t *testing.T) {
4203 ctx := testApex(t, `
4216 actual := android.AndroidMkEntriesForTest(t, ctx, p)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
4218 t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES value '%s', expected '%s'", actual, expected)
4222 func TestPrebuiltApexName(t *testing.T) {
4223 testApex(t, `
4231 testApex(t, `
4240 func TestPrebuiltApexNameWithPlatformBootclasspath(t *testing.T) {
4272 ).RunTest(t)
4277 func TestPrebuiltExportDexImplementationJars(t *testing.T) {
4280 checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
4286 t.Errorf("Incorrect DexJarBuildPath value '%s', expected '%s'", actual, expected)
4290 ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext, name string) {
4293 t.Errorf("invalid set of variants for %q: expected %q, found %q", "libfoo", expected, actual)
4297 t.Run("prebuilt only", func(t *testing.T) {
4326 ctx := testDexpreoptWithApexes(t, bp, "", transform)
4332 t.Errorf("expected: %q, found: %q", expected, actual)
4339 t.Errorf("expected: %q, found: %q", expected, actual)
4342 checkDexJarBuildPath(t, ctx, "libfoo")
4344 checkDexJarBuildPath(t, ctx, "libbar")
4347 t.Run("prebuilt with source preferred", func(t *testing.T) {
4387 ctx := testDexpreoptWithApexes(t, bp, "", transform)
4389 checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
4390 ensureNoSourceVariant(t, ctx, "libfoo")
4392 checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
4393 ensureNoSourceVariant(t, ctx, "libbar")
4396 t.Run("prebuilt preferred with source", func(t *testing.T) {
4437 ctx := testDexpreoptWithApexes(t, bp, "", transform)
4439 checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
4440 ensureNoSourceVariant(t, ctx, "libfoo")
4442 checkDexJarBuildPath(t, ctx, "prebuilt_libbar")
4443 ensureNoSourceVariant(t, ctx, "libbar")
4447 func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
4455 …checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath st…
4456 t.Helper()
4464 android.AssertStringEquals(t, "boot dex jar path", bootDexJarPath, buildRule.Input.String())
4468t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRe…
4472 …checkHiddenAPIIndexInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInpu…
4473 t.Helper()
4478 java.CheckHiddenAPIRuleInputs(t, "intermediate index", expectedIntermediateInputs, rule)
4486 t.Run("prebuilt only", func(t *testing.T) {
4523 ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
4524 …checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4525 …checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4528 checkHiddenAPIIndexInputs(t, ctx, `
4534 t.Run("apex_set only", func(t *testing.T) {
4564 ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
4565 …checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4566 …checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4569 checkHiddenAPIIndexInputs(t, ctx, `
4575 t.Run("prebuilt with source library preferred", func(t *testing.T) {
4630 …testDexpreoptWithApexes(t, bp, "module libfoo does not provide a dex boot jar", preparer, fragment)
4633 t.Run("prebuilt library preferred with source", func(t *testing.T) {
4685 ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
4686 …checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4687 …checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4690 checkHiddenAPIIndexInputs(t, ctx, `
4696 t.Run("prebuilt with source apex preferred", func(t *testing.T) {
4759 ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
4760 …checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/libfoo/android_common_apex10000/hi…
4761 …checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/libbar/android_common_myapex/hidde…
4764 checkHiddenAPIIndexInputs(t, ctx, `
4770 t.Run("prebuilt preferred with source apex disabled", func(t *testing.T) {
4835 ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
4836 …checkBootDexJarPath(t, ctx, "libfoo", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4837 …checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/dea…
4840 checkHiddenAPIIndexInputs(t, ctx, `
4847 func TestApexWithTests(t *testing.T) {
4848 ctx := testApex(t, `
4923 ensureContains(t, copyCmds, "image.apex/bin/test/mytest")
4924 ensureContains(t, copyCmds, "image.apex/lib64/mylib.so")
4927 ensureContains(t, copyCmds, "image.apex/bin/test/baz")
4928 ensureContains(t, copyCmds, "image.apex/bin/test/bar/baz")
4931 ensureContains(t, copyCmds, "image.apex/bin/test/mytest1")
4932 ensureContains(t, copyCmds, "image.apex/bin/test/mytest2")
4933 ensureContains(t, copyCmds, "image.apex/bin/test/mytest3")
4937 data := android.AndroidMkDataForTest(t, ctx, bundle)
4943 ensureContains(t, androidMk, "LOCAL_MODULE := mytest.myapex\n")
4944 ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
4945 ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
4946 ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
4947 ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex\n")
4948 ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
4949 ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
4952 data = android.AndroidMkDataForTest(t, ctx, flatBundle)
4955 ensureContainsOnce(t, flatAndroidMk, "LOCAL_TEST_DATA := :baz :bar/baz\n")
4956 ensureContainsOnce(t, flatAndroidMk, "LOCAL_TEST_DATA := :testdata/baz\n")
4959 func TestInstallExtraFlattenedApexes(t *testing.T) {
4960 ctx := testApex(t, `
4977 ensureListContains(t, ab.requiredDeps, "myapex.flattened")
4978 mk := android.AndroidMkDataForTest(t, ctx, ab)
4982 ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += myapex.flattened")
4985 func TestErrorsIfDepsAreNotEnabled(t *testing.T) {
4986 testApexError(t, `module "myapex" .* depends on disabled module "libfoo"`, `
5007 testApexError(t, `module "myapex" .* depends on disabled module "myjar"`, `
5031 func TestApexWithJavaImport(t *testing.T) {
5032 ctx := testApex(t, `
5057 ensureContains(t, copyCmds, "image.apex/javalib/myjavaimport.jar")
5060 func TestApexWithApps(t *testing.T) {
5061 ctx := testApex(t, `
5121 ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
5122 ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk")
5127 t.Errorf("jni libs are not uncompressed for AppFoo")
5133 ensureListContains(t, appZipRule.Implicits.Strings(), jniOutput.String())
5135 ensureNotContains(t, copyCmds, "image.apex/lib64/"+jni+".so")
5139 func TestApexWithAppImports(t *testing.T) {
5140 ctx := testApex(t, `
5184 ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt/AppFooPrebuilt.apk")
5185 ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt/AwesomePrebuiltAppFooPriv.apk")
5188 func TestApexWithAppImportsPrefer(t *testing.T) {
5189 ctx := testApex(t, `
5225 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
5230 func TestApexWithTestHelperApp(t *testing.T) {
5231 ctx := testApex(t, `
5259 ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo/TesterHelpAppFoo.apk")
5262 func TestApexPropertiesShouldBeDefaultable(t *testing.T) {
5264 testApexError(t, `requires "libfoo" that doesn't list the APEX under 'apex_available'.`, `
5298 func TestApexAvailable_DirectDep(t *testing.T) {
5300 testApexError(t, "requires \"libfoo\" that doesn't list the APEX under 'apex_available'.", `
5335 func TestApexAvailable_IndirectDep(t *testing.T) {
5337 …testApexError(t, `requires "libbaz" that doesn't list the APEX under 'apex_available'.\n\nDependen…
5380 func TestApexAvailable_InvalidApexName(t *testing.T) {
5381 testApexError(t, "\"otherapex\" is not a valid module name", `
5402 testApex(t, `
5441 func TestApexAvailable_CheckForPlatform(t *testing.T) {
5442 ctx := testApex(t, `
5493 t.Errorf("%q shouldn't be available to platform", libfoo.String())
5500 t.Errorf("%q should be available to platform", libfoo2.String())
5504 func TestApexAvailable_CreatedForApex(t *testing.T) {
5505 ctx := testApex(t, `
5531 t.Errorf("%q shouldn't be available to platform", libfooShared.String())
5535 t.Errorf("%q should be available to platform", libfooStatic.String())
5539 func TestOverrideApex(t *testing.T) {
5540 ctx := testApex(t, `
5596 t.Errorf("GetOverriddenBy should be empty, but was %q", originalVariant.GetOverriddenBy())
5599t.Errorf("GetOverriddenBy should be \"override_myapex\", but was %q", overriddenVariant.GetOverrid…
5606 ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
5607 ensureContains(t, copyCmds, "image.apex/app/override_app/override_app.apk")
5612 t.Errorf("name should be \"override_myapex\", but was %q", name)
5616t.Errorf("override_myapex should have logging parent (com.foo.bar), but was %q.", apexBundle.overr…
5620 ensureContains(t, optFlags, "--override_apk_package_name test.overridden.package")
5621 ensureContains(t, optFlags, "--pubkey testkey2.avbpubkey")
5624 ensureEquals(t, signApkRule.Args["certificates"], "testkey.x509.pem testkey.pk8")
5626 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
5630 ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
5631 ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
5632 ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex")
5633 ensureContains(t, androidMk, "LOCAL_OVERRIDES_MODULES := unknownapex myapex")
5634 ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex")
5635 ensureNotContains(t, androidMk, "LOCAL_MODULE := override_app.myapex")
5636 ensureNotContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex")
5637 ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex")
5640 func TestLegacyAndroid10Support(t *testing.T) {
5641 ctx := testApex(t, `
5667 …ensureContains(t, args["opt_flags"], "--manifest_json "+module.Output("apex_manifest.json").Output…
5668 ensureNotContains(t, args["opt_flags"], "--no_hashtree")
5678 t.Errorf("%q missing unwinder dep", lib)
5700 func TestJavaSDKLibrary(t *testing.T) {
5701 ctx := testApex(t, `
5729 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
5735 …ensureContains(t, sdkLibrary.RuleParams.Command, `<library name=\"foo\" file=\"/apex/myapex/javali…
5919 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
5928 t.Errorf("expected %q, found %#q", expected, actual)
5932 func TestJavaSDKLibrary_ImportOnly(t *testing.T) {
5933 testApexError(t, `java_libs: "foo" is not configured to be compiled into dex`, `
5959 func TestCompatConfig(t *testing.T) {
5963 ).RunTestWithBp(t, `
5999 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
6005 func TestRejectNonInstallableJavaLibrary(t *testing.T) {
6006 testApexError(t, `"myjar" is not configured to be compiled into dex`, `
6031 func TestCarryRequiredModuleNames(t *testing.T) {
6032 ctx := testApex(t, `
6059 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
6065 ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += a b\n")
6066 ensureContains(t, androidMk, "LOCAL_HOST_REQUIRED_MODULES += c d\n")
6067 ensureContains(t, androidMk, "LOCAL_TARGET_REQUIRED_MODULES += e f\n")
6070 func TestSymlinksFromApexToSystem(t *testing.T) {
6150 ensureRealfileExists := func(t *testing.T, files []fileInApex, file string) {
6154 t.Errorf("%q is not a real file", file)
6159 t.Errorf("%q is not found", file)
6162 ensureSymlinkExists := func(t *testing.T, files []fileInApex, file string) {
6166 t.Errorf("%q is not a symlink", file)
6171 t.Errorf("%q is not found", file)
6176 ctx := testApex(t, bp, withUnbundledBuild)
6177 files := getFiles(t, ctx, "myapex", "android_common_myapex_image")
6178 ensureRealfileExists(t, files, "javalib/myjar.jar")
6179 ensureRealfileExists(t, files, "lib64/mylib.so")
6180 ensureRealfileExists(t, files, "lib64/myotherlib.so")
6182 files = getFiles(t, ctx, "myapex.updatable", "android_common_myapex.updatable_image")
6183 ensureRealfileExists(t, files, "javalib/myjar.jar")
6184 ensureRealfileExists(t, files, "lib64/mylib.so")
6185 ensureRealfileExists(t, files, "lib64/myotherlib.so")
6188 ctx = testApex(t, bp)
6189 files = getFiles(t, ctx, "myapex", "android_common_myapex_image")
6190 ensureRealfileExists(t, files, "javalib/myjar.jar")
6191 ensureRealfileExists(t, files, "lib64/mylib.so")
6192 ensureSymlinkExists(t, files, "lib64/myotherlib.so") // this is symlink
6194 files = getFiles(t, ctx, "myapex.updatable", "android_common_myapex.updatable_image")
6195 ensureRealfileExists(t, files, "javalib/myjar.jar")
6196 ensureRealfileExists(t, files, "lib64/mylib.so")
6197 ensureRealfileExists(t, files, "lib64/myotherlib.so") // this is a real file
6200 func TestSymlinksFromApexToSystemRequiredModuleNames(t *testing.T) {
6201 ctx := testApex(t, `
6240 data := android.AndroidMkDataForTest(t, ctx, apexBundle)
6245 ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
6246 ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n")
6247 ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n")
6249 …ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex:64 myotherlib:64 apex_manifes…
6252 func TestApexWithJniLibs(t *testing.T) {
6253 ctx := testApex(t, `
6287 ensureEquals(t, rule.Args["opt"], "-a jniLibs mylib.so")
6288 ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
6294 func TestApexMutatorsDontRunIfDisabled(t *testing.T) {
6295 ctx := testApex(t, `
6314 t.Errorf("Expected variants: %v, but got: %v", expected, got)
6318 func TestAppBundle(t *testing.T) {
6319 ctx := testApex(t, `
6345 …ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.…
6346 …ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.androi…
6349 func TestAppSetBundle(t *testing.T) {
6350 ctx := testApex(t, `
6371 …ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.…
6375 t.Fatalf("Expected 3 commands, got %d in:\n%s", len(copyCmds), s)
6377 ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet$")
6378 ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet$")
6379 ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet .*/AppSet.zip$")
6382 func TestAppSetBundlePrebuilt(t *testing.T) {
6393 ctx := testApex(t, bp, prepareForTestWithSantitizeHwaddress)
6401 …android.AssertArrayString(t, "extractor input", []string{"myapex.hwasan.apks"}, extractedApex.Inpu…
6407 android.AssertStringEquals(t, "myapex input", extractorOutput, copiedApex.Input.String())
6410 func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer android.FixturePreparer, …
6411 t.Helper()
6517 testDexpreoptWithApexes(t, bp, errmsg, preparer, fragments...)
6520 func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, preparer android.FixturePreparer, fra…
6521 t.Helper()
6566 RunTestWithBp(t, bp)
6571 func TestDuplicateDeapexeresFromPrebuiltApexes(t *testing.T) {
6600 t.Run("java_import", func(t *testing.T) {
6601 _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
6610 t.Run("java_sdk_library_import", func(t *testing.T) {
6611 _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `contents: ["libfoo"]`)+`
6622 t.Run("prebuilt_bootclasspath_fragment", func(t *testing.T) {
6623 _ = preparers.RunTestWithBp(t, fmt.Sprintf(bpBase, `
6638 func TestUpdatable_should_set_min_sdk_version(t *testing.T) {
6639 testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
6654 func TestUpdatableDefault_should_set_min_sdk_version(t *testing.T) {
6655 testApexError(t, `"myapex" .*: updatable: updatable APEXes should set min_sdk_version`, `
6669 func TestNoUpdatableJarsInBootImage(t *testing.T) {
6695 t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
6701 testNoUpdatableJarsInBootImage(t, "", preparer, fragment)
6704 t.Run("updatable jar from ART apex in the framework boot image => error", func(t *testing.T) {
6708 testNoUpdatableJarsInBootImage(t, err, preparer)
6711 t.Run("updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
6715 testNoUpdatableJarsInBootImage(t, err, preparer)
6718 t.Run("non-updatable jar from some other apex in the ART boot image => error", func(t *testing.T) {
6722 testNoUpdatableJarsInBootImage(t, err, preparer)
6725t.Run("updatable jar from some other apex in the framework boot image => error", func(t *testing.T…
6728 testNoUpdatableJarsInBootImage(t, err, preparer)
6731t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.…
6737 testNoUpdatableJarsInBootImage(t, "", preparer, fragment)
6740 t.Run("nonexistent jar in the ART boot image => error", func(t *testing.T) {
6743 testNoUpdatableJarsInBootImage(t, err, preparer)
6746 t.Run("nonexistent jar in the framework boot image => error", func(t *testing.T) {
6749 testNoUpdatableJarsInBootImage(t, err, preparer)
6752 t.Run("platform jar in the ART boot image => error", func(t *testing.T) {
6756 testNoUpdatableJarsInBootImage(t, err, preparer)
6759 t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
6761 testNoUpdatableJarsInBootImage(t, "", preparer)
6765 func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
6767 t.Run("prebuilt no source", func(t *testing.T) {
6773 testDexpreoptWithApexes(t, `
6802 func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJars []string, rules […
6803 t.Helper()
6836 RunTestWithBp(t, bp)
6839 func TestApexPermittedPackagesRules(t *testing.T) {
6917 t.Run(tc.name, func(t *testing.T) {
6919 testApexPermittedPackagesRules(t, tc.expectedError, tc.bp, tc.bootJars, rules)
6924 func TestTestFor(t *testing.T) {
6925 ctx := testApex(t, `
6991 …android.AssertArrayString(t, "unexpected "+linkedLib+" link library for "+mod, []string{linkedLib …
7001 func TestIndirectTestFor(t *testing.T) {
7002 ctx := testApex(t, `
7049 …android.AssertArrayString(t, "unexpected "+linkedLib+" link library for "+mod, []string{linkedLib …
7061 func TestTestForForLibInOtherApex(t *testing.T) {
7063 _ = testApex(t, `
7116 func TestApexSet(t *testing.T) {
7117 ctx := testApex(t, `
7143 t.Errorf("Unexpected abis parameter - expected %q vs actual %q", expected, actual)
7148 t.Errorf("Unexpected abis parameter - expected %q vs actual %q", expected, actual)
7154 …actualOverrides := android.AndroidMkEntriesForTest(t, ctx, a)[0].EntryMap["LOCAL_OVERRIDES_MODULES…
7156t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES - expected %q vs actual %q", expectedOverrides, actual…
7160 func TestNoStaticLinkingToStubsLib(t *testing.T) {
7161 testApexError(t, `.*required by "mylib" is a native library providing stub.*`, `
7197 func TestApexKeysTxt(t *testing.T) {
7198 ctx := testApex(t, `
7234 …ensureContains(t, content, `name="myapex_set.apex" public_key="PRESIGNED" private_key="PRESIGNED" …
7235 …ensureContains(t, content, `name="myapex.apex" public_key="PRESIGNED" private_key="PRESIGNED" cont…
7238 func TestAllowedFiles(t *testing.T) {
7239 ctx := testApex(t, `
7285 t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
7290 t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
7294 func TestNonPreferredPrebuiltDependency(t *testing.T) {
7295 testApex(t, `
7330 func TestCompressedApex(t *testing.T) {
7331 ctx := testApex(t, `
7350 ensureContains(t, compressRule.Output.String(), "myapex.capex.unsigned")
7353 ensureEquals(t, signApkRule.Input.String(), compressRule.Output.String())
7357 ensureContains(t, ab.outputFile.String(), "myapex.capex")
7360 data := android.AndroidMkDataForTest(t, ctx, ab)
7364 ensureContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.capex\n")
7367 func TestPreferredPrebuiltSharedLibDep(t *testing.T) {
7368 ctx := testApex(t, `
7409 data := android.AndroidMkDataForTest(t, ctx, ab)
7416 ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherlib\n")
7419 func TestExcludeDependency(t *testing.T) {
7420 ctx := testApex(t, `
7458 ensureContains(t, ldFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
7462 ensureNotContains(t, ldFlags, "mylib2/android_arm64_armv8-a_shared_apex10000/mylib2.so")
7466 ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so")
7469 func TestPrebuiltStubLibDep(t *testing.T) {
7561 t.Run(test.name, func(t *testing.T) {
7563 t.Run("otherapex_enabled_"+otherApexEnabled, func(t *testing.T) {
7564 ctx := testApex(t, fmt.Sprintf(bpBase, otherApexEnabled)+test.stublibBp)
7582 for _, ent := range android.AndroidMkEntriesForTest(t, ctx, mod) {
7598 t.Errorf("More than one AndroidMk entry for \"stublib\": %s and %s", entry.mod, ent.mod)
7606 t.Errorf("AndroidMk entry for \"stublib\" missing")
7610t.Errorf("Wrong module for \"stublib\" AndroidMk entry: got prebuilt %t, want prebuilt %t", isPreb…
7613 t.Errorf("Module for \"stublib\" AndroidMk entry isn't a stub: %s", entry.mod)
7616t.Errorf("AndroidMk entry for \"stublib\" has LOCAL_NOT_AVAILABLE_FOR_PLATFORM set: %+v", entry.mk…
7621 t.Errorf("LOCAL_EXPORT_CFLAGS expected to have %q, but got %q", expected, cflags)
7630 func TestApexJavaCoverage(t *testing.T) {
7690 ).RunTest(t)
7694 t.Errorf("Failed to find jacoco rule for mylib")
7697 t.Errorf("Failed to find jacoco rule for mybootclasspathlib")
7700 t.Errorf("Failed to find jacoco rule for mysystemserverclasspathlib")