blob: a95e5899ba075bec5bac0091fae9fabfb802f5a9 [file] [log] [blame]
Sasha Smundakff36da02019-02-12 17:12:08 -08001// Copyright 2018 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 (
Sasha Smundakff36da02019-02-12 17:12:08 -080018 "testing"
19)
20
21func testVtsConfig(test *testing.T, bpFileContents string) *TestContext {
Colin Cross98be1bb2019-12-13 20:41:13 -080022 config := TestArchConfig(buildDir, nil, bpFileContents, nil)
Sasha Smundakff36da02019-02-12 17:12:08 -080023
24 ctx := NewTestArchContext()
Colin Cross4b49b762019-11-22 15:25:03 -080025 ctx.RegisterModuleType("vts_config", VtsConfigFactory)
Colin Cross98be1bb2019-12-13 20:41:13 -080026 ctx.Register(config)
Sasha Smundakff36da02019-02-12 17:12:08 -080027 _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
28 FailIfErrored(test, errs)
29 _, errs = ctx.PrepareBuildActions(config)
30 FailIfErrored(test, errs)
31 return ctx
32}
33
34func TestVtsConfig(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070035 t.Parallel()
Sasha Smundakff36da02019-02-12 17:12:08 -080036 ctx := testVtsConfig(t, `
37vts_config { name: "plain"}
38vts_config { name: "with_manifest", test_config: "manifest.xml" }
39`)
40
41 variants := ctx.ModuleVariantsForTests("plain")
42 if len(variants) > 1 {
43 t.Errorf("expected 1, got %d", len(variants))
44 }
45 expectedOutputFilename := ctx.ModuleForTests(
46 "plain", variants[0]).Module().(*VtsConfig).OutputFilePath.Base()
47 if expectedOutputFilename != "plain" {
48 t.Errorf("expected plain, got %q", expectedOutputFilename)
49 }
50}