summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
author Chan Wang <chanwang@google.com> 2025-01-14 18:04:39 +0000
committer Chan Wang <chanwang@google.com> 2025-01-14 21:32:03 +0000
commit54956a6ed9fe5e441fb0e6c966080872c3fd1d81 (patch)
tree3ac21eae5b6e99d14c3c2fe7e85693b862a016d8 /apex/apex_test.go
parent8256360f4f4458475e6a6ef97c501057c1f3e8e8 (diff)
Resend aosp/3445142
Not revert^2 to avoid potential automerge issue, because the previous change failed to auto-merge into internal branch (b/389693264 logged for it) Bug: 380222284 Test: m nothing --no-skip-soong-tests Change-Id: Ie55e98597cb931a4e3e84ae595317f3cc21192c9
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go84
1 files changed, 74 insertions, 10 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go
index b344a2bb9..a5b66c10e 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -2421,11 +2421,11 @@ func TestApexMinSdkVersion_InVendorApex(t *testing.T) {
android.AssertStringDoesContain(t, "cflags", cflags, "-target aarch64-linux-android29")
}
-func TestTrackAllowedDeps(t *testing.T) {
+func TestTrackAllowedDepsForAndroidApex(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
apex {
- name: "myapex",
+ name: "com.android.myapex",
key: "myapex.key",
updatable: true,
native_shared_libs: [
@@ -2453,7 +2453,7 @@ func TestTrackAllowedDeps(t *testing.T) {
srcs: ["mylib.cpp"],
shared_libs: ["libbar", "libbar_rs"],
min_sdk_version: "29",
- apex_available: ["myapex"],
+ apex_available: ["com.android.myapex"],
}
cc_library {
@@ -2472,20 +2472,23 @@ func TestTrackAllowedDeps(t *testing.T) {
name: "yourlib",
srcs: ["mylib.cpp"],
min_sdk_version: "29",
- apex_available: ["myapex", "myapex2", "//apex_available:platform"],
+ apex_available: ["com.android.myapex", "myapex2", "//apex_available:platform"],
}
`, withFiles(android.MockFS{
"packages/modules/common/build/allowed_deps.txt": nil,
- }))
+ }),
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/com.android.myapex-file_contexts": nil,
+ }))
depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings()
- android.AssertStringListContains(t, "updatable myapex should generate depsinfo file", inputs,
- "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt")
+ android.AssertStringListContains(t, "updatable com.android.myapex should generate depsinfo file", inputs,
+ "out/soong/.intermediates/com.android.myapex/android_common_com.android.myapex/depsinfo/flatlist.txt")
android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs,
"out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt")
- myapex := ctx.ModuleForTests("myapex", "android_common_myapex")
+ myapex := ctx.ModuleForTests("com.android.myapex", "android_common_com.android.myapex")
flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx,
myapex.Output("depsinfo/flatlist.txt")), "\n")
android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep",
@@ -2498,22 +2501,83 @@ func TestTrackAllowedDeps(t *testing.T) {
flatlist, "yourlib(minSdkVersion:29)")
}
-func TestTrackAllowedDeps_SkipWithoutAllowedDepsTxt(t *testing.T) {
+func TestNotTrackAllowedDepsForNonAndroidApex(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
apex {
name: "myapex",
key: "myapex.key",
updatable: true,
+ native_shared_libs: [
+ "mylib",
+ "yourlib",
+ ],
min_sdk_version: "29",
}
+ apex {
+ name: "myapex2",
+ key: "myapex.key",
+ updatable: false,
+ native_shared_libs: ["yourlib"],
+ }
+
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
- `)
+
+ cc_library {
+ name: "mylib",
+ srcs: ["mylib.cpp"],
+ shared_libs: ["libbar"],
+ min_sdk_version: "29",
+ apex_available: ["myapex"],
+ }
+
+ cc_library {
+ name: "libbar",
+ stubs: { versions: ["29", "30"] },
+ }
+
+ cc_library {
+ name: "yourlib",
+ srcs: ["mylib.cpp"],
+ min_sdk_version: "29",
+ apex_available: ["myapex", "myapex2", "//apex_available:platform"],
+ }
+ `, withFiles(android.MockFS{
+ "packages/modules/common/build/allowed_deps.txt": nil,
+ }))
+
+ depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
+ inputs := depsinfo.Rule("generateApexDepsInfoFilesRule").BuildParams.Inputs.Strings()
+ android.AssertStringListDoesNotContain(t, "updatable myapex should generate depsinfo file", inputs,
+ "out/soong/.intermediates/myapex/android_common_myapex/depsinfo/flatlist.txt")
+ android.AssertStringListDoesNotContain(t, "non-updatable myapex2 should not generate depsinfo file", inputs,
+ "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt")
+}
+
+func TestTrackAllowedDeps_SkipWithoutAllowedDepsTxt(t *testing.T) {
+ t.Parallel()
+ ctx := testApex(t, `
+ apex {
+ name: "com.android.myapex",
+ key: "myapex.key",
+ updatable: true,
+ min_sdk_version: "29",
+ }
+
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `,
+ android.FixtureMergeMockFs(android.MockFS{
+ "system/sepolicy/apex/com.android.myapex-file_contexts": nil,
+ }))
depsinfo := ctx.SingletonForTests("apex_depsinfo_singleton")
if nil != depsinfo.MaybeRule("generateApexDepsInfoFilesRule").Output {
t.Error("apex_depsinfo_singleton shouldn't run when allowed_deps.txt doesn't exist")