1// 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 ( 18 "testing" 19) 20 21func testVtsConfig(test *testing.T, bpFileContents string) *TestContext { 22 config := TestArchConfig(buildDir, nil, bpFileContents, nil) 23 24 ctx := NewTestArchContext() 25 ctx.RegisterModuleType("vts_config", VtsConfigFactory) 26 ctx.Register(config) 27 _, 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) { 35 ctx := testVtsConfig(t, ` 36vts_config { name: "plain"} 37vts_config { name: "with_manifest", test_config: "manifest.xml" } 38`) 39 40 variants := ctx.ModuleVariantsForTests("plain") 41 if len(variants) > 1 { 42 t.Errorf("expected 1, got %d", len(variants)) 43 } 44 expectedOutputFilename := ctx.ModuleForTests( 45 "plain", variants[0]).Module().(*VtsConfig).OutputFilePath.Base() 46 if expectedOutputFilename != "plain" { 47 t.Errorf("expected plain, got %q", expectedOutputFilename) 48 } 49} 50