• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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 sysprop
16
17import (
18	"testing"
19
20	"android/soong/bp2build"
21)
22
23func TestSyspropLibrarySimple(t *testing.T) {
24	bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{
25		Description:                "sysprop_library simple",
26		ModuleTypeUnderTest:        "sysprop_library",
27		ModuleTypeUnderTestFactory: syspropLibraryFactory,
28		Filesystem: map[string]string{
29			"foo.sysprop": "",
30			"bar.sysprop": "",
31		},
32		Blueprint: `
33sysprop_library {
34	name: "sysprop_foo",
35	srcs: [
36		"foo.sysprop",
37		"bar.sysprop",
38	],
39	property_owner: "Platform",
40}
41`,
42		ExpectedBazelTargets: []string{
43			bp2build.MakeBazelTargetNoRestrictions("sysprop_library",
44				"sysprop_foo",
45				bp2build.AttrNameToString{
46					"srcs": `[
47        "foo.sysprop",
48        "bar.sysprop",
49    ]`,
50				}),
51			bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared",
52				"libsysprop_foo",
53				bp2build.AttrNameToString{
54					"dep": `":sysprop_foo"`,
55				}),
56			bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static",
57				"libsysprop_foo_bp2build_cc_library_static",
58				bp2build.AttrNameToString{
59					"dep": `":sysprop_foo"`,
60				}),
61		},
62	})
63}
64
65func TestSyspropLibraryCppMinSdkVersion(t *testing.T) {
66	bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{
67		Description:                "sysprop_library with min_sdk_version",
68		ModuleTypeUnderTest:        "sysprop_library",
69		ModuleTypeUnderTestFactory: syspropLibraryFactory,
70		Filesystem: map[string]string{
71			"foo.sysprop": "",
72			"bar.sysprop": "",
73		},
74		Blueprint: `
75sysprop_library {
76	name: "sysprop_foo",
77	srcs: [
78		"foo.sysprop",
79		"bar.sysprop",
80	],
81	cpp: {
82		min_sdk_version: "5",
83	},
84	property_owner: "Platform",
85}
86`,
87		ExpectedBazelTargets: []string{
88			bp2build.MakeBazelTargetNoRestrictions("sysprop_library",
89				"sysprop_foo",
90				bp2build.AttrNameToString{
91					"srcs": `[
92        "foo.sysprop",
93        "bar.sysprop",
94    ]`,
95				}),
96			bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared",
97				"libsysprop_foo",
98				bp2build.AttrNameToString{
99					"dep":             `":sysprop_foo"`,
100					"min_sdk_version": `"5"`,
101				}),
102			bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static",
103				"libsysprop_foo_bp2build_cc_library_static",
104				bp2build.AttrNameToString{
105					"dep":             `":sysprop_foo"`,
106					"min_sdk_version": `"5"`,
107				}),
108		},
109	})
110}
111