Change test_module_config from copying files to symlink files.
Now the derived modules will have symlink's to base's testcase dir
rather than copyfile files from base's intermediates dir.
I also removed storing the "base" module as dependency and only use
data from the provider in GenerateAndroidBuildActions and
AndroidMkEntries.
I did have to add two fields to the provider for this.
To ensure the symlinks always resolve to a physical file, I also added
goals such that building `derived-target` will also build `build-target`
Create new Make variable: LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES
for tasks/general-tests.mk,device-tests.mk to read.
This allows "support" files that are installed with soong rules rather
than make rules to still end up in the zips.
Sample dir structure:
% tree -ls testcases aosp_cf_x86_64_phone[4:31:54]/0
[ 4096] testcases
├── [ 4096] FrameworksServicesTests
│ ├── [ 4096] data
│ │ └── [ 851] broken_shortcut.xml
│ ├── [ 2800] FrameworksServicesTests.config
│ ├── [ 12695] JobTestApp.apk
│ ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk
│ ├── [ 16791] SimpleServiceTestApp1.apk
│ ├── [ 16791] SimpleServiceTestApp2.apk
│ ├── [ 16791] SimpleServiceTestApp3.apk
│ ├── [ 1017763] SuspendTestApp.apk
│ └── [ 4096] x86_64
│ └── [ 79827767] FrameworksServicesTests.apk
└── [ 4096] FrameworksServicesTests_contentprotection
├── [ 4096] data
│ └── [ 54] broken_shortcut.xml -> ../../FrameworksServicesTests/data/broken_shortcut.xml
├── [ 3005] FrameworksServicesTests_contentprotection.config
├── [ 41] JobTestApp.apk -> ../FrameworksServicesTests/JobTestApp.apk
├── [ 69] MediaButtonReceiverHolderTestHelperApp.apk -> ../FrameworksServicesTests/MediaButtonReceiverHolderTestHelperApp.apk
├── [ 52] SimpleServiceTestApp1.apk -> ../FrameworksServicesTests/SimpleServiceTestApp1.apk
├── [ 52] SimpleServiceTestApp2.apk -> ../FrameworksServicesTests/SimpleServiceTestApp2.apk
├── [ 52] SimpleServiceTestApp3.apk -> ../FrameworksServicesTests/SimpleServiceTestApp3.apk
├── [ 45] SuspendTestApp.apk -> ../FrameworksServicesTests/SuspendTestApp.apk
├── [ 36] test_module_config.manifest
└── [ 4096] x86_64
├── [ 64] FrameworksServicesTests.apk -> ../../FrameworksServicesTests/x86_64/FrameworksServicesTests.apk
└── [ 36] UNUSED-FrameworksServicesTests.apk
Test: m clean && atest FrameworksServicesTests_contentprotection
Test: m clean && atest CtsDevicePolicyManagerTestCases_ParentProfileApiDisabled
Bug: b/332320956
Change-Id: I8466f253fa559bc74cef4533edf263650e96bbfb
diff --git a/tradefed_modules/test_module_config_test.go b/tradefed_modules/test_module_config_test.go
index b2049b1..97179f5 100644
--- a/tradefed_modules/test_module_config_test.go
+++ b/tradefed_modules/test_module_config_test.go
@@ -16,6 +16,7 @@
import (
"android/soong/android"
"android/soong/java"
+ "fmt"
"strconv"
"strings"
"testing"
@@ -69,15 +70,36 @@
entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, derived.Module())[0]
// Ensure some entries from base are there, specifically support files for data and helper apps.
- assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
+ // 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")
// And some new derived entries are there.
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE_TAGS"], []string{"tests"})
- // And ones we override
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
-
android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
+
+ // 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",
+ "",
+ })
}
// Make sure we call test-config-fixer with the right args.
@@ -92,7 +114,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-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"}]'`)
+ `--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.
@@ -195,8 +217,14 @@
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",
@@ -220,8 +248,12 @@
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
- assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
+ 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"])
+
// 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.
@@ -232,8 +264,11 @@
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
- assertEntryPairValues(t, entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"], []string{"HelperApp.apk", "data/testfile"})
- android.AssertArrayString(t, "", entries.EntryMap["LOCAL_SOONG_JNI_LIBS_SYMBOLS"], []string{""})
+ 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"])
// 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.
@@ -269,6 +304,8 @@
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.")
@@ -385,16 +422,3 @@
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])
- }
-}