diff options
| author | 2023-02-02 14:39:53 +0000 | |
|---|---|---|
| committer | 2023-02-02 14:39:53 +0000 | |
| commit | a928c8dae11d603c77c3f0a8133536fc09418e4d (patch) | |
| tree | ff0cb02e92bf8cf0a8f081819e94cf8e01e57a7d | |
| parent | 1978fdf9b28c99ea32a0f72289d7dc999cfe07dd (diff) | |
| parent | d4f5d932a1f966797a0ea671af088d88019d5417 (diff) | |
Merge "Add soong unit test for trimmed apex build"
| -rw-r--r-- | android/testing.go | 5 | ||||
| -rw-r--r-- | apex/apex_test.go | 67 |
2 files changed, 72 insertions, 0 deletions
diff --git a/android/testing.go b/android/testing.go index e4202ae6b..fc39a9c7a 100644 --- a/android/testing.go +++ b/android/testing.go @@ -1125,6 +1125,11 @@ func SetKatiEnabledForTests(config Config) { config.katiEnabled = true } +func SetTrimmedApexEnabledForTests(config Config) { + config.productVariables.TrimmedApex = new(bool) + *config.productVariables.TrimmedApex = true +} + func AndroidMkEntriesForTest(t *testing.T, ctx *TestContext, mod blueprint.Module) []AndroidMkEntries { t.Helper() var p AndroidMkEntriesProvider diff --git a/apex/apex_test.go b/apex/apex_test.go index ea068eeba..31e848e42 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -9862,3 +9862,70 @@ func TestApexBuildsAgainstApiSurfaceStubLibraries(t *testing.T) { libcCoreVariant := result.ModuleForTests("libc.apiimport", "android_arm64_armv8-a_shared").Module() android.AssertBoolEquals(t, "core variant should link against source libc", true, hasDep(libfooCoreVariant, libcCoreVariant)) } + +func TestTrimmedApex(t *testing.T) { + bp := ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["libfoo","libbaz"], + min_sdk_version: "29", + trim_against: "mydcla", + } + apex { + name: "mydcla", + key: "myapex.key", + native_shared_libs: ["libfoo","libbar"], + min_sdk_version: "29", + file_contexts: ":myapex-file_contexts", + dynamic_common_lib_apex: true, + } + apex_key { + name: "myapex.key", + } + cc_library { + name: "libfoo", + shared_libs: ["libc"], + apex_available: ["myapex","mydcla"], + min_sdk_version: "29", + } + cc_library { + name: "libbar", + shared_libs: ["libc"], + apex_available: ["myapex","mydcla"], + min_sdk_version: "29", + } + cc_library { + name: "libbaz", + shared_libs: ["libc"], + apex_available: ["myapex","mydcla"], + min_sdk_version: "29", + } + cc_api_library { + name: "libc", + src: "libc.so", + min_sdk_version: "29", + recovery_available: true, + } + api_imports { + name: "api_imports", + shared_libs: [ + "libc", + ], + header_libs: [], + } + ` + ctx := testApex(t, bp) + module := ctx.ModuleForTests("myapex", "android_common_myapex_image") + apexRule := module.MaybeRule("apexRule") + if apexRule.Rule == nil { + t.Errorf("Expecting regular apex rule but a non regular apex rule found") + } + + ctx = testApex(t, bp, android.FixtureModifyConfig(android.SetTrimmedApexEnabledForTests)) + trimmedApexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("TrimmedApexRule") + libs_to_trim := trimmedApexRule.Args["libs_to_trim"] + android.AssertStringDoesContain(t, "missing lib to trim", libs_to_trim, "libfoo") + android.AssertStringDoesContain(t, "missing lib to trim", libs_to_trim, "libbar") + android.AssertStringDoesNotContain(t, "unexpected libs in the libs to trim", libs_to_trim, "libbaz") +} |