apex: make allowed_files prop overridable

Because override_apex can modify the contents of the base apex,
allowed_files (which describes the contents) should be overridable.

Bug: 159503079
Bug: 159392784
Bug: 158169437
Test: m (soong test added)
Merged-In: I12744b0465dc3cfc90a66643867e65b4092cd0f7
Change-Id: I12744b0465dc3cfc90a66643867e65b4092cd0f7
(cherry picked from commit faa5399b3f)
This commit is contained in:
Jooyung Han
2020-06-20 12:47:47 +09:00
parent 34753055d1
commit 938b593887
3 changed files with 63 additions and 5 deletions

View File

@@ -5396,6 +5396,61 @@ func TestApexKeysTxt(t *testing.T) {
ensureNotContains(t, content, "myapex.apex")
}
func TestAllowedFiles(t *testing.T) {
ctx, _ := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
apps: ["app"],
allowed_files: "allowed.txt",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
android_app {
name: "app",
srcs: ["foo/bar/MyClass.java"],
package_name: "foo",
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
}
`, withFiles(map[string][]byte{
"sub/Android.bp": []byte(`
override_apex {
name: "override_myapex",
base: "myapex",
apps: ["override_app"],
allowed_files: ":allowed",
}
// Overridable "path" property should be referenced indirectly
filegroup {
name: "allowed",
srcs: ["allowed.txt"],
}
override_android_app {
name: "override_app",
base: "app",
package_name: "bar",
}
`),
}))
rule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("diffApexContentRule")
if expected, actual := "allowed.txt", rule.Args["allowed_files_file"]; expected != actual {
t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
}
rule2 := ctx.ModuleForTests("myapex", "android_common_override_myapex_myapex_image").Rule("diffApexContentRule")
if expected, actual := "sub/allowed.txt", rule2.Args["allowed_files_file"]; expected != actual {
t.Errorf("allowed_files_file: expected %q but got %q", expected, actual)
}
}
func TestMain(m *testing.M) {
run := func() int {
setUp()