Fix tests to use correct fixtures for configuring (Apex)BootJars.
This is in preparation to r.android.com/1740313 where setting correct
variables would be enforced (i.e. apex and non-apex boot jars must be in
config.ApexBootJars and config.BootJars correspondingly).
Bug: 191369843
Test: m nothing
Change-Id: Ic86680c1f7af53d229083b2cc58beb3ceccb4b6a
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 41bfcea..f07bf63 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4663,6 +4663,7 @@
prebuilt_bootclasspath_fragment {
name: "art-bootclasspath-fragment",
+ image_name: "art",
contents: ["core-oj"],
hidden_api: {
annotation_flags: "my-bootclasspath-fragment/annotation-flags.csv",
@@ -4871,7 +4872,7 @@
func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
preparer := android.GroupFixturePreparers(
- java.FixtureConfigureBootJars("myapex:libfoo", "myapex:libbar"),
+ java.FixtureConfigureApexBootJars("myapex:libfoo", "myapex:libbar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
@@ -4949,6 +4950,7 @@
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ permitted_packages: ["foo"],
}
java_sdk_library_import {
@@ -4958,6 +4960,7 @@
},
apex_available: ["myapex"],
shared_library: false,
+ permitted_packages: ["bar"],
}
`
@@ -4998,6 +5001,7 @@
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ permitted_packages: ["foo"],
}
java_sdk_library_import {
@@ -5007,6 +5011,7 @@
},
apex_available: ["myapex"],
shared_library: false,
+ permitted_packages: ["bar"],
}
`
@@ -5120,6 +5125,7 @@
prefer: true,
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ permitted_packages: ["foo"],
}
java_library {
@@ -5136,6 +5142,7 @@
},
apex_available: ["myapex"],
shared_library: false,
+ permitted_packages: ["bar"],
}
java_sdk_library {
@@ -5209,6 +5216,7 @@
name: "libfoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: ["myapex"],
+ permitted_packages: ["foo"],
}
java_sdk_library_import {
@@ -5225,6 +5233,7 @@
srcs: ["foo/bar/MyClass.java"],
unsafe_ignore_missing_latest_api: true,
apex_available: ["myapex"],
+ permitted_packages: ["bar"],
}
`
@@ -5286,6 +5295,7 @@
prefer: true,
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ permitted_packages: ["foo"],
}
java_library {
@@ -5302,6 +5312,7 @@
},
apex_available: ["myapex"],
shared_library: false,
+ permitted_packages: ["bar"],
}
java_sdk_library {
@@ -6899,6 +6910,7 @@
apex_available: [
"some-updatable-apex",
],
+ permitted_packages: ["some.updatable.apex.lib"],
}
java_library {
@@ -6908,6 +6920,7 @@
"some-non-updatable-apex",
],
compile_dex: true,
+ permitted_packages: ["some.non.updatable.apex.lib"],
}
bootclasspath_fragment {
@@ -7118,7 +7131,9 @@
"myapex",
],
}
- `)
+ `,
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
+ )
}
func TestNoUpdatableJarsInBootImage(t *testing.T) {
@@ -7148,18 +7163,30 @@
}
t.Run("updatable jar from ART apex in the ART boot image => ok", func(t *testing.T) {
- preparer := java.FixtureConfigureBootJars("com.android.art.debug:some-art-lib")
- fragment := java.ApexVariantReference{
- Apex: proptools.StringPtr("com.android.art.debug"),
- Module: proptools.StringPtr("art-bootclasspath-fragment"),
+ preparer := android.GroupFixturePreparers(
+ java.FixtureConfigureBootJars("com.android.art.debug:some-art-lib"),
+ java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
+ )
+ fragments := []java.ApexVariantReference{
+ {
+ Apex: proptools.StringPtr("com.android.art.debug"),
+ Module: proptools.StringPtr("art-bootclasspath-fragment"),
+ },
+ {
+ Apex: proptools.StringPtr("some-non-updatable-apex"),
+ Module: proptools.StringPtr("some-non-updatable-fragment"),
+ },
}
- testNoUpdatableJarsInBootImage(t, "", preparer, fragment)
+ testNoUpdatableJarsInBootImage(t, "", preparer, fragments...)
})
t.Run("updatable jar from ART apex in the framework boot image => error", func(t *testing.T) {
err := `module "some-art-lib" from updatable apexes \["com.android.art.debug"\] is not allowed in the framework boot image`
// Update the dexpreopt BootJars directly.
- preparer := prepareSetBootJars("com.android.art.debug:some-art-lib")
+ preparer := android.GroupFixturePreparers(
+ prepareSetBootJars("com.android.art.debug:some-art-lib"),
+ java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
+ )
testNoUpdatableJarsInBootImage(t, err, preparer)
})
@@ -7179,12 +7206,15 @@
t.Run("updatable jar from some other apex in the framework boot image => error", func(t *testing.T) {
err := `module "some-updatable-apex-lib" from updatable apexes \["some-updatable-apex"\] is not allowed in the framework boot image`
- preparer := java.FixtureConfigureBootJars("some-updatable-apex:some-updatable-apex-lib")
+ preparer := android.GroupFixturePreparers(
+ java.FixtureConfigureBootJars("some-updatable-apex:some-updatable-apex-lib"),
+ java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
+ )
testNoUpdatableJarsInBootImage(t, err, preparer)
})
t.Run("non-updatable jar from some other apex in the framework boot image => ok", func(t *testing.T) {
- preparer := java.FixtureConfigureBootJars("some-non-updatable-apex:some-non-updatable-apex-lib")
+ preparer := java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib")
fragment := java.ApexVariantReference{
Apex: proptools.StringPtr("some-non-updatable-apex"),
Module: proptools.StringPtr("some-non-updatable-fragment"),
@@ -7212,13 +7242,22 @@
})
t.Run("platform jar in the framework boot image => ok", func(t *testing.T) {
- preparer := java.FixtureConfigureBootJars("platform:some-platform-lib")
- testNoUpdatableJarsInBootImage(t, "", preparer)
+ preparer := android.GroupFixturePreparers(
+ java.FixtureConfigureBootJars("platform:some-platform-lib"),
+ java.FixtureConfigureApexBootJars("some-non-updatable-apex:some-non-updatable-apex-lib"),
+ )
+ fragments := []java.ApexVariantReference{
+ {
+ Apex: proptools.StringPtr("some-non-updatable-apex"),
+ Module: proptools.StringPtr("some-non-updatable-fragment"),
+ },
+ }
+ testNoUpdatableJarsInBootImage(t, "", preparer, fragments...)
})
}
func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) {
- preparer := java.FixtureConfigureBootJars("myapex:libfoo")
+ preparer := java.FixtureConfigureApexBootJars("myapex:libfoo")
t.Run("prebuilt no source", func(t *testing.T) {
fragment := java.ApexVariantReference{
Apex: proptools.StringPtr("myapex"),
@@ -7256,6 +7295,7 @@
name: "libfoo",
jars: ["libfoo.jar"],
apex_available: ["myapex"],
+ permitted_packages: ["libfoo"],
}
`, "", preparer, fragment)
})
@@ -8168,6 +8208,8 @@
java.PrepareForTestWithJavaDefaultModules,
android.PrepareForTestWithAndroidBuildComponents,
android.FixtureWithRootAndroidBp(bp),
+ dexpreopt.FixtureSetApexBootJars("myapex:mybootclasspathlib"),
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:mysystemserverclasspathlib"),
android.FixtureMergeEnv(map[string]string{
"EMMA_INSTRUMENT": "true",
}),
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 6098989..3e19014 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -130,7 +130,8 @@
result := android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
// Configure some libraries in the art bootclasspath_fragment and platform_bootclasspath.
- java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo", "platform:bar"),
+ java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
+ java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"),
prepareForTestWithArtApex,
java.PrepareForTestWithJavaSdkLibraryFiles,
@@ -642,7 +643,7 @@
prepareForTestWithBootclasspathFragment,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
- java.FixtureConfigureBootJars("myapex:foo", "myapex:bar"),
+ java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
@@ -893,7 +894,8 @@
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
- java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "myapex:foo", "myapex:bar"),
+ java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
+ java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
@@ -1062,7 +1064,8 @@
prepareForTestWithArtApex,
prepareForTestWithMyapex,
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
- java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "myapex:foo", "myapex:bar"),
+ java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
+ java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
diff --git a/apex/classpath_element_test.go b/apex/classpath_element_test.go
index 0193127..e2d8465 100644
--- a/apex/classpath_element_test.go
+++ b/apex/classpath_element_test.go
@@ -58,6 +58,7 @@
}),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "othersdklibrary"),
+ java.FixtureConfigureApexBootJars("myapex:bar"),
android.FixtureWithRootAndroidBp(`
apex {
name: "com.android.art",
@@ -79,6 +80,7 @@
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
+ image_name: "art",
apex_available: [
"com.android.art",
],
@@ -193,6 +195,10 @@
apex: "com.android.art",
module: "art-bootclasspath-fragment",
},
+ {
+ apex: "myapex",
+ module: "mybootclasspath-fragment",
+ },
],
}
`),
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index eaee20d..d1897ae 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -39,7 +39,7 @@
prepareForTestWithMyapex,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo"),
- java.FixtureConfigureBootJars("myapex:bar"),
+ java.FixtureConfigureApexBootJars("myapex:bar"),
android.FixtureWithRootAndroidBp(`
platform_bootclasspath {
name: "platform-bootclasspath",
@@ -194,6 +194,7 @@
bootclasspath_fragment {
name: "art-bootclasspath-fragment",
+ image_name: "art",
apex_available: [
"com.android.art",
],
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index 537f51d..a64c6f4 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -15,6 +15,7 @@
package apex
import (
+ "android/soong/dexpreopt"
"testing"
"android/soong/android"
@@ -30,6 +31,7 @@
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverclasspathFragment,
prepareForTestWithMyapex,
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
).RunTestWithBp(t, `
apex {
name: "myapex",
@@ -81,6 +83,7 @@
result := android.GroupFixturePreparers(
prepareForTestWithSystemserverclasspathFragment,
prepareForTestWithMyapex,
+ dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
).RunTestWithBp(t, `
apex {
name: "myapex",