diff options
| author | 2022-12-21 10:17:44 +0900 | |
|---|---|---|
| committer | 2022-12-21 10:17:44 +0900 | |
| commit | 1724d58a91e43a3f04817ddf93dae605673d1a95 (patch) | |
| tree | a24111e38e2081ea461170ef84438a85ee256294 /apex/apex_test.go | |
| parent | 862c0d68fff500d7fe59bc2fcfc9c7d75596e5b5 (diff) | |
apex_vndk doen't need stub variants
This was revealed by the new check added in
Ib3c6efd16bdf13b59f79be66d4f9dba49100f6cc.
This was okay since the old implementation relied on the fact that impl
variant comes before stub variants.
To make the new check happy and keep the intention explicit, stub
variants are not added to VNDK apex.
Bug: 191770320
Test: m (apex_test)
Change-Id: I455f2c9b6bc471c579379286c0198f36d325adf6
Diffstat (limited to 'apex/apex_test.go')
| -rw-r--r-- | apex/apex_test.go | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index b818f7036..33fce7c8b 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -3420,11 +3420,34 @@ type fileInApex struct { isLink bool } +func (f fileInApex) String() string { + return f.src + ":" + f.path +} + +func (f fileInApex) match(expectation string) bool { + parts := strings.Split(expectation, ":") + if len(parts) == 1 { + match, _ := path.Match(parts[0], f.path) + return match + } + if len(parts) == 2 { + matchSrc, _ := path.Match(parts[0], f.src) + matchDst, _ := path.Match(parts[1], f.path) + return matchSrc && matchDst + } + panic("invalid expected file specification: " + expectation) +} + func getFiles(t *testing.T, ctx *android.TestContext, moduleName, variant string) []fileInApex { t.Helper() - apexRule := ctx.ModuleForTests(moduleName, variant).Rule("apexRule") + module := ctx.ModuleForTests(moduleName, variant) + apexRule := module.MaybeRule("apexRule") + apexDir := "/image.apex/" + if apexRule.Rule == nil { + apexRule = module.Rule("zipApexRule") + apexDir = "/image.zipapex/" + } copyCmds := apexRule.Args["copy_commands"] - imageApexDir := "/image.apex/" var ret []fileInApex for _, cmd := range strings.Split(copyCmds, "&&") { cmd = strings.TrimSpace(cmd) @@ -3455,11 +3478,11 @@ func getFiles(t *testing.T, ctx *android.TestContext, moduleName, variant string t.Fatalf("copyCmds should contain mkdir/cp commands only: %q", cmd) } if dst != "" { - index := strings.Index(dst, imageApexDir) + index := strings.Index(dst, apexDir) if index == -1 { - t.Fatal("copyCmds should copy a file to image.apex/", cmd) + t.Fatal("copyCmds should copy a file to "+apexDir, cmd) } - dstFile := dst[index+len(imageApexDir):] + dstFile := dst[index+len(apexDir):] ret = append(ret, fileInApex{path: dstFile, src: src, isLink: isLink}) } } @@ -3472,16 +3495,16 @@ func ensureExactContents(t *testing.T, ctx *android.TestContext, moduleName, var var surplus []string filesMatched := make(map[string]bool) for _, file := range getFiles(t, ctx, moduleName, variant) { - mactchFound := false + matchFound := false for _, expected := range files { - if matched, _ := path.Match(expected, file.path); matched { + if file.match(expected) { + matchFound = true filesMatched[expected] = true - mactchFound = true break } } - if !mactchFound { - surplus = append(surplus, file.path) + if !matchFound { + surplus = append(surplus, file.String()) } } @@ -3974,6 +3997,11 @@ func TestVndkApexShouldNotProvideNativeLibs(t *testing.T) { apexManifestRule := ctx.ModuleForTests("com.android.vndk.current", "android_common_image").Rule("apexManifestRule") provideNativeLibs := names(apexManifestRule.Args["provideNativeLibs"]) ensureListEmpty(t, provideNativeLibs) + ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{ + "out/soong/.intermediates/libz/android_vendor.29_arm64_armv8-a_shared/libz.so:lib64/libz.so", + "out/soong/.intermediates/libz/android_vendor.29_arm_armv7-a-neon_shared/libz.so:lib/libz.so", + "*/*", + }) } func TestDependenciesInApexManifest(t *testing.T) { |