blob: a6c27274b8df2355e194d2ddc5a996af830ffef6 [file] [log] [blame]
Weijia He32282f62024-11-05 22:21:04 +00001// Copyright 2024 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package tradefed_modules
16
17import (
Weijia Heaa37c162024-11-06 19:46:03 +000018 "fmt"
19
Weijia He32282f62024-11-05 22:21:04 +000020 "android/soong/android"
21)
22
23func init() {
24 RegisterTestSuiteBuildComponents(android.InitRegistrationContext)
25}
26
27func RegisterTestSuiteBuildComponents(ctx android.RegistrationContext) {
28 ctx.RegisterModuleType("test_suite", TestSuiteFactory)
29}
30
31var PrepareForTestWithTestSuiteBuildComponents = android.GroupFixturePreparers(
32 android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents),
33)
34
35type testSuiteProperties struct {
36 Description string
37 Tests []string `android:"path,arch_variant"`
38}
39
40type testSuiteModule struct {
41 android.ModuleBase
42 android.DefaultableModuleBase
43 testSuiteProperties
44}
45
46func (t *testSuiteModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Weijia Heaa37c162024-11-06 19:46:03 +000047 suiteName := ctx.ModuleName()
48 manifestPath := android.PathForSuiteInstall(ctx, suiteName, suiteName+".json")
49 android.WriteFileRule(ctx, manifestPath, fmt.Sprintf(`{"name": %q}`, suiteName))
50 ctx.Phony(suiteName, manifestPath)
Weijia He32282f62024-11-05 22:21:04 +000051}
52
53func TestSuiteFactory() android.Module {
54 module := &testSuiteModule{}
55 module.AddProperties(&module.testSuiteProperties)
56
57 android.InitAndroidModule(module)
58 android.InitDefaultableModule(module)
59
60 return module
61}