diff options
author | 2024-11-05 22:21:04 +0000 | |
---|---|---|
committer | 2024-11-05 22:21:04 +0000 | |
commit | 32282f69e883792e7f10cd7f26b97c94438ec519 (patch) | |
tree | b78e56051636d84f6fe2cf593ec371d3804a4cb2 /tradefed_modules | |
parent | 0ba7034bf723aaf35db29811f6709aec5828b487 (diff) |
Add boilerplates for test_suite module type to tradefed_modules
This CL adds a new module type: test_suite.
test_suite {
name: "example-test-suite",
description: "some example test suite"
tests: [
"ExampleTest1",
"ExampleTest2",
],
}
test_suite allows users to define a suite of tests that can be run together. The test_suite module type takes a list of tests as input, and it will generate a single test module that can be run by tradefed.
This CL also adds a test for the test_suite module type. The test verifies that the test_suite module type can be used to define a suite of tests, and that the generated test module can be run by tradefed.
Change-Id: I1a8585899b29b0e96234a7abbd367de033d5f686
Bug: 372945132
Diffstat (limited to 'tradefed_modules')
-rw-r--r-- | tradefed_modules/Android.bp | 2 | ||||
-rw-r--r-- | tradefed_modules/test_suite.go | 56 | ||||
-rw-r--r-- | tradefed_modules/test_suite_test.go | 47 |
3 files changed, 105 insertions, 0 deletions
diff --git a/tradefed_modules/Android.bp b/tradefed_modules/Android.bp index 9969ae280..67d91b27c 100644 --- a/tradefed_modules/Android.bp +++ b/tradefed_modules/Android.bp @@ -13,9 +13,11 @@ bootstrap_go_package { ], srcs: [ "test_module_config.go", + "test_suite.go", ], testSrcs: [ "test_module_config_test.go", + "test_suite_test.go", ], pluginFor: ["soong_build"], } diff --git a/tradefed_modules/test_suite.go b/tradefed_modules/test_suite.go new file mode 100644 index 000000000..8ab194d94 --- /dev/null +++ b/tradefed_modules/test_suite.go @@ -0,0 +1,56 @@ +// 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" +) + +func init() { + RegisterTestSuiteBuildComponents(android.InitRegistrationContext) +} + +func RegisterTestSuiteBuildComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("test_suite", TestSuiteFactory) +} + +var PrepareForTestWithTestSuiteBuildComponents = android.GroupFixturePreparers( + android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents), +) + +type testSuiteProperties struct { + Description string + Tests []string `android:"path,arch_variant"` +} + +type testSuiteModule struct { + android.ModuleBase + android.DefaultableModuleBase + testSuiteProperties +} + +func (t *testSuiteModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { + // TODO(hwj): Implement this. +} + +func TestSuiteFactory() android.Module { + module := &testSuiteModule{} + module.AddProperties(&module.testSuiteProperties) + + android.InitAndroidModule(module) + android.InitDefaultableModule(module) + + return module +} diff --git a/tradefed_modules/test_suite_test.go b/tradefed_modules/test_suite_test.go new file mode 100644 index 000000000..f9e9da06a --- /dev/null +++ b/tradefed_modules/test_suite_test.go @@ -0,0 +1,47 @@ +// 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" + "testing" +) + +func TestTestSuites(t *testing.T) { + t.Parallel() + android.GroupFixturePreparers( + java.PrepareForTestWithJavaDefaultModules, + android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents), + ).RunTestWithBp(t, ` + android_test { + name: "TestModule1", + sdk_version: "current", + } + + android_test { + name: "TestModule2", + sdk_version: "current", + } + + test_suite { + name: "my-suite", + description: "a test suite", + tests: [ + "TestModule1", + "TestModule2", + ] + } + `) +} |