summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
author Jingwen Chen <jingwen@google.com> 2022-04-19 13:58:58 +0000
committer Jingwen Chen <jingwen@google.com> 2022-04-21 10:20:51 +0000
commit6cb124b8d9197562c83bb8ce708f04d3486d6143 (patch)
treeb878db15ab040e42cf8dc0537a817b7208792a35 /apex/apex_test.go
parent3a5be76dc0757285342489ca733b4b35252468b4 (diff)
Append APEX version instead of build ID for APK-in-APEX paths.
This CL removes the build_id.mk suffix and replaces it with a hardcoded placeholder string that will be replaced with the actual version in apex_manifest.json by apexer at apex construction time. This means that as long as the apex version is incremented, the APK-in-APEX will be installed to a new directory path from the package manager's perspective. Fixes: 229574810 Bug: 229625490 Bug: 226559955 Bug: 224589412 Bug: 227417611 Bug: 228157333 Bug: 228803590 Bug: 229136249 Test: atest StrictJavaPackagesTest Test: soong tests Test: deapexer list out/dist/com.google.android.permission.apex Change-Id: I9cef1418c3fc7e0970d96995b8398f5e82f479e0
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go57
1 files changed, 13 insertions, 44 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 7b2905884..4a52115db 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -223,7 +223,6 @@ 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")
}),
)
@@ -683,7 +682,7 @@ func TestDefaults(t *testing.T) {
"etc/myetc",
"javalib/myjar.jar",
"lib64/mylib.so",
- "app/AppFoo@TEST.BUILD_ID/AppFoo.apk",
+ "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk",
"overlay/blue/rro.apk",
"etc/bpf/bpf.o",
"etc/bpf/bpf2.o",
@@ -5683,8 +5682,8 @@ func TestApexWithApps(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
- 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")
+ ensureContains(t, copyCmds, "image.apex/app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk")
+ ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@__APEX_VERSION_PLACEHOLDER__/AppFooPriv.apk")
appZipRule := ctx.ModuleForTests("AppFoo", "android_common_apex10000").Description("zip jni libs")
// JNI libraries are uncompressed
@@ -5701,36 +5700,6 @@ 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 {
@@ -5776,8 +5745,8 @@ func TestApexWithAppImports(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
- 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")
+ ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk")
+ ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@__APEX_VERSION_PLACEHOLDER__/AwesomePrebuiltAppFooPriv.apk")
}
func TestApexWithAppImportsPrefer(t *testing.T) {
@@ -5818,7 +5787,7 @@ func TestApexWithAppImportsPrefer(t *testing.T) {
}))
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
- "app/AppFoo@TEST.BUILD_ID/AppFooPrebuilt.apk",
+ "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk",
})
}
@@ -5851,7 +5820,7 @@ func TestApexWithTestHelperApp(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
- ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@TEST.BUILD_ID/TesterHelpAppFoo.apk")
+ ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@__APEX_VERSION_PLACEHOLDER__/TesterHelpAppFoo.apk")
}
func TestApexPropertiesShouldBeDefaultable(t *testing.T) {
@@ -6294,8 +6263,8 @@ func TestOverrideApex(t *testing.T) {
apexRule := module.Rule("apexRule")
copyCmds := apexRule.Args["copy_commands"]
- 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/app/app@__APEX_VERSION_PLACEHOLDER__/app.apk")
+ ensureContains(t, copyCmds, "image.apex/app/override_app@__APEX_VERSION_PLACEHOLDER__/override_app.apk")
ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o")
ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o")
@@ -7199,7 +7168,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@TEST.BUILD_ID/AppFoo.apk"}]}`)
+ ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk"}]}`)
}
func TestAppSetBundle(t *testing.T) {
@@ -7230,9 +7199,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@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$")
+ ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$")
+ ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$")
+ ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__ .*/AppSet.zip$")
}
func TestAppSetBundlePrebuilt(t *testing.T) {