Revert "Change test_module_config from copying files to symlink ..."
Revert submission 3060229-ron-tmc-symlinks
Reason for revert: Droidmonitor created revert due to b/344045516
Reverted changes: /q/submissionid:3060229-ron-tmc-symlinks
Change-Id: If5045366677163560cdae95c0ab74256b4b49b9a
diff --git a/tradefed_modules/test_module_config_test.go b/tradefed_modules/test_module_config_test.go
index 97179f5..b2049b1 100644
--- a/tradefed_modules/test_module_config_test.go
+++ b/tradefed_modules/test_module_config_test.go
@@ -16,7 +16,6 @@
import (
"android/soong/android"
"android/soong/java"
- "fmt"
"strconv"
"strings"
"testing"
@@ -70,36 +69,15 @@
entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
// Ensure some entries from base are there, specifically support files for data and helper apps.
- // Do not use LOCAL_COMPATIBILITY_SUPPORT_FILES, but instead use LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES
- android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
- []string{"out/soong/target/product/test_device/testcases/derived_test/arm64/base.apk",
- "out/soong/target/product/test_device/testcases/derived_test/HelperApp.apk",
- "out/soong/target/product/test_device/testcases/derived_test/data/testfile"},
- entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{})
-
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_REQUIRED_MODULES"], []string{"base"})
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_CERTIFICATE"], []string{"build/make/target/product/security/testkey.x509.pem"})
- android.AssertStringEquals(t, "", entries.Class, "APPS")
+ assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
// And some new derived entries are there.
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE_TAGS"], []string{"tests"})
- android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
+ // And ones we override
+ android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
- // Check the footer lines. Our support files should depend on base's support files.
- convertedActual := make([]string, 5)
- for i, e := range entries.FooterLinesForTests() {
- // AssertStringPathsRelativeToTop doesn't replace both instances
- convertedActual[i] = strings.Replace(e, ctx.Config.SoongOutDir(), "", 2)
- }
- android.AssertArrayString(t, fmt.Sprintf("%s", ctx.Config.SoongOutDir()), convertedActual, []string{
- "include $(BUILD_SYSTEM)/soong_app_prebuilt.mk",
- "/target/product/test_device/testcases/derived_test/arm64/base.apk: /target/product/test_device/testcases/base/arm64/base.apk",
- "/target/product/test_device/testcases/derived_test/HelperApp.apk: /target/product/test_device/testcases/base/HelperApp.apk",
- "/target/product/test_device/testcases/derived_test/data/testfile: /target/product/test_device/testcases/base/data/testfile",
- "",
- })
+ android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
}
// Make sure we call test-config-fixer with the right args.
@@ -114,7 +92,7 @@
derived := ctx.ModuleForTests("derived_test", "android_common")
rule_cmd := derived.Rule("fix_test_config").RuleParams.Command
android.AssertStringDoesContain(t, "Bad FixConfig rule inputs", rule_cmd,
- `--test-runner-options='[{"Name":"exclude-filter","Key":"","Value":"android.test.example.devcodelab.DevCodelabTest#testHelloFail"},{"Name":"include-annotation","Key":"","Value":"android.platform.test.annotations.LargeTest"}]'`)
+ `--test-file-name=derived_test.apk --orig-test-file-name=base.apk --test-runner-options='[{"Name":"exclude-filter","Key":"","Value":"android.test.example.devcodelab.DevCodelabTest#testHelloFail"},{"Name":"include-annotation","Key":"","Value":"android.platform.test.annotations.LargeTest"}]'`)
}
// Ensure we error for a base we don't support.
@@ -217,14 +195,8 @@
name: "base",
sdk_version: "current",
srcs: ["a.java"],
- data: [":HelperApp", "data/testfile"],
}
- android_test_helper_app {
- name: "HelperApp",
- srcs: ["helper.java"],
- }
-
test_module_config {
name: "derived_test",
base: "base",
@@ -248,12 +220,8 @@
derived := ctx.ModuleForTests("derived_test", "android_common")
entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
// All these should be the same in both derived tests
- android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
- []string{"out/soong/target/product/test_device/testcases/derived_test/arm64/base.apk",
- "out/soong/target/product/test_device/testcases/derived_test/HelperApp.apk",
- "out/soong/target/product/test_device/testcases/derived_test/data/testfile"},
- entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])
-
+ assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
+ android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
// Except this one, which points to the updated tradefed xml file.
android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
// And this one, the module name.
@@ -264,11 +232,8 @@
derived := ctx.ModuleForTests("another_derived_test", "android_common")
entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
// All these should be the same in both derived tests
- android.AssertStringPathsRelativeToTopEquals(t, "support-files", ctx.Config,
- []string{"out/soong/target/product/test_device/testcases/another_derived_test/arm64/base.apk",
- "out/soong/target/product/test_device/testcases/another_derived_test/HelperApp.apk",
- "out/soong/target/product/test_device/testcases/another_derived_test/data/testfile"},
- entries.EntryMap["LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES"])
+ assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
+ android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
// Except this one, which points to the updated tradefed xml file.
android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "another_derived_test/android_common/test_config_fixer/another_derived_test.config")
// And this one, the module name.
@@ -304,8 +269,6 @@
allEntries := android.AndroidMkEntriesForTest(t, ctx.TestContext, mod)
entries := allEntries[0]
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"derived_test"})
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SDK_VERSION"], []string{"private_current"})
- android.AssertStringEquals(t, "", entries.Class, "JAVA_LIBRARIES")
if !mod.Host() {
t.Errorf("host bit is not set for a java_test_host module.")
@@ -422,3 +385,16 @@
t.Errorf("test-only: Expected but not found: %v, Found but not expected: %v", left, right)
}
}
+
+// Use for situations where the entries map contains pairs: [srcPath:installedPath1, srcPath2:installedPath2]
+// and we want to compare the RHS of the pairs, i.e. installedPath1, installedPath2
+func assertEntryPairValues(t *testing.T, actual []string, expected []string) {
+ for i, e := range actual {
+ parts := strings.Split(e, ":")
+ if len(parts) != 2 {
+ t.Errorf("Expected entry to have a value delimited by :, received: %s", e)
+ return
+ }
+ android.AssertStringEquals(t, "", parts[1], expected[i])
+ }
+}