blob: 142b2f5912e8b4d9101c34c8f19774554b18ad74 [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 {
Sasha Smundakff36da02019-02-12 17:12:08 -080022 config := TestArchConfig(buildDir, nil)
Sasha Smundakff36da02019-02-12 17:12:08 -080023
24 ctx := NewTestArchContext()
25 ctx.RegisterModuleType("vts_config", ModuleFactoryAdaptor(VtsConfigFactory))
26 ctx.Register()
27 mockFiles := map[string][]byte{
28 "Android.bp": []byte(bpFileContents),
29 }
30 ctx.MockFileSystem(mockFiles)
31 _, errs := ctx.ParseFileList(".", []string{"Android.bp"})
32 FailIfErrored(test, errs)
33 _, errs = ctx.PrepareBuildActions(config)
34 FailIfErrored(test, errs)
35 return ctx
36}
37
38func TestVtsConfig(t *testing.T) {
39 ctx := testVtsConfig(t, `
40vts_config { name: "plain"}
41vts_config { name: "with_manifest", test_config: "manifest.xml" }
42`)
43
44 variants := ctx.ModuleVariantsForTests("plain")
45 if len(variants) > 1 {
46 t.Errorf("expected 1, got %d", len(variants))
47 }
48 expectedOutputFilename := ctx.ModuleForTests(
49 "plain", variants[0]).Module().(*VtsConfig).OutputFilePath.Base()
50 if expectedOutputFilename != "plain" {
51 t.Errorf("expected plain, got %q", expectedOutputFilename)
52 }
53}