Test bootImageConfig/Variant fields
Most of the fields in the bootImageConfig/Variant structs are assigned inside a Once func so are guaranteed to be only set once. However, some are assigned outside. This change adds comprehensive tests for those structs and verifies that the constant fields are preserved and the mutated fields have the correct value. The check for the constant fields is added in a new TestBootImageConfig test. The check for the mutated fields is added into TestSnapshotWithBootclasspathFragment_ImageName as that test checks an art bootclasspath_fragment in the following configurations: * source on its own * prebuilt on its own * source and prebuilt with source preferred * source and prebuilt with prebuilt It reveals a couple of interesting facts: * All the *installs fields are set to the same value irrespective of whether the source or prebuilt is preferred. The information is constructed solely from information already within the bootImageConfig/Variant and so can be moved within Once. * The licenseMetadataFile is incorrect when prebuilt is preferred. That is due to both the source and prebuilt modules setting it and the source module always wins as the source module depends on the prebuilt so always runs its GenerateAndroidBuildActions after it. Those issues will be cleaned up in following changes. Bug: 245956352 Test: m nothing Change-Id: If917cfbcb3b1c842a8682d51cc1ee1fed1c51add
This commit is contained in:
@@ -17,6 +17,7 @@ package sdk
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -80,7 +81,7 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
|
||||
// Add a platform_bootclasspath that depends on the fragment.
|
||||
fixtureAddPlatformBootclasspathForBootclasspathFragment("com.android.art", "mybootclasspathfragment"),
|
||||
|
||||
java.FixtureConfigureBootJars("com.android.art:mybootlib"),
|
||||
java.PrepareForBootImageConfigTest,
|
||||
android.FixtureWithRootAndroidBp(`
|
||||
sdk {
|
||||
name: "mysdk",
|
||||
@@ -99,7 +100,7 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
|
||||
bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
image_name: "art",
|
||||
contents: ["mybootlib"],
|
||||
contents: ["core1", "core2"],
|
||||
apex_available: ["com.android.art"],
|
||||
hidden_api: {
|
||||
split_packages: ["*"],
|
||||
@@ -113,19 +114,32 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "mybootlib",
|
||||
name: "core1",
|
||||
srcs: ["Test.java"],
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
compile_dex: true,
|
||||
apex_available: ["com.android.art"],
|
||||
}
|
||||
`),
|
||||
|
||||
java_library {
|
||||
name: "core2",
|
||||
srcs: ["Test.java"],
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
compile_dex: true,
|
||||
apex_available: ["com.android.art"],
|
||||
}
|
||||
`),
|
||||
).RunTest(t)
|
||||
|
||||
// A preparer to update the test fixture used when processing an unpackage snapshot.
|
||||
preparerForSnapshot := fixtureAddPrebuiltApexForBootclasspathFragment("com.android.art", "mybootclasspathfragment")
|
||||
|
||||
// Check that source on its own configures the bootImageConfig correctly.
|
||||
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
|
||||
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
||||
|
||||
CheckSnapshot(t, result, "mysdk", "",
|
||||
checkAndroidBpContents(`
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
@@ -136,7 +150,10 @@ prebuilt_bootclasspath_fragment {
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["com.android.art"],
|
||||
image_name: "art",
|
||||
contents: ["mybootlib"],
|
||||
contents: [
|
||||
"core1",
|
||||
"core2",
|
||||
],
|
||||
hidden_api: {
|
||||
annotation_flags: "hiddenapi/annotation-flags.csv",
|
||||
metadata: "hiddenapi/metadata.csv",
|
||||
@@ -148,11 +165,19 @@ prebuilt_bootclasspath_fragment {
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "mybootlib",
|
||||
name: "core1",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["com.android.art"],
|
||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar"],
|
||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/core1.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "core2",
|
||||
prefer: false,
|
||||
visibility: ["//visibility:public"],
|
||||
apex_available: ["com.android.art"],
|
||||
jars: ["java_boot_libs/snapshot/jars/are/invalid/core2.jar"],
|
||||
}
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
@@ -162,31 +187,55 @@ java_import {
|
||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/signature-patterns.csv -> hiddenapi/signature-patterns.csv
|
||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-stub-flags.csv -> hiddenapi/filtered-stub-flags.csv
|
||||
.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/filtered-flags.csv -> hiddenapi/filtered-flags.csv
|
||||
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/mybootlib.jar
|
||||
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core1.jar
|
||||
.intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/core2.jar
|
||||
`),
|
||||
snapshotTestPreparer(checkSnapshotWithoutSource, preparerForSnapshot),
|
||||
|
||||
// Check the behavior of the snapshot without the source.
|
||||
snapshotTestChecker(checkSnapshotWithoutSource, func(t *testing.T, result *android.TestResult) {
|
||||
// Make sure that the boot jars package check rule includes the dex jar retrieved from the prebuilt apex.
|
||||
checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/mybootlib.jar")
|
||||
// Make sure that the boot jars package check rule includes the dex jars retrieved from the prebuilt apex.
|
||||
checkBootJarsPackageCheckRule(t, result,
|
||||
"out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core1.jar",
|
||||
"out/soong/.intermediates/prebuilts/apex/com.android.art.deapexer/android_common/deapexer/javalib/core2.jar",
|
||||
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar")
|
||||
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/snapshot/mybootclasspathfragment/android_common_com.android.art/meta_lic")
|
||||
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
||||
}),
|
||||
|
||||
snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot),
|
||||
|
||||
// Check the behavior of the snapshot when the source is preferred.
|
||||
snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) {
|
||||
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
|
||||
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
||||
}),
|
||||
|
||||
snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),
|
||||
|
||||
// Check the behavior of the snapshot when it is preferred.
|
||||
snapshotTestChecker(checkSnapshotPreferredWithSource, func(t *testing.T, result *android.TestResult) {
|
||||
// TODO - the expectedLicenseMetadataFile passed here is incorrect as it is for the source module not the prebuilt module.
|
||||
java.CheckMutatedArtBootImageConfig(t, result, "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/meta_lic")
|
||||
java.CheckMutatedFrameworkBootImageConfig(t, result, "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic")
|
||||
}),
|
||||
)
|
||||
|
||||
// Make sure that the boot jars package check rule includes the dex jar created from the source.
|
||||
checkBootJarsPackageCheckRule(t, result, "out/soong/.intermediates/mybootlib/android_common_apex10000/aligned/mybootlib.jar")
|
||||
// Make sure that the boot jars package check rule includes the dex jars created from the source.
|
||||
checkBootJarsPackageCheckRule(t, result,
|
||||
"out/soong/.intermediates/core1/android_common_apex10000/aligned/core1.jar",
|
||||
"out/soong/.intermediates/core2/android_common_apex10000/aligned/core2.jar",
|
||||
"out/soong/.intermediates/default/java/framework/android_common/aligned/framework.jar")
|
||||
}
|
||||
|
||||
// checkBootJarsPackageCheckRule checks that the supplied module is an input to the boot jars
|
||||
// package check rule.
|
||||
func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModule string) {
|
||||
func checkBootJarsPackageCheckRule(t *testing.T, result *android.TestResult, expectedModules ...string) {
|
||||
t.Helper()
|
||||
platformBcp := result.ModuleForTests("platform-bootclasspath", "android_common")
|
||||
bootJarsCheckRule := platformBcp.Rule("boot_jars_package_check")
|
||||
command := bootJarsCheckRule.RuleParams.Command
|
||||
expectedCommandArgs := " out/soong/host/linux-x86/bin/dexdump build/soong/scripts/check_boot_jars/package_allowed_list.txt " + expectedModule + " &&"
|
||||
expectedCommandArgs := " build/soong/scripts/check_boot_jars/package_allowed_list.txt " + strings.Join(expectedModules, " ") + " &&"
|
||||
android.AssertStringDoesContain(t, "boot jars package check", command, expectedCommandArgs)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user