Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 1 | // Copyright 2016 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 android |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "io" |
Dan Shi | 403c9d3 | 2020-02-13 14:49:33 -0800 | [diff] [blame] | 20 | "strings" |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 21 | ) |
| 22 | |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 23 | func init() { |
| 24 | RegisterModuleType("vts_config", VtsConfigFactory) |
| 25 | } |
| 26 | |
| 27 | type vtsConfigProperties struct { |
Patrice Arruda | 3cec272 | 2019-03-13 14:01:12 -0700 | [diff] [blame] | 28 | // Override the default (AndroidTest.xml) test manifest file name. |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 29 | Test_config *string |
Dan Shi | 403c9d3 | 2020-02-13 14:49:33 -0800 | [diff] [blame] | 30 | // Additional test suites to add the test to. |
| 31 | Test_suites []string `android:"arch_variant"` |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | type VtsConfig struct { |
| 35 | ModuleBase |
| 36 | properties vtsConfigProperties |
| 37 | OutputFilePath OutputPath |
| 38 | } |
| 39 | |
| 40 | func (me *VtsConfig) GenerateAndroidBuildActions(ctx ModuleContext) { |
| 41 | me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath |
| 42 | } |
| 43 | |
| 44 | func (me *VtsConfig) AndroidMk() AndroidMkData { |
| 45 | androidMkData := AndroidMkData{ |
| 46 | Class: "FAKE", |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 47 | Include: "$(BUILD_SYSTEM)/suite_host_config.mk", |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 48 | OutputFile: OptionalPathForPath(me.OutputFilePath), |
| 49 | } |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 50 | androidMkData.Extra = []AndroidMkExtraFunc{ |
| 51 | func(w io.Writer, outputFile Path) { |
| 52 | if me.properties.Test_config != nil { |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 53 | fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n", |
| 54 | *me.properties.Test_config) |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 55 | } |
Dan Shi | 984c129 | 2020-03-18 22:42:00 -0700 | [diff] [blame] | 56 | fmt.Fprintf(w, "LOCAL_COMPATIBILITY_SUITE := vts10 %s\n", |
Dan Shi | 403c9d3 | 2020-02-13 14:49:33 -0800 | [diff] [blame] | 57 | strings.Join(me.properties.Test_suites, " ")) |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 58 | }, |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 59 | } |
| 60 | return androidMkData |
| 61 | } |
| 62 | |
| 63 | func InitVtsConfigModule(me *VtsConfig) { |
| 64 | me.AddProperties(&me.properties) |
| 65 | } |
| 66 | |
Dan Shi | 984c129 | 2020-03-18 22:42:00 -0700 | [diff] [blame] | 67 | // vts_config generates a Vendor Test Suite (VTS10) configuration file from the |
Patrice Arruda | 3cec272 | 2019-03-13 14:01:12 -0700 | [diff] [blame] | 68 | // <test_config> xml file and stores it in a subdirectory of $(HOST_OUT). |
Sasha Smundak | ff36da0 | 2019-02-12 17:12:08 -0800 | [diff] [blame] | 69 | func VtsConfigFactory() Module { |
| 70 | module := &VtsConfig{} |
| 71 | InitVtsConfigModule(module) |
| 72 | InitAndroidArchModule(module /*TODO: or HostAndDeviceSupported? */, HostSupported, MultilibFirst) |
| 73 | return module |
| 74 | } |