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

Commit 40a3f654 authored by Paul Duffin's avatar Paul Duffin
Browse files

Improve hidden API checking in TestBootDexJarsFromSourcesAndPrebuilts

Previously, the test only checked how the intermediate index file was
created from class jars. This change also checks how the monolithic
index file was created from the intermediate index file and the index
files generated from each bootclasspath_fragment.

At the moment the checks reveal that the monolithic index file is
created solely from the intermediate index file. However, a follow up
change to Soong will alter the behavior of the test.

Bug: 194063708
Test: m nothing
Change-Id: I343712d7d17ab0a07f5b32226321fc6815847e1f
parent 2cde5f43
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -4890,7 +4890,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		}
	}

	checkHiddenAPIIndexInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInputs string) {
	checkHiddenAPIIndexFromClassesInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInputs string) {
		t.Helper()
		platformBootclasspath := ctx.ModuleForTests("platform-bootclasspath", "android_common")
		var rule android.TestingBuildParams
@@ -4899,6 +4899,15 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		java.CheckHiddenAPIRuleInputs(t, "intermediate index", expectedIntermediateInputs, rule)
	}

	checkHiddenAPIIndexFromFlagsInputs := func(t *testing.T, ctx *android.TestContext, expectedIntermediateInputs string) {
		t.Helper()
		platformBootclasspath := ctx.ModuleForTests("platform-bootclasspath", "android_common")
		var rule android.TestingBuildParams

		rule = platformBootclasspath.Output("hiddenapi-index.csv")
		java.CheckHiddenAPIRuleInputs(t, "monolithic index", expectedIntermediateInputs, rule)
	}

	fragment := java.ApexVariantReference{
		Apex:   proptools.StringPtr("myapex"),
		Module: proptools.StringPtr("my-bootclasspath-fragment"),
@@ -4946,10 +4955,13 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexInputs(t, ctx, `
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `
			out/soong/.intermediates/libbar.stubs/android_common/combined/libbar.stubs.jar
			out/soong/.intermediates/libfoo/android_common_myapex/combined/libfoo.jar
		`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)
	})

	t.Run("apex_set only", func(t *testing.T) {
@@ -4987,10 +4999,13 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexInputs(t, ctx, `
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `
			out/soong/.intermediates/libbar.stubs/android_common/combined/libbar.stubs.jar
			out/soong/.intermediates/libfoo/android_common_myapex/combined/libfoo.jar
		`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)
	})

	t.Run("prebuilt with source library preferred", func(t *testing.T) {
@@ -5108,10 +5123,13 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexInputs(t, ctx, `
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `
			out/soong/.intermediates/prebuilt_libbar.stubs/android_common/combined/libbar.stubs.jar
			out/soong/.intermediates/prebuilt_libfoo/android_common_myapex/combined/libfoo.jar
		`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)
	})

	t.Run("prebuilt with source apex preferred", func(t *testing.T) {
@@ -5182,10 +5200,13 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexInputs(t, ctx, `
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `
			out/soong/.intermediates/libbar/android_common_myapex/javac/libbar.jar
			out/soong/.intermediates/libfoo/android_common_apex10000/javac/libfoo.jar
		`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)
	})

	t.Run("prebuilt preferred with source apex disabled", func(t *testing.T) {
@@ -5258,10 +5279,13 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
		checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar")

		// Verify the correct module jars contribute to the hiddenapi index file.
		checkHiddenAPIIndexInputs(t, ctx, `
		checkHiddenAPIIndexFromClassesInputs(t, ctx, `
			out/soong/.intermediates/prebuilt_libbar.stubs/android_common/combined/libbar.stubs.jar
			out/soong/.intermediates/prebuilt_libfoo/android_common_myapex/combined/libfoo.jar
		`)
		checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
			out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
		`)
	})
}