summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Bill Yang <yangbill@google.com> 2025-03-04 10:56:25 +0000
committer Bill Yang <yangbill@google.com> 2025-03-04 11:11:14 +0000
commit98a34c97540dd6e781e9adf391135b408ccb9d3d (patch)
tree64bf1dcf362927d71d723dec748f0432d601d27d
parente0ce38b8105279869f0bdaab06238b5a7177a13f (diff)
Fix path replacement logic for test_package
The original Makefile used patsubst for string replacement, which replaces only the first matching pattern. To prevent unintended modifications to other test paths, replace 'strings.ReplaceAll' with 'strings.Replace'. Bug: 399246722 Test: m dist platform_tests Change-Id: I692c7400fbba914e7b0c4cfe81ae7dd0d07b803f
-rw-r--r--ci_tests/ci_test_package_zip.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/ci_tests/ci_test_package_zip.go b/ci_tests/ci_test_package_zip.go
index 0db3f9f67..f1cfb15b3 100644
--- a/ci_tests/ci_test_package_zip.go
+++ b/ci_tests/ci_test_package_zip.go
@@ -236,20 +236,21 @@ func extendBuilderCommand(ctx android.ModuleContext, m android.Module, builder *
if strings.HasPrefix(f, "out") {
continue
}
- f = strings.ReplaceAll(f, "system/", "DATA/")
+ if strings.HasPrefix(f, "system/") {
+ f = strings.Replace(f, "system/", "DATA/", 1)
+ }
f = strings.ReplaceAll(f, filepath.Join("testcases", name, arch), filepath.Join("DATA", class, name))
f = strings.ReplaceAll(f, filepath.Join("testcases", name, secondArch), filepath.Join("DATA", class, name))
- f = strings.ReplaceAll(f, "testcases", filepath.Join("DATA", class))
- f = strings.ReplaceAll(f, "data/", "DATA/")
+ if strings.HasPrefix(f, "testcases") {
+ f = strings.Replace(f, "testcases", filepath.Join("DATA", class), 1)
+ }
+ if strings.HasPrefix(f, "data/") {
+ f = strings.Replace(f, "data/", "DATA/", 1)
+ }
f = strings.ReplaceAll(f, "DATA_other", "system_other")
f = strings.ReplaceAll(f, "system_other/DATA", "system_other/system")
dir := filepath.Dir(f)
- // ignore the additional installed files from test
- if strings.Contains(dir, "DATA/native_tests") || strings.Count(dir, "DATA") > 1 {
- continue
- }
-
tempOut := android.PathForModuleOut(ctx, "STAGING", f)
builder.Command().Text("mkdir").Flag("-p").Text(filepath.Join(stagingDir.String(), dir))
builder.Command().Text("cp").Flag("-Rf").Input(installedFile).Output(tempOut)