Weijia He | 32282f6 | 2024-11-05 22:21:04 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package tradefed_modules |
| 16 | |
| 17 | import ( |
Weijia He | aa37c16 | 2024-11-06 19:46:03 +0000 | [diff] [blame^] | 18 | "fmt" |
| 19 | |
Weijia He | 32282f6 | 2024-11-05 22:21:04 +0000 | [diff] [blame] | 20 | "android/soong/android" |
| 21 | ) |
| 22 | |
| 23 | func init() { |
| 24 | RegisterTestSuiteBuildComponents(android.InitRegistrationContext) |
| 25 | } |
| 26 | |
| 27 | func RegisterTestSuiteBuildComponents(ctx android.RegistrationContext) { |
| 28 | ctx.RegisterModuleType("test_suite", TestSuiteFactory) |
| 29 | } |
| 30 | |
| 31 | var PrepareForTestWithTestSuiteBuildComponents = android.GroupFixturePreparers( |
| 32 | android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents), |
| 33 | ) |
| 34 | |
| 35 | type testSuiteProperties struct { |
| 36 | Description string |
| 37 | Tests []string `android:"path,arch_variant"` |
| 38 | } |
| 39 | |
| 40 | type testSuiteModule struct { |
| 41 | android.ModuleBase |
| 42 | android.DefaultableModuleBase |
| 43 | testSuiteProperties |
| 44 | } |
| 45 | |
| 46 | func (t *testSuiteModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Weijia He | aa37c16 | 2024-11-06 19:46:03 +0000 | [diff] [blame^] | 47 | 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 He | 32282f6 | 2024-11-05 22:21:04 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | func 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 | } |