blob: 9ac959e1896f9c48aa6eaacc35235261ae2c500b [file] [log] [blame]
karenluoc0318192019-10-10 21:26:26 -04001// Copyright 2019 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 testCSuiteConfig(test *testing.T, bpFileContents string) *TestContext {
Colin Cross98be1bb2019-12-13 20:41:13 -080022 config := TestArchConfig(buildDir, nil, bpFileContents, nil)
karenluoc0318192019-10-10 21:26:26 -040023
Colin Crossae8600b2020-10-29 17:09:13 -070024 ctx := NewTestArchContext(config)
Colin Cross4b49b762019-11-22 15:25:03 -080025 ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
Colin Crossae8600b2020-10-29 17:09:13 -070026 ctx.Register()
karenluoc0318192019-10-10 21:26:26 -040027 _, 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 TestCSuiteConfig(t *testing.T) {
karenluoc0318192019-10-10 21:26:26 -040035 ctx := testCSuiteConfig(t, `
36csuite_config { name: "plain"}
37csuite_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().(*CSuiteConfig).OutputFilePath.Base()
46 if expectedOutputFilename != "plain" {
47 t.Errorf("expected plain, got %q", expectedOutputFilename)
48 }
49}