karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 1 | // 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 | |
| 15 | package android |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | func testCSuiteConfig(test *testing.T, bpFileContents string) *TestContext { |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 22 | config := TestArchConfig(buildDir, nil, bpFileContents, nil) |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 23 | |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 24 | ctx := NewTestArchContext(config) |
Colin Cross | 4b49b76 | 2019-11-22 15:25:03 -0800 | [diff] [blame] | 25 | ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory) |
Colin Cross | ae8600b | 2020-10-29 17:09:13 -0700 | [diff] [blame] | 26 | ctx.Register() |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 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 | |
| 34 | func TestCSuiteConfig(t *testing.T) { |
karenluo | c031819 | 2019-10-10 21:26:26 -0400 | [diff] [blame] | 35 | ctx := testCSuiteConfig(t, ` |
| 36 | csuite_config { name: "plain"} |
| 37 | csuite_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 | } |