Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39f65b16 authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Automerger Merge Worker
Browse files

Merge "Add more tests for dexpreopting." am: 40eb3b3e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1840057

Change-Id: I43ca5e97e606a269068e07cf0cca2c6bd0d082c8
parents 91368f3a 40eb3b3e
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -8289,6 +8289,75 @@ func TestProhibitStaticExecutable(t *testing.T) {
	`)
}

func TestAndroidMk_DexpreoptBuiltInstalledForApex(t *testing.T) {
	ctx := testApex(t, `
		apex {
			name: "myapex",
			key: "myapex.key",
			updatable: false,
			java_libs: ["foo"],
		}

		apex_key {
			name: "myapex.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}

		java_library {
			name: "foo",
			srcs: ["foo.java"],
			apex_available: ["myapex"],
			installable: true,
		}
	`,
		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
	)

	apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
	data := android.AndroidMkDataForTest(t, ctx, apexBundle)
	var builder strings.Builder
	data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
	androidMk := builder.String()
	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex")
}

func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) {
	ctx := testApex(t, `
		prebuilt_apex {
			name: "myapex",
			arch: {
				arm64: {
					src: "myapex-arm64.apex",
				},
				arm: {
					src: "myapex-arm.apex",
				},
			},
			exported_java_libs: ["foo"],
		}

		java_import {
			name: "foo",
			jars: ["foo.jar"],
			installable: true,
		}
	`,
		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
	)

	prebuilt := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*Prebuilt)
	entriesList := android.AndroidMkEntriesForTest(t, ctx, prebuilt)
	mainModuleEntries := entriesList[0]
	android.AssertArrayString(t,
		"LOCAL_REQUIRED_MODULES",
		mainModuleEntries.EntryMap["LOCAL_REQUIRED_MODULES"],
		[]string{
			"foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex",
			"foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex",
		})
}

func TestMain(m *testing.M) {
	os.Exit(m.Run())
}