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

Commit 1b3d4923 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Make apex/boot_image_test.go more realistic"

parents 30231da6 9ea71c0f
Loading
Loading
Loading
Loading
+96 −20
Original line number Diff line number Diff line
@@ -160,24 +160,29 @@ func checkBootImage(t *testing.T, result *android.TestResult, moduleName string,
	android.AssertTrimmedStringEquals(t, "invalid paths for "+moduleName, expectedBootImageFiles, strings.Join(allPaths, "\n"))
}

func TestBootImageInApex(t *testing.T) {
func TestBootImageInArtApex(t *testing.T) {
	result := android.GroupFixturePreparers(
		prepareForTestWithBootImage,
		prepareForTestWithMyapex,
		// Configure some libraries in the framework boot image.
		dexpreopt.FixtureSetBootJars("platform:foo", "platform:bar"),
		prepareForTestWithArtApex,

		// Configure some libraries in the art boot image.
		dexpreopt.FixtureSetArtBootJars("com.android.art:foo", "com.android.art:bar"),
	).RunTestWithBp(t, `
		apex {
			name: "myapex",
			key: "myapex.key",
			name: "com.android.art",
			key: "com.android.art.key",
			boot_images: [
				"mybootimage",
			],
			java_libs: [
				"foo",
				"bar",
			],
			updatable: false,
		}

		apex_key {
			name: "myapex.key",
			name: "com.android.art.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}
@@ -186,52 +191,123 @@ func TestBootImageInApex(t *testing.T) {
			name: "foo",
			srcs: ["b.java"],
			installable: true,
			apex_available: [
				"com.android.art",
			],
		}

		java_library {
			name: "bar",
			srcs: ["b.java"],
			installable: true,
			apex_available: [
				"com.android.art",
			],
		}

		boot_image {
			name: "mybootimage",
			image_name: "boot",
			image_name: "art",
			apex_available: [
				"myapex",
				"com.android.art",
			],
		}

		// Make sure that a preferred prebuilt doesn't affect the apex.
		prebuilt_boot_image {
			name: "mybootimage",
			image_name: "boot",
			image_name: "art",
			prefer: true,
			apex_available: [
				"myapex",
				"com.android.art",
			],
		}
	`)

	ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
	ensureExactContents(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
		"javalib/arm/boot.art",
		"javalib/arm/boot.oat",
		"javalib/arm/boot.vdex",
		"javalib/arm/boot-bar.art",
		"javalib/arm/boot-bar.oat",
		"javalib/arm/boot-bar.vdex",
		"javalib/arm/boot-foo.art",
		"javalib/arm/boot-foo.oat",
		"javalib/arm/boot-foo.vdex",
		"javalib/arm64/boot.art",
		"javalib/arm64/boot.oat",
		"javalib/arm64/boot.vdex",
		"javalib/arm64/boot-bar.art",
		"javalib/arm64/boot-bar.oat",
		"javalib/arm64/boot-bar.vdex",
		"javalib/arm64/boot-foo.art",
		"javalib/arm64/boot-foo.oat",
		"javalib/arm64/boot-foo.vdex",
		"javalib/bar.jar",
		"javalib/foo.jar",
	})

	java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
		`myapex.key`,
	java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art_image", []string{
		`bar`,
		`com.android.art.key`,
		`foo`,
		`mybootimage`,
	})
}

func TestBootImageInPrebuiltArtApex(t *testing.T) {
	result := android.GroupFixturePreparers(
		prepareForTestWithBootImage,
		prepareForTestWithArtApex,

		android.FixtureMergeMockFs(android.MockFS{
			"com.android.art-arm64.apex": nil,
			"com.android.art-arm.apex":   nil,
		}),

		// Configure some libraries in the art boot image.
		dexpreopt.FixtureSetArtBootJars("com.android.art:foo", "com.android.art:bar"),
	).RunTestWithBp(t, `
		prebuilt_apex {
			name: "com.android.art",
			arch: {
				arm64: {
					src: "com.android.art-arm64.apex",
				},
				arm: {
					src: "com.android.art-arm.apex",
				},
			},
			exported_java_libs: ["foo", "bar"],
		}

		java_import {
			name: "foo",
			jars: ["foo.jar"],
			apex_available: [
				"com.android.art",
			],
		}

		java_import {
			name: "bar",
			jars: ["bar.jar"],
			apex_available: [
				"com.android.art",
			],
		}

		prebuilt_boot_image {
			name: "mybootimage",
			image_name: "art",
			apex_available: [
				"com.android.art",
			],
		}
	`)

	java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common", []string{
		`prebuilt_bar`,
		`prebuilt_foo`,
	})

	java.CheckModuleDependencies(t, result.TestContext, "mybootimage", "android_common", []string{
		`dex2oatd`,
	})
}

// TODO(b/177892522) - add test for host apex.