2018-11-12 19:13:39 +01:00
|
|
|
// Copyright 2018 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package dexpreopt
|
|
|
|
|
|
|
|
import (
|
2019-01-31 02:32:39 +01:00
|
|
|
"android/soong/android"
|
2019-10-02 18:42:44 +02:00
|
|
|
"fmt"
|
2018-11-12 19:13:39 +01:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2020-01-31 18:44:54 +01:00
|
|
|
func testSystemModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
|
2019-10-02 18:42:44 +02:00
|
|
|
return testModuleConfig(ctx, name, "system")
|
|
|
|
}
|
|
|
|
|
2020-01-31 18:44:54 +01:00
|
|
|
func testSystemProductModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
|
2019-10-02 18:42:44 +02:00
|
|
|
return testModuleConfig(ctx, name, "system/product")
|
|
|
|
}
|
|
|
|
|
2020-01-31 18:44:54 +01:00
|
|
|
func testProductModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
|
2019-10-02 18:42:44 +02:00
|
|
|
return testModuleConfig(ctx, name, "product")
|
|
|
|
}
|
|
|
|
|
2020-01-31 18:44:54 +01:00
|
|
|
func testModuleConfig(ctx android.PathContext, name, partition string) *ModuleConfig {
|
2021-09-16 08:15:39 +02:00
|
|
|
return createTestModuleConfig(
|
|
|
|
name,
|
|
|
|
fmt.Sprintf("/%s/app/test/%s.apk", partition, name),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/%s.apk", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/dex/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func testApexModuleConfig(ctx android.PathContext, name, apexName string) *ModuleConfig {
|
|
|
|
return createTestModuleConfig(
|
|
|
|
name,
|
|
|
|
fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, name),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/dexpreopt/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/aligned/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
|
|
|
|
}
|
|
|
|
|
2021-12-14 19:54:06 +01:00
|
|
|
func testPlatformSystemServerModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
|
|
|
|
return createTestModuleConfig(
|
|
|
|
name,
|
|
|
|
fmt.Sprintf("/system/framework/%s.jar", name),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/dexpreopt/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/aligned/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
|
|
|
|
}
|
|
|
|
|
2022-05-07 08:40:13 +02:00
|
|
|
func testSystemExtSystemServerModuleConfig(ctx android.PathContext, name string) *ModuleConfig {
|
|
|
|
return createTestModuleConfig(
|
|
|
|
name,
|
|
|
|
fmt.Sprintf("/system_ext/framework/%s.jar", name),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/dexpreopt/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/aligned/%s.jar", name, name)),
|
|
|
|
android.PathForOutput(ctx, fmt.Sprintf("%s/enforce_uses_libraries.status", name)))
|
|
|
|
}
|
|
|
|
|
2021-09-16 08:15:39 +02:00
|
|
|
func createTestModuleConfig(name, dexLocation string, buildPath, dexPath, enforceUsesLibrariesStatusFile android.OutputPath) *ModuleConfig {
|
2020-01-31 18:44:54 +01:00
|
|
|
return &ModuleConfig{
|
2019-10-02 18:42:44 +02:00
|
|
|
Name: name,
|
2021-09-16 08:15:39 +02:00
|
|
|
DexLocation: dexLocation,
|
|
|
|
BuildPath: buildPath,
|
|
|
|
DexPath: dexPath,
|
2019-02-15 19:39:37 +01:00
|
|
|
UncompressedDex: false,
|
|
|
|
HasApkLibraries: false,
|
|
|
|
PreoptFlags: nil,
|
|
|
|
ProfileClassListing: android.OptionalPath{},
|
|
|
|
ProfileIsTextListing: false,
|
2021-09-16 08:15:39 +02:00
|
|
|
EnforceUsesLibrariesStatusFile: enforceUsesLibrariesStatusFile,
|
2019-02-15 19:39:37 +01:00
|
|
|
EnforceUsesLibraries: false,
|
2020-11-03 16:15:46 +01:00
|
|
|
ClassLoaderContexts: nil,
|
2019-02-15 19:39:37 +01:00
|
|
|
Archs: []android.ArchType{android.Arm},
|
2019-11-08 11:54:21 +01:00
|
|
|
DexPreoptImagesDeps: []android.OutputPaths{android.OutputPaths{}},
|
2021-05-07 11:53:21 +02:00
|
|
|
DexPreoptImageLocationsOnHost: []string{},
|
2019-02-15 19:39:37 +01:00
|
|
|
PreoptBootClassPathDexFiles: nil,
|
|
|
|
PreoptBootClassPathDexLocations: nil,
|
|
|
|
PreoptExtractedApk: false,
|
|
|
|
NoCreateAppImage: false,
|
|
|
|
ForceCreateAppImage: false,
|
|
|
|
PresignedPrebuilt: false,
|
|
|
|
}
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDexPreopt(t *testing.T) {
|
2020-01-10 21:32:59 +01:00
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
2020-11-17 02:32:30 +01:00
|
|
|
ctx := android.BuilderContextForTesting(config)
|
2021-01-21 16:05:11 +01:00
|
|
|
globalSoong := globalSoongConfigForTests()
|
2020-01-10 21:32:59 +01:00
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testSystemModuleConfig(ctx, "test")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2018-11-12 19:13:39 +01:00
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2018-11-12 19:13:39 +01:00
|
|
|
if err != nil {
|
2019-02-15 19:39:37 +01:00
|
|
|
t.Fatal(err)
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-11 23:11:09 +01:00
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
2019-02-15 19:39:37 +01:00
|
|
|
{android.PathForOutput(ctx, "test/oat/arm/package.odex"), "/system/app/test/oat/arm/test.odex"},
|
|
|
|
{android.PathForOutput(ctx, "test/oat/arm/package.vdex"), "/system/app/test/oat/arm/test.vdex"},
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:25:24 +01:00
|
|
|
if rule.Installs().String() != wantInstalls.String() {
|
2018-11-12 19:13:39 +01:00
|
|
|
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDexPreoptSystemOther(t *testing.T) {
|
2020-01-10 21:32:59 +01:00
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
2020-11-17 02:32:30 +01:00
|
|
|
ctx := android.BuilderContextForTesting(config)
|
2021-01-21 16:05:11 +01:00
|
|
|
globalSoong := globalSoongConfigForTests()
|
2019-10-02 18:42:44 +02:00
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
systemModule := testSystemModuleConfig(ctx, "Stest")
|
|
|
|
systemProductModule := testSystemProductModuleConfig(ctx, "SPtest")
|
|
|
|
productModule := testProductModuleConfig(ctx, "Ptest")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2018-11-12 19:13:39 +01:00
|
|
|
|
|
|
|
global.HasSystemOther = true
|
|
|
|
|
2019-10-02 18:42:44 +02:00
|
|
|
type moduleTest struct {
|
2020-01-31 18:44:54 +01:00
|
|
|
module *ModuleConfig
|
2019-10-02 18:42:44 +02:00
|
|
|
expectedPartition string
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
2019-10-02 18:42:44 +02:00
|
|
|
tests := []struct {
|
|
|
|
patterns []string
|
|
|
|
moduleTests []moduleTest
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
patterns: []string{"app/%"},
|
|
|
|
moduleTests: []moduleTest{
|
2019-10-03 15:18:45 +02:00
|
|
|
{module: systemModule, expectedPartition: "system_other/system"},
|
2019-10-02 18:42:44 +02:00
|
|
|
{module: systemProductModule, expectedPartition: "system/product"},
|
|
|
|
{module: productModule, expectedPartition: "product"},
|
|
|
|
},
|
|
|
|
},
|
2020-09-15 11:28:55 +02:00
|
|
|
// product/app/% only applies to product apps inside the system partition
|
2019-10-02 18:42:44 +02:00
|
|
|
{
|
|
|
|
patterns: []string{"app/%", "product/app/%"},
|
|
|
|
moduleTests: []moduleTest{
|
2019-10-03 15:18:45 +02:00
|
|
|
{module: systemModule, expectedPartition: "system_other/system"},
|
|
|
|
{module: systemProductModule, expectedPartition: "system_other/system/product"},
|
2020-09-15 11:28:55 +02:00
|
|
|
{module: productModule, expectedPartition: "product"},
|
2019-10-02 18:42:44 +02:00
|
|
|
},
|
|
|
|
},
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2019-10-02 18:42:44 +02:00
|
|
|
for _, test := range tests {
|
|
|
|
global.PatternsOnSystemOther = test.patterns
|
|
|
|
for _, mt := range test.moduleTests {
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages)
|
2019-10-02 18:42:44 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
name := mt.module.Name
|
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
|
|
|
{android.PathForOutput(ctx, name+"/oat/arm/package.odex"), fmt.Sprintf("/%s/app/test/oat/arm/%s.odex", mt.expectedPartition, name)},
|
|
|
|
{android.PathForOutput(ctx, name+"/oat/arm/package.vdex"), fmt.Sprintf("/%s/app/test/oat/arm/%s.vdex", mt.expectedPartition, name)},
|
|
|
|
}
|
|
|
|
|
|
|
|
if rule.Installs().String() != wantInstalls.String() {
|
2020-09-15 11:28:55 +02:00
|
|
|
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
2019-10-02 18:42:44 +02:00
|
|
|
}
|
|
|
|
}
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
2019-10-02 18:42:44 +02:00
|
|
|
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2021-09-16 08:15:39 +02:00
|
|
|
func TestDexPreoptApexSystemServerJars(t *testing.T) {
|
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
|
|
|
ctx := android.BuilderContextForTesting(config)
|
|
|
|
globalSoong := globalSoongConfigForTests()
|
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testApexModuleConfig(ctx, "service-A", "com.android.apex1")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2021-09-16 08:15:39 +02:00
|
|
|
|
|
|
|
global.ApexSystemServerJars = android.CreateTestConfiguredJarList(
|
|
|
|
[]string{"com.android.apex1:service-A"})
|
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2021-09-16 08:15:39 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.odex"},
|
2021-12-14 19:54:06 +01:00
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.vdex"},
|
|
|
|
}
|
|
|
|
|
|
|
|
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDexPreoptStandaloneSystemServerJars(t *testing.T) {
|
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
|
|
|
ctx := android.BuilderContextForTesting(config)
|
|
|
|
globalSoong := globalSoongConfigForTests()
|
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testPlatformSystemServerModuleConfig(ctx, "service-A")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2021-12-14 19:54:06 +01:00
|
|
|
|
|
|
|
global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(
|
|
|
|
[]string{"platform:service-A"})
|
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2021-12-14 19:54:06 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system/framework/oat/arm/service-A.odex"},
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system/framework/oat/arm/service-A.vdex"},
|
|
|
|
}
|
|
|
|
|
|
|
|
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
|
|
|
|
}
|
|
|
|
|
2022-05-07 08:40:13 +02:00
|
|
|
func TestDexPreoptSystemExtSystemServerJars(t *testing.T) {
|
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
|
|
|
ctx := android.BuilderContextForTesting(config)
|
|
|
|
globalSoong := globalSoongConfigForTests()
|
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testSystemExtSystemServerModuleConfig(ctx, "service-A")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2022-05-07 08:40:13 +02:00
|
|
|
|
|
|
|
global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(
|
|
|
|
[]string{"system_ext:service-A"})
|
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2022-05-07 08:40:13 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system_ext/framework/oat/arm/service-A.odex"},
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system_ext/framework/oat/arm/service-A.vdex"},
|
|
|
|
}
|
|
|
|
|
|
|
|
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
|
|
|
|
}
|
|
|
|
|
2021-12-14 19:54:06 +01:00
|
|
|
func TestDexPreoptApexStandaloneSystemServerJars(t *testing.T) {
|
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
|
|
|
ctx := android.BuilderContextForTesting(config)
|
|
|
|
globalSoong := globalSoongConfigForTests()
|
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testApexModuleConfig(ctx, "service-A", "com.android.apex1")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2021-12-14 19:54:06 +01:00
|
|
|
|
|
|
|
global.ApexStandaloneSystemServerJars = android.CreateTestConfiguredJarList(
|
|
|
|
[]string{"com.android.apex1:service-A"})
|
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2021-12-14 19:54:06 +01:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.odex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.odex"},
|
2021-09-16 08:15:39 +02:00
|
|
|
{android.PathForOutput(ctx, "service-A/dexpreopt/oat/arm/javalib.vdex"), "/system/framework/oat/arm/apex@com.android.apex1@javalib@service-A.jar@classes.vdex"},
|
|
|
|
}
|
|
|
|
|
|
|
|
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
|
|
|
|
}
|
|
|
|
|
2018-11-12 19:13:39 +01:00
|
|
|
func TestDexPreoptProfile(t *testing.T) {
|
2020-01-10 21:32:59 +01:00
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
2020-11-17 02:32:30 +01:00
|
|
|
ctx := android.BuilderContextForTesting(config)
|
2021-01-21 16:05:11 +01:00
|
|
|
globalSoong := globalSoongConfigForTests()
|
2020-01-10 21:32:59 +01:00
|
|
|
global := GlobalConfigForTests(ctx)
|
|
|
|
module := testSystemModuleConfig(ctx, "test")
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
productPackages := android.PathForTesting("product_packages.txt")
|
2018-11-12 19:13:39 +01:00
|
|
|
|
2019-02-15 19:39:37 +01:00
|
|
|
module.ProfileClassListing = android.OptionalPathForPath(android.PathForTesting("profile"))
|
2018-11-12 19:13:39 +01:00
|
|
|
|
Move CLC construction to Ninja phase.
Before this change, dexpreopt was often broken with optional libraries.
This was because the CLC construction was done in Soong at an early
stage, where we don't have sufficient information to determine whether
an optional library is installed or not.
For example, the "Settings" package uses an optional library called
"androidx.window.extensions". On some devices, the library is installed,
but on some other devices, it's not. Soong always adds the library to
the CLC, meaning the CLC is wrong for devices which don't have the
library. This change fixes the problem. See the tests below.
After this change, the CLC construction is done by a Python script
invoked at a very late stage. It uses product_packages.txt, which is
generated by Make, to determine whether an optional library is
installed or not, and filter out libraries that are not installed.
Note that optional libraries are still added as dependencies by Soong.
This is because dependencies have to be added at an early stage. This
means what dex2oat eventually uses will be a subset of the dependencies,
which is fine.
Bug: 282877248
Test: m
Test: atest construct_context_test
Test: -
1. lunch aosp_cf_x86_64_phone-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. See androidx.window.extensions
Test: -
1. lunch aosp_redfin-userdebug && m
2. Check the .invocation file of the "Settings" package (defined in
.bp file)
3. Don't see androidx.window.extensions
Test: Check the .invocation file of the "Dialer" package (defined in
.mk file)
Test: -
1. Build a Pixel 5 system image and flash it to a Pixel 5 device.
2. adb shell pm art dump
3. See "reason=prebuilt" instead of "reason=vdex".
(https://diff.googleplex.com/#key=fB6Ls9q2QGSN, before: left,
after: right)
Change-Id: Ia112bd7c2328373e68db6bffb74bf34030f683d8
2023-05-17 17:57:30 +02:00
|
|
|
rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
|
2018-11-12 19:13:39 +01:00
|
|
|
if err != nil {
|
2019-02-15 19:39:37 +01:00
|
|
|
t.Fatal(err)
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-11 23:11:09 +01:00
|
|
|
wantInstalls := android.RuleBuilderInstalls{
|
2019-02-15 19:39:37 +01:00
|
|
|
{android.PathForOutput(ctx, "test/profile.prof"), "/system/app/test/test.apk.prof"},
|
|
|
|
{android.PathForOutput(ctx, "test/oat/arm/package.art"), "/system/app/test/oat/arm/test.art"},
|
|
|
|
{android.PathForOutput(ctx, "test/oat/arm/package.odex"), "/system/app/test/oat/arm/test.odex"},
|
|
|
|
{android.PathForOutput(ctx, "test/oat/arm/package.vdex"), "/system/app/test/oat/arm/test.vdex"},
|
2018-11-12 19:13:39 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:25:24 +01:00
|
|
|
if rule.Installs().String() != wantInstalls.String() {
|
2018-11-12 19:13:39 +01:00
|
|
|
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
|
|
|
}
|
|
|
|
}
|
2021-04-07 17:00:19 +02:00
|
|
|
|
|
|
|
func TestDexPreoptConfigToJson(t *testing.T) {
|
|
|
|
config := android.TestConfig("out", nil, "", nil)
|
|
|
|
ctx := android.BuilderContextForTesting(config)
|
|
|
|
module := testSystemModuleConfig(ctx, "test")
|
|
|
|
data, err := moduleConfigToJSON(module)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Failed to convert module config data to JSON, %v", err)
|
|
|
|
}
|
|
|
|
parsed, err := ParseModuleConfig(ctx, data)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Failed to parse JSON, %v", err)
|
|
|
|
}
|
|
|
|
before := fmt.Sprintf("%v", module)
|
|
|
|
after := fmt.Sprintf("%v", parsed)
|
|
|
|
android.AssertStringEquals(t, "The result must be the same as the original after marshalling and unmarshalling it.", before, after)
|
|
|
|
}
|