blob: 4662af4c1fbf10c40ca180165d32cdbb8492ce4c [file] [log] [blame]
Liz Kammer45faf8f2022-06-02 16:00:54 -04001// Copyright 2022 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 bp2build
16
17import (
18 "fmt"
19 "testing"
20
21 "android/soong/linkerconfig"
22)
23
24func runLinkerConfigTestCase(t *testing.T, tc bp2buildTestCase) {
25 t.Helper()
26 (&tc).moduleTypeUnderTest = "linker_config"
27 (&tc).moduleTypeUnderTestFactory = linkerconfig.LinkerConfigFactory
28 runBp2BuildTestCaseSimple(t, tc)
29}
30
31func TestLinkerConfigConvertsSrc(t *testing.T) {
32 runLinkerConfigTestCase(t,
33 bp2buildTestCase{
34 blueprint: `
35linker_config {
36 name: "foo",
37 src: "a.json",
38}
39`,
40 expectedBazelTargets: []string{makeBazelTarget("linker_config", "foo", attrNameToString{
41 "src": `"a.json"`,
42 })},
43 })
44
45}
46
47func TestLinkerConfigNoSrc(t *testing.T) {
48 runLinkerConfigTestCase(t,
49 bp2buildTestCase{
50 blueprint: `
51linker_config {
52 name: "foo",
53}
54`,
55 expectedBazelTargets: []string{},
56 expectedErr: fmt.Errorf("Android.bp:2:1: module \"foo\": src: empty src is not supported"),
57 })
58
59}