diff options
-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", + ] + } + `) +} |