diff options
author | 2024-05-30 00:07:40 +0000 | |
---|---|---|
committer | 2024-05-30 20:44:44 +0000 | |
commit | 15a67111f8f49cd900711ee27d4ae23e88464971 (patch) | |
tree | 0cbb00f95a440c5ba129e9def186c5f64222aef0 /java/dex_test.go | |
parent | 2f9af23734a53041e37437c9d22a664fd4db2313 (diff) |
Make dex_preopt.enable_prof_rewrite=false an error for optimized apps
If profile guided dexpreopt _and_ optimization/obfuscation is true, then
apps must use the rewritten profile created by r8/d8
Bug: 335418838
Test: m nothing --no-skip-soong-tests
Change-Id: Iac45b614f43e52ac40ad1d13df0338bcafa788c3
Diffstat (limited to 'java/dex_test.go')
-rw-r--r-- | java/dex_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/java/dex_test.go b/java/dex_test.go index eb017d5e9..4862d06c9 100644 --- a/java/dex_test.go +++ b/java/dex_test.go @@ -689,3 +689,27 @@ func TestR8FlagsArtProfile(t *testing.T) { "--create-profile-from=out/soong/.intermediates/app/android_common/profile.prof.txt --output-profile-type=app", ) } + +// This test checks that users explicitly set `enable_profile_rewriting` to true when the following are true +// 1. optimize or obfuscate is enabled AND +// 2. dex_preopt.profile_guided is enabled +// +// The rewritten profile should be used since the dex signatures in the checked-in profile will not match the optimized binary. +func TestEnableProfileRewritingIsRequiredForOptimizedApps(t *testing.T) { + testJavaError(t, + "Enable_profile_rewriting must be true when profile_guided dexpreopt and R8 optimization/obfuscation is turned on", + ` +android_app { + name: "app", + srcs: ["foo.java"], + platform_apis: true, + dex_preopt: { + profile_guided: true, + profile: "profile.txt.prof", + // enable_profile_rewriting is not set, this is an error + }, + optimize: { + optimize: true, + } +}`) +} |