From 7d3c9e0b5f54bd6f61a973e1360262949a035c87 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Mon, 13 Dec 2021 17:19:05 +0000 Subject: [PATCH] Test that `DisableGenerateProfile` takes effects for APEXes. Bug: 209630530 Test: m nothing Change-Id: I5953f36e219ba63f8a01fa5dc60456db35eef5ac --- apex/bootclasspath_fragment_test.go | 19 +++++++++++++++++++ dexpreopt/testing.go | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index 7ecf9b20f..ce828e1af 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -16,6 +16,7 @@ package apex import ( "fmt" + "path" "sort" "strings" "testing" @@ -442,6 +443,24 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) { checkCopiesToPredefinedLocationForArt(t, result.Config, module, "bar", "foo") }) + t.Run("boot image disable generate profile", func(t *testing.T) { + result := android.GroupFixturePreparers( + commonPreparer, + + // Configure some libraries in the art bootclasspath_fragment that match the source + // bootclasspath_fragment's contents property. + java.FixtureConfigureBootJars("com.android.art:foo", "com.android.art:bar"), + addSource("foo", "bar"), + dexpreopt.FixtureDisableGenerateProfile(true), + ).RunTest(t) + + files := getFiles(t, result.TestContext, "com.android.art", "android_common_com.android.art_image") + for _, file := range files { + matched, _ := path.Match("etc/boot-image.prof", file.path) + android.AssertBoolEquals(t, "\"etc/boot-image.prof\" should not be in the APEX", matched, false) + } + }) + t.Run("boot image files with preferred prebuilt", func(t *testing.T) { result := android.GroupFixturePreparers( commonPreparer, diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go index 5131cd3f4..47ae494e3 100644 --- a/dexpreopt/testing.go +++ b/dexpreopt/testing.go @@ -167,3 +167,10 @@ func FixtureSetBootImageProfiles(profiles ...string) android.FixturePreparer { dexpreoptConfig.BootImageProfiles = android.PathsForSource(ctx, profiles) }) } + +// FixtureDisableGenerateProfile sets the DisableGenerateProfile property in the global config. +func FixtureDisableGenerateProfile(disable bool) android.FixturePreparer { + return FixtureModifyGlobalConfig(func(_ android.PathContext, dexpreoptConfig *GlobalConfig) { + dexpreoptConfig.DisableGenerateProfile = disable + }) +}