summaryrefslogtreecommitdiff
path: root/apex/apex_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r--apex/apex_test.go48
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) {