diff options
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r-- | apex/apex_test.go | 84 |
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") |