Suffix the build ID to the dirname of APK-in-APEX files. am: 11cca671ac

Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/17508450

Change-Id: If1ddcbebf2f746fd345a29ba966bf5ac8c02c41f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jingwen Chen
2022-04-05 19:44:58 +00:00
committed by Automerger Merge Worker
2 changed files with 72 additions and 16 deletions

View File

@@ -219,6 +219,7 @@ var prepareForApexTest = android.GroupFixturePreparers(
// not because of these tests specifically (it's not used by the tests)
variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"}
variables.Platform_vndk_version = proptools.StringPtr("29")
variables.BuildId = proptools.StringPtr("TEST.BUILD_ID")
}),
)
@@ -678,7 +679,7 @@ func TestDefaults(t *testing.T) {
"etc/myetc",
"javalib/myjar.jar",
"lib64/mylib.so",
"app/AppFoo/AppFoo.apk",
"app/AppFoo@TEST.BUILD_ID/AppFoo.apk",
"overlay/blue/rro.apk",
"etc/bpf/bpf.o",
"etc/bpf/bpf2.o",
@@ -5658,8 +5659,8 @@ func TestApexWithApps(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk")
ensureContains(t, copyCmds, "image.apex/app/AppFoo@TEST.BUILD_ID/AppFoo.apk")
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@TEST.BUILD_ID/AppFooPriv.apk")
appZipRule := ctx.ModuleForTests("AppFoo", "android_common_apex10000").Description("zip jni libs")
// JNI libraries are uncompressed
@@ -5676,6 +5677,36 @@ func TestApexWithApps(t *testing.T) {
}
}
func TestApexWithAppImportBuildId(t *testing.T) {
invalidBuildIds := []string{"../", "a b", "a/b", "a/b/../c", "/a"}
for _, id := range invalidBuildIds {
message := fmt.Sprintf("Unable to use build id %s as filename suffix", id)
fixture := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildId = proptools.StringPtr(id)
})
testApexError(t, message, `apex {
name: "myapex",
key: "myapex.key",
apps: ["AppFooPrebuilt"],
updatable: false,
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
android_app_import {
name: "AppFooPrebuilt",
apk: "PrebuiltAppFoo.apk",
presigned: true,
apex_available: ["myapex"],
}
`, fixture)
}
}
func TestApexWithAppImports(t *testing.T) {
ctx := testApex(t, `
apex {
@@ -5721,8 +5752,8 @@ func TestApexWithAppImports(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt/AppFooPrebuilt.apk")
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt/AwesomePrebuiltAppFooPriv.apk")
ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@TEST.BUILD_ID/AppFooPrebuilt.apk")
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@TEST.BUILD_ID/AwesomePrebuiltAppFooPriv.apk")
}
func TestApexWithAppImportsPrefer(t *testing.T) {
@@ -5763,7 +5794,7 @@ func TestApexWithAppImportsPrefer(t *testing.T) {
}))
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
"app/AppFoo/AppFooPrebuilt.apk",
"app/AppFoo@TEST.BUILD_ID/AppFooPrebuilt.apk",
})
}
@@ -5796,7 +5827,7 @@ func TestApexWithTestHelperApp(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo/TesterHelpAppFoo.apk")
ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@TEST.BUILD_ID/TesterHelpAppFoo.apk")
}
func TestApexPropertiesShouldBeDefaultable(t *testing.T) {
@@ -6239,8 +6270,8 @@ func TestOverrideApex(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk")
ensureContains(t, copyCmds, "image.apex/app/override_app/override_app.apk")
ensureNotContains(t, copyCmds, "image.apex/app/app@TEST.BUILD_ID/app.apk")
ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk")
ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o")
ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o")
@@ -7026,7 +7057,7 @@ func TestAppBundle(t *testing.T) {
content := bundleConfigRule.Args["content"]
ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`)
ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo/AppFoo.apk"}]}`)
ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`)
}
func TestAppSetBundle(t *testing.T) {
@@ -7057,9 +7088,9 @@ func TestAppSetBundle(t *testing.T) {
if len(copyCmds) != 3 {
t.Fatalf("Expected 3 commands, got %d in:\n%s", len(copyCmds), s)
}
ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet$")
ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet$")
ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet .*/AppSet.zip$")
ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@TEST.BUILD_ID$")
ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@TEST.BUILD_ID$")
ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@TEST.BUILD_ID .*/AppSet.zip$")
}
func TestAppSetBundlePrebuilt(t *testing.T) {