blob: 77fb9fed93aee6a4f7fa78e19ce44c5acc1f4860 [file] [log] [blame]
Sasha Smundakff36da02019-02-12 17:12:08 -08001// 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
15package android
16
17import (
18 "fmt"
19 "io"
Dan Shi403c9d32020-02-13 14:49:33 -080020 "strings"
Sasha Smundakff36da02019-02-12 17:12:08 -080021)
22
Sasha Smundakff36da02019-02-12 17:12:08 -080023func init() {
24 RegisterModuleType("vts_config", VtsConfigFactory)
25}
26
27type vtsConfigProperties struct {
Patrice Arruda3cec2722019-03-13 14:01:12 -070028 // Override the default (AndroidTest.xml) test manifest file name.
Sasha Smundakff36da02019-02-12 17:12:08 -080029 Test_config *string
Dan Shi403c9d32020-02-13 14:49:33 -080030 // Additional test suites to add the test to.
31 Test_suites []string `android:"arch_variant"`
Sasha Smundakff36da02019-02-12 17:12:08 -080032}
33
34type VtsConfig struct {
35 ModuleBase
36 properties vtsConfigProperties
37 OutputFilePath OutputPath
38}
39
40func (me *VtsConfig) GenerateAndroidBuildActions(ctx ModuleContext) {
41 me.OutputFilePath = PathForModuleOut(ctx, me.BaseModuleName()).OutputPath
42}
43
44func (me *VtsConfig) AndroidMk() AndroidMkData {
45 androidMkData := AndroidMkData{
46 Class: "FAKE",
karenluoc0318192019-10-10 21:26:26 -040047 Include: "$(BUILD_SYSTEM)/suite_host_config.mk",
Sasha Smundakff36da02019-02-12 17:12:08 -080048 OutputFile: OptionalPathForPath(me.OutputFilePath),
49 }
karenluoc0318192019-10-10 21:26:26 -040050 androidMkData.Extra = []AndroidMkExtraFunc{
51 func(w io.Writer, outputFile Path) {
52 if me.properties.Test_config != nil {
Sasha Smundakff36da02019-02-12 17:12:08 -080053 fmt.Fprintf(w, "LOCAL_TEST_CONFIG := %s\n",
54 *me.properties.Test_config)
karenluoc0318192019-10-10 21:26:26 -040055 }
Dan Shi984c1292020-03-18 22:42:00 -070056 fmt.Fprintf(w, "LOCAL_COMPATIBILITY_SUITE := vts10 %s\n",
Dan Shi403c9d32020-02-13 14:49:33 -080057 strings.Join(me.properties.Test_suites, " "))
karenluoc0318192019-10-10 21:26:26 -040058 },
Sasha Smundakff36da02019-02-12 17:12:08 -080059 }
60 return androidMkData
61}
62
63func InitVtsConfigModule(me *VtsConfig) {
64 me.AddProperties(&me.properties)
65}
66
Dan Shi984c1292020-03-18 22:42:00 -070067// vts_config generates a Vendor Test Suite (VTS10) configuration file from the
Patrice Arruda3cec2722019-03-13 14:01:12 -070068// <test_config> xml file and stores it in a subdirectory of $(HOST_OUT).
Sasha Smundakff36da02019-02-12 17:12:08 -080069func VtsConfigFactory() Module {
70 module := &VtsConfig{}
71 InitVtsConfigModule(module)
72 InitAndroidArchModule(module /*TODO: or HostAndDeviceSupported? */, HostSupported, MultilibFirst)
73 return module
74}