platform_build_soong/tradefed_modules/test_module_config_test.go

401 lines
15 KiB
Go
Raw Normal View History

Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
// Copyright 2024 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package tradefed_modules
import (
"android/soong/android"
"android/soong/java"
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
"strconv"
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
"strings"
"testing"
"github.com/google/blueprint"
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
)
const bp = `
android_app {
name: "foo",
srcs: ["a.java"],
sdk_version: "current",
}
android_test_helper_app {
name: "HelperApp",
srcs: ["helper.java"],
}
android_test {
name: "base",
sdk_version: "current",
data: [":HelperApp", "data/testfile"],
}
test_module_config {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
test_suites: ["general-tests"],
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}
`
// Ensure we create files needed and set the AndroidMkEntries needed
func TestModuleConfigAndroidTest(t *testing.T) {
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).RunTestWithBp(t, bp)
derived := ctx.ModuleForTests("derived_test", "android_common")
// Assert there are rules to create these files.
derived.Output("test_module_config.manifest")
derived.Output("test_config_fixer/derived_test.config")
// Ensure some basic rules exist.
ctx.ModuleForTests("base", "android_common").Output("package-res.apk")
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"})
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
// 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{""})
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
2024-04-12 00:43:32 +02:00
android.AssertStringMatches(t, "", entries.EntryMap["LOCAL_FULL_TEST_CONFIG"][0], "derived_test/android_common/test_config_fixer/derived_test.config")
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}
// Make sure we call test-config-fixer with the right args.
func TestModuleConfigOptions(t *testing.T) {
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).RunTestWithBp(t, bp)
// Check that we generate a rule to make a new AndroidTest.xml/Module.config file.
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_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}
// Ensure we error for a base we don't support.
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
func TestModuleConfigWithHostBaseShouldFailWithExplicitMessage(t *testing.T) {
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
badBp := `
java_test_host {
name: "base",
srcs: ["a.java"],
}
test_module_config {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
test_suites: ["general-tests"],
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}`
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
android.GroupFixturePreparers(
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
android.FixtureExpectsAtLeastOneErrorMatchingPattern("'java_test_host' module used as base, but 'android_test' expected")).
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
RunTestWithBp(t, badBp)
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
}
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
func TestModuleConfigBadBaseShouldFailWithGeneralMessage(t *testing.T) {
badBp := `
java_library {
name: "base",
srcs: ["a.java"],
}
test_module_config {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests"],
}`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsOneErrorPattern("'base' module used as base but it is not a 'android_test' module.")).
RunTestWithBp(t, badBp)
}
func TestModuleConfigNoBaseShouldFail(t *testing.T) {
badBp := `
java_library {
name: "base",
srcs: ["a.java"],
}
test_module_config {
name: "derived_test",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests"],
}`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsOneErrorPattern("'base' field must be set to a 'android_test' module.")).
RunTestWithBp(t, badBp)
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}
// Ensure we error for a base we don't support.
func TestModuleConfigNoFiltersOrAnnotationsShouldFail(t *testing.T) {
badBp := `
android_test {
name: "base",
sdk_version: "current",
srcs: ["a.java"],
}
test_module_config {
name: "derived_test",
base: "base",
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
test_suites: ["general-tests"],
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}`
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsAtLeastOneErrorMatchingPattern("Test options must be given")).
RunTestWithBp(t, badBp)
ctx.ModuleForTests("derived_test", "android_common")
}
func TestModuleConfigMultipleDerivedTestsWriteDistinctMakeEntries(t *testing.T) {
multiBp := `
android_test {
name: "base",
sdk_version: "current",
srcs: ["a.java"],
}
test_module_config {
name: "derived_test",
base: "base",
include_annotations: ["android.platform.test.annotations.LargeTest"],
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
test_suites: ["general-tests"],
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}
test_module_config {
name: "another_derived_test",
base: "base",
include_annotations: ["android.platform.test.annotations.LargeTest"],
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
test_suites: ["general-tests"],
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
}`
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).RunTestWithBp(t, multiBp)
{
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{""})
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
// 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.
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"derived_test"})
}
{
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{""})
Test_Module_Config soong implementation New soong module type `TestModuleConfig` This module type allows to write: test_module_config { name: "DerivedFrameworks1", base: "FrameworksServicesTests", include_filters: ["com.android.server.accessibility.FingerprintGestureDispatcherTest"], } This goal is to put the test options (include_fitler in this case) in Android.bp rather than TEST_MAPPING to be able to name a set of options and to allow the CI to more precise about which part of a TestModule might be failing. In general, it is recommended to split up tests rather than use this approach, but that isn't always feasible. More details on project here:  https://docs.google.com/document/d/1MpA4BS6mTr-1D-K9MVmzdHkSufAvIkkM4gPEUglNodk/edit?tab=t.0 Migration plan here: https://docs.google.com/document/d/1x3w-BvKO3E-GbY8YOSBuzJC6-pkLkuhfjSyZ1hJQBYM/edit?tab=t.0 Some details of final output: * All the [data] files from Derived are the same as base. * The apk names is changed to be the Module name * The test options are added to .config file * test-file-name in the .config file (for base.apk) is changed to be new apk. * module-info.json is hand inspected between base and derived. * I added a .manifest file so future tools know what base is, if they need it. We are working a mechanism to use a CAS so the zip of the testcases won't explode. (however the trident disk image will get bigger) % tree -ls out/target/product/shiba/testcases/DerivedFrameworks1 out/target/product/shiba/testcases/FrameworksServicesTests [ 4096] out/target/product/shiba/testcases/DerivedFrameworks1 ├── [ 4096] arm64 │   └── [ 72346281] DerivedFrameworks1.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 3157] DerivedFrameworks1.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk ├── [ 1017540] SuspendTestApp.apk └── [ 36] test_module_config.manifest [ 4096] out/target/product/shiba/testcases/FrameworksServicesTests ├── [ 4096] arm64 │   └── [ 72346281] FrameworksServicesTests.apk ├── [ 20887] BstatsTestApp.apk ├── [ 4096] data │   └── [ 851] broken_shortcut.xml ├── [ 2866] FrameworksServicesTests.config ├── [ 12695] JobTestApp.apk ├── [ 8599] MediaButtonReceiverHolderTestHelperApp.apk ├── [ 16791] SimpleServiceTestApp1.apk ├── [ 16791] SimpleServiceTestApp2.apk ├── [ 16791] SimpleServiceTestApp3.apk └── [ 1017540] SuspendTestApp.apk Fixes: 314148134 Test: atest DerivedFrameworks1 DerivedFrameworks2 Test: m blueprint_tests Change-Id: Ib73a3404557e0bd583b065f0cf2fd55fba9ccdbe
2024-02-02 21:37:20 +01:00
// 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.
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"another_derived_test"})
}
}
Add test_module_config_host This pairs with `test_module_config` but also works on the base is a `java_test_host` module. e.g. test_module_config_host { name: "CtsOsHostTestCases_DERIVED_2566", base: "CtsOsHostTestCases", test_suites: ["general-tests"], include_filters: [ "android.os.cts.StaticSharedLibsHostTests" ], exclude_annotations: [ "androidx.test.filters.FlakyTest","org.junit.Ignore" ], } The new module is composed of the previous and shares much of the same code. With respect to build size, Without this change, if you build CtsAppSecurityHostTestCases, there will be several copies of the jar (and related apks) : *) 1 in framework out/host/linux-x86/framework/CtsAppSecurityHostTestCases.jar *) 1 in testcases for the test out/host/linux-x86/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar *) 1 per compatibility suite testcases out/host/linux-x86/mts-documentsui/android-mts-documentsui/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mediaprovider/android-mts-mediaprovider/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts/android-mts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/cts/android-cts/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar out/host/linux-x86/mts-mainline-infra/android-mts-mainline-infra/testcases/CtsAppSecurityHostTestCases/CtsAppSecurityHostTestCases.jar A dervived test using CtsAppSecurityHostTestCases as base adds one more to its testcases dir: *) derived testcase. out/host/linux-x86/testcases/CtsAppSecurityHostTestCases_presubmit_ExternalStorageApp/CtsAppSecurityHostTestCases.jar Fixes: b/327280990 Test: m clean && m CtsOsHostTestCases_DERIVED_2566# as above Test: atest CtsOsHostTestCases_DERIVED_2566 --collect-tests-only Test: migrated the 71 TestMapping instances to Android.bp and build them. Ran tests on some of them. Ran some original `test_module_config` tests derived from `android_test` as well TODO: Add actions to validate the given filters are valid for the given test apks/jars. Change-Id: I115eedb6ff6ba8e72bb49e71867daf49d25ca0f1
2024-03-14 22:14:39 +01:00
// Test_module_config_host rule is allowed to depend on java_test_host
func TestModuleConfigHostBasics(t *testing.T) {
bp := `
java_test_host {
name: "base",
srcs: ["a.java"],
test_suites: ["suiteA", "general-tests", "suiteB"],
}
test_module_config_host {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests"],
}`
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).RunTestWithBp(t, bp)
variant := ctx.Config.BuildOS.String() + "_common"
derived := ctx.ModuleForTests("derived_test", variant)
mod := derived.Module().(*testModuleConfigHostModule)
allEntries := android.AndroidMkEntriesForTest(t, ctx.TestContext, mod)
entries := allEntries[0]
android.AssertArrayString(t, "", entries.EntryMap["LOCAL_MODULE"], []string{"derived_test"})
if !mod.Host() {
t.Errorf("host bit is not set for a java_test_host module.")
}
actualData, _ := strconv.ParseBool(entries.EntryMap["LOCAL_IS_UNIT_TEST"][0])
android.AssertBoolEquals(t, "LOCAL_IS_UNIT_TEST", true, actualData)
}
// When you pass an 'android_test' as base, the warning message is a bit obscure,
// talking about variants, but it is something. Ideally we could do better.
func TestModuleConfigHostBadBaseShouldFailWithVariantWarning(t *testing.T) {
badBp := `
android_test {
name: "base",
sdk_version: "current",
srcs: ["a.java"],
}
test_module_config_host {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
}`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsAtLeastOneErrorMatchingPattern("missing variant")).
RunTestWithBp(t, badBp)
}
func TestModuleConfigHostNeedsATestSuite(t *testing.T) {
badBp := `
java_test_host {
name: "base",
srcs: ["a.java"],
}
test_module_config_host {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
}`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsAtLeastOneErrorMatchingPattern("At least one test-suite must be set")).
RunTestWithBp(t, badBp)
}
func TestTestOnlyProvider(t *testing.T) {
t.Parallel()
ctx := android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).RunTestWithBp(t, `
// These should be test-only
test_module_config_host {
name: "host-derived-test",
base: "host-base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests"],
}
test_module_config {
name: "derived-test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests"],
}
android_test {
name: "base",
sdk_version: "current",
data: ["data/testfile"],
}
java_test_host {
name: "host-base",
srcs: ["a.java"],
test_suites: ["general-tests"],
}`,
)
// Visit all modules and ensure only the ones that should
// marked as test-only are marked as test-only.
actualTestOnly := []string{}
ctx.VisitAllModules(func(m blueprint.Module) {
if provider, ok := android.OtherModuleProvider(ctx.TestContext.OtherModuleProviderAdaptor(), m, android.TestOnlyProviderKey); ok {
if provider.TestOnly {
actualTestOnly = append(actualTestOnly, m.Name())
}
}
})
expectedTestOnlyModules := []string{
"host-derived-test",
"derived-test",
// android_test and java_test_host are tests too.
"host-base",
"base",
}
notEqual, left, right := android.ListSetDifference(expectedTestOnlyModules, actualTestOnly)
if notEqual {
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])
}
}