Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 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 | |
| 15 | package sysprop |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/bp2build" |
| 21 | ) |
| 22 | |
| 23 | func 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: ` |
| 33 | sysprop_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", |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 44 | "sysprop_foo", |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 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{ |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 54 | "dep": `":sysprop_foo"`, |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 55 | }), |
| 56 | bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", |
| 57 | "libsysprop_foo_bp2build_cc_library_static", |
| 58 | bp2build.AttrNameToString{ |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 59 | "dep": `":sysprop_foo"`, |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 60 | }), |
| 61 | }, |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | func 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: ` |
| 75 | sysprop_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", |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 89 | "sysprop_foo", |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 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{ |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 99 | "dep": `":sysprop_foo"`, |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 100 | "min_sdk_version": `"5"`, |
| 101 | }), |
| 102 | bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static", |
| 103 | "libsysprop_foo_bp2build_cc_library_static", |
| 104 | bp2build.AttrNameToString{ |
Trevor Radcliffe | cee4e05 | 2022-09-06 19:31:25 +0000 | [diff] [blame^] | 105 | "dep": `":sysprop_foo"`, |
Trevor Radcliffe | ad3d123 | 2022-09-01 16:25:10 +0000 | [diff] [blame] | 106 | "min_sdk_version": `"5"`, |
| 107 | }), |
| 108 | }, |
| 109 | }) |
| 110 | } |