| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 1 | // Copyright 2021 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 bp2build | 
|  | 16 |  | 
|  | 17 | import ( | 
| Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 18 | "fmt" | 
|  | 19 | "testing" | 
|  | 20 |  | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 21 | "android/soong/android" | 
|  | 22 | "android/soong/etc" | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 23 | ) | 
|  | 24 |  | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 25 | func runPrebuiltEtcTestCase(t *testing.T, tc Bp2buildTestCase) { | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 26 | t.Helper() | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 27 | (&tc).ModuleTypeUnderTest = "prebuilt_etc" | 
|  | 28 | (&tc).ModuleTypeUnderTestFactory = etc.PrebuiltEtcFactory | 
| Zi Wang | 0405414 | 2023-10-10 14:49:18 -0700 | [diff] [blame] | 29 | RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc) | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 30 | } | 
|  | 31 |  | 
| Zi Wang | 0405414 | 2023-10-10 14:49:18 -0700 | [diff] [blame] | 32 | func runPrebuiltRootHostTestCase(t *testing.T, tc Bp2buildTestCase) { | 
|  | 33 | t.Helper() | 
|  | 34 | (&tc).ModuleTypeUnderTest = "prebuilt_root_host" | 
|  | 35 | (&tc).ModuleTypeUnderTestFactory = etc.PrebuiltRootHostFactory | 
|  | 36 | RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc) | 
|  | 37 | } | 
|  | 38 |  | 
|  | 39 | func registerPrebuiltModuleTypes(ctx android.RegistrationContext) { | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 40 | } | 
|  | 41 |  | 
|  | 42 | func TestPrebuiltEtcSimple(t *testing.T) { | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 43 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 44 | Description: "prebuilt_etc - simple example", | 
|  | 45 | Filesystem:  map[string]string{}, | 
|  | 46 | Blueprint: ` | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 47 | prebuilt_etc { | 
|  | 48 | name: "apex_tz_version", | 
|  | 49 | src: "version/tz_version", | 
|  | 50 | filename: "tz_version", | 
|  | 51 | sub_dir: "tz", | 
|  | 52 | installable: false, | 
|  | 53 | } | 
|  | 54 | `, | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 55 | ExpectedBazelTargets: []string{ | 
| Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 56 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
| Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 57 | "filename":    `"tz_version"`, | 
|  | 58 | "installable": `False`, | 
|  | 59 | "src":         `"version/tz_version"`, | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 60 | "dir":         `"etc/tz"`, | 
| Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 61 | })}}) | 
| Rupert Shuttleworth | 378fc1b | 2021-07-28 08:03:16 -0400 | [diff] [blame] | 62 | } | 
| Liz Kammer | dff00ea | 2021-10-04 13:44:34 -0400 | [diff] [blame] | 63 |  | 
|  | 64 | func TestPrebuiltEtcArchVariant(t *testing.T) { | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 65 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 66 | Description: "prebuilt_etc - arch variant", | 
|  | 67 | Filesystem:  map[string]string{}, | 
|  | 68 | Blueprint: ` | 
| Liz Kammer | dff00ea | 2021-10-04 13:44:34 -0400 | [diff] [blame] | 69 | prebuilt_etc { | 
|  | 70 | name: "apex_tz_version", | 
|  | 71 | src: "version/tz_version", | 
|  | 72 | filename: "tz_version", | 
|  | 73 | sub_dir: "tz", | 
|  | 74 | installable: false, | 
|  | 75 | arch: { | 
|  | 76 | arm: { | 
|  | 77 | src: "arm", | 
|  | 78 | }, | 
|  | 79 | arm64: { | 
|  | 80 | src: "arm64", | 
|  | 81 | }, | 
|  | 82 | } | 
|  | 83 | } | 
|  | 84 | `, | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 85 | ExpectedBazelTargets: []string{ | 
| Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 86 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
| Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 87 | "filename":    `"tz_version"`, | 
|  | 88 | "installable": `False`, | 
|  | 89 | "src": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 90 | "//build/bazel_common_rules/platforms/arch:arm": "arm", | 
|  | 91 | "//build/bazel_common_rules/platforms/arch:arm64": "arm64", | 
| Liz Kammer | dff00ea | 2021-10-04 13:44:34 -0400 | [diff] [blame] | 92 | "//conditions:default": "version/tz_version", | 
| Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 93 | })`, | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 94 | "dir": `"etc/tz"`, | 
| Liz Kammer | 78cfdaa | 2021-11-08 12:56:31 -0500 | [diff] [blame] | 95 | })}}) | 
| Liz Kammer | dff00ea | 2021-10-04 13:44:34 -0400 | [diff] [blame] | 96 | } | 
| Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 97 |  | 
|  | 98 | func TestPrebuiltEtcArchAndTargetVariant(t *testing.T) { | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 99 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 100 | Description: "prebuilt_etc - arch variant", | 
|  | 101 | Filesystem:  map[string]string{}, | 
|  | 102 | Blueprint: ` | 
| Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 103 | prebuilt_etc { | 
|  | 104 | name: "apex_tz_version", | 
|  | 105 | src: "version/tz_version", | 
|  | 106 | filename: "tz_version", | 
|  | 107 | sub_dir: "tz", | 
|  | 108 | installable: false, | 
|  | 109 | arch: { | 
|  | 110 | arm: { | 
|  | 111 | src: "arm", | 
|  | 112 | }, | 
|  | 113 | arm64: { | 
|  | 114 | src: "darwin_or_arm64", | 
|  | 115 | }, | 
|  | 116 | }, | 
|  | 117 | target: { | 
|  | 118 | darwin: { | 
|  | 119 | src: "darwin_or_arm64", | 
|  | 120 | } | 
|  | 121 | }, | 
|  | 122 | } | 
|  | 123 | `, | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 124 | ExpectedBazelTargets: []string{ | 
| Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 125 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
| Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 126 | "filename":    `"tz_version"`, | 
|  | 127 | "installable": `False`, | 
|  | 128 | "src": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 129 | "//build/bazel_common_rules/platforms/os_arch:android_arm": "arm", | 
|  | 130 | "//build/bazel_common_rules/platforms/os_arch:android_arm64": "darwin_or_arm64", | 
|  | 131 | "//build/bazel_common_rules/platforms/os_arch:darwin_arm64": "darwin_or_arm64", | 
|  | 132 | "//build/bazel_common_rules/platforms/os_arch:darwin_x86_64": "darwin_or_arm64", | 
|  | 133 | "//build/bazel_common_rules/platforms/os_arch:linux_bionic_arm64": "darwin_or_arm64", | 
| Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 134 | "//conditions:default": "version/tz_version", | 
|  | 135 | })`, | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 136 | "dir": `"etc/tz"`, | 
|  | 137 | })}}) | 
|  | 138 | } | 
| Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 139 | func TestPrebuiltEtcProductVariables(t *testing.T) { | 
|  | 140 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 141 | Description: "prebuilt etc - product variables", | 
|  | 142 | Filesystem:  map[string]string{}, | 
|  | 143 | Blueprint: ` | 
|  | 144 | prebuilt_etc { | 
|  | 145 | name: "apex_tz_version", | 
|  | 146 | src: "version/tz_version", | 
|  | 147 | filename: "tz_version", | 
|  | 148 | product_variables: { | 
|  | 149 | native_coverage: { | 
|  | 150 | src: "src1", | 
|  | 151 | }, | 
|  | 152 | }, | 
|  | 153 | } | 
|  | 154 | `, | 
|  | 155 | ExpectedBazelTargets: []string{ | 
|  | 156 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
|  | 157 | "filename": `"tz_version"`, | 
|  | 158 | "src": `select({ | 
| Cole Faust | 87c0c33 | 2023-07-31 12:10:12 -0700 | [diff] [blame] | 159 | "//build/bazel/product_config/config_settings:native_coverage": "src1", | 
| Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 160 | "//conditions:default": "version/tz_version", | 
|  | 161 | })`, | 
|  | 162 | "dir": `"etc"`, | 
|  | 163 | })}}) | 
|  | 164 | } | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 165 |  | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 166 | func runPrebuiltUsrShareTestCase(t *testing.T, tc Bp2buildTestCase) { | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 167 | t.Helper() | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 168 | (&tc).ModuleTypeUnderTest = "prebuilt_usr_share" | 
|  | 169 | (&tc).ModuleTypeUnderTestFactory = etc.PrebuiltUserShareFactory | 
| Zi Wang | 0405414 | 2023-10-10 14:49:18 -0700 | [diff] [blame] | 170 | RunBp2BuildTestCase(t, registerPrebuiltModuleTypes, tc) | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 171 | } | 
|  | 172 |  | 
|  | 173 | func registerPrebuiltUsrShareModuleTypes(ctx android.RegistrationContext) { | 
|  | 174 | } | 
|  | 175 |  | 
|  | 176 | func TestPrebuiltUsrShareSimple(t *testing.T) { | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 177 | runPrebuiltUsrShareTestCase(t, Bp2buildTestCase{ | 
|  | 178 | Description: "prebuilt_usr_share - simple example", | 
|  | 179 | Filesystem:  map[string]string{}, | 
|  | 180 | Blueprint: ` | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 181 | prebuilt_usr_share { | 
|  | 182 | name: "apex_tz_version", | 
|  | 183 | src: "version/tz_version", | 
|  | 184 | filename: "tz_version", | 
|  | 185 | sub_dir: "tz", | 
|  | 186 | installable: false, | 
|  | 187 | } | 
|  | 188 | `, | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 189 | ExpectedBazelTargets: []string{ | 
| Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 190 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 191 | "filename":    `"tz_version"`, | 
|  | 192 | "installable": `False`, | 
|  | 193 | "src":         `"version/tz_version"`, | 
|  | 194 | "dir":         `"usr/share/tz"`, | 
|  | 195 | })}}) | 
|  | 196 | } | 
|  | 197 |  | 
|  | 198 | func TestPrebuiltEtcNoSubdir(t *testing.T) { | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 199 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 200 | Description: "prebuilt_etc - no subdir", | 
|  | 201 | Filesystem:  map[string]string{}, | 
|  | 202 | Blueprint: ` | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 203 | prebuilt_etc { | 
|  | 204 | name: "apex_tz_version", | 
|  | 205 | src: "version/tz_version", | 
|  | 206 | filename: "tz_version", | 
|  | 207 | installable: false, | 
|  | 208 | } | 
|  | 209 | `, | 
| Sam Delmerico | 3177a6e | 2022-06-21 19:28:33 +0000 | [diff] [blame] | 210 | ExpectedBazelTargets: []string{ | 
| Alix | e06d75b | 2022-08-31 18:28:19 +0000 | [diff] [blame] | 211 | MakeBazelTarget("prebuilt_file", "apex_tz_version", AttrNameToString{ | 
| Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | c78604e | 2022-02-28 18:22:59 -0500 | [diff] [blame] | 212 | "filename":    `"tz_version"`, | 
|  | 213 | "installable": `False`, | 
|  | 214 | "src":         `"version/tz_version"`, | 
|  | 215 | "dir":         `"etc"`, | 
| Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 216 | })}}) | 
|  | 217 | } | 
| Alix | 993872a | 2022-06-15 17:42:14 +0000 | [diff] [blame] | 218 |  | 
|  | 219 | func TestFilenameAsProperty(t *testing.T) { | 
|  | 220 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 221 | Description: "prebuilt_etc - filename is specified as a property ", | 
|  | 222 | Filesystem:  map[string]string{}, | 
|  | 223 | Blueprint: ` | 
|  | 224 | prebuilt_etc { | 
|  | 225 | name: "foo", | 
|  | 226 | src: "fooSrc", | 
|  | 227 | filename: "fooFileName", | 
|  | 228 | } | 
|  | 229 | `, | 
|  | 230 | ExpectedBazelTargets: []string{ | 
|  | 231 | MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{ | 
|  | 232 | "filename": `"fooFileName"`, | 
|  | 233 | "src":      `"fooSrc"`, | 
|  | 234 | "dir":      `"etc"`, | 
|  | 235 | })}}) | 
|  | 236 | } | 
|  | 237 |  | 
|  | 238 | func TestFileNameFromSrc(t *testing.T) { | 
|  | 239 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 240 | Description: "prebuilt_etc - filename_from_src is true  ", | 
|  | 241 | Filesystem:  map[string]string{}, | 
|  | 242 | Blueprint: ` | 
|  | 243 | prebuilt_etc { | 
|  | 244 | name: "foo", | 
|  | 245 | filename_from_src: true, | 
|  | 246 | src: "fooSrc", | 
|  | 247 | } | 
|  | 248 | `, | 
|  | 249 | ExpectedBazelTargets: []string{ | 
|  | 250 | MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{ | 
|  | 251 | "filename": `"fooSrc"`, | 
|  | 252 | "src":      `"fooSrc"`, | 
|  | 253 | "dir":      `"etc"`, | 
|  | 254 | })}}) | 
|  | 255 | } | 
|  | 256 |  | 
|  | 257 | func TestFileNameFromSrcMultipleSrcs(t *testing.T) { | 
|  | 258 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 259 | Description: "prebuilt_etc - filename_from_src is true but there are multiple srcs", | 
|  | 260 | Filesystem:  map[string]string{}, | 
|  | 261 | Blueprint: ` | 
|  | 262 | prebuilt_etc { | 
|  | 263 | name: "foo", | 
|  | 264 | filename_from_src: true, | 
|  | 265 | arch: { | 
|  | 266 | arm: { | 
|  | 267 | src: "barSrc", | 
|  | 268 | }, | 
|  | 269 | arm64: { | 
|  | 270 | src: "bazSrc", | 
|  | 271 | }, | 
|  | 272 | } | 
|  | 273 | } | 
|  | 274 | `, | 
|  | 275 | ExpectedBazelTargets: []string{ | 
|  | 276 | MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{ | 
|  | 277 | "filename_from_src": `True`, | 
|  | 278 | "dir":               `"etc"`, | 
|  | 279 | "src": `select({ | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 280 | "//build/bazel_common_rules/platforms/arch:arm": "barSrc", | 
|  | 281 | "//build/bazel_common_rules/platforms/arch:arm64": "bazSrc", | 
| Alix | 993872a | 2022-06-15 17:42:14 +0000 | [diff] [blame] | 282 | "//conditions:default": None, | 
|  | 283 | })`, | 
|  | 284 | })}}) | 
|  | 285 | } | 
|  | 286 |  | 
|  | 287 | func TestFilenameFromModuleName(t *testing.T) { | 
|  | 288 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 289 | Description: "prebuilt_etc - neither filename nor filename_from_src are specified ", | 
|  | 290 | Filesystem:  map[string]string{}, | 
|  | 291 | Blueprint: ` | 
|  | 292 | prebuilt_etc { | 
|  | 293 | name: "foo", | 
|  | 294 | } | 
|  | 295 | `, | 
|  | 296 | ExpectedBazelTargets: []string{ | 
|  | 297 | MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{ | 
|  | 298 | "filename": `"foo"`, | 
|  | 299 | "dir":      `"etc"`, | 
|  | 300 | })}}) | 
|  | 301 | } | 
| Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 302 |  | 
|  | 303 | func TestPrebuiltEtcProductVariableArchSrcs(t *testing.T) { | 
|  | 304 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 305 | Description: "prebuilt etc- SRcs from arch variant product variables", | 
|  | 306 | Filesystem:  map[string]string{}, | 
|  | 307 | Blueprint: ` | 
|  | 308 | prebuilt_etc { | 
|  | 309 | name: "foo", | 
|  | 310 | filename: "fooFilename", | 
|  | 311 | arch: { | 
|  | 312 | arm: { | 
|  | 313 | src: "armSrc", | 
|  | 314 | product_variables: { | 
|  | 315 | native_coverage: { | 
|  | 316 | src: "nativeCoverageArmSrc", | 
|  | 317 | }, | 
|  | 318 | }, | 
|  | 319 | }, | 
|  | 320 | }, | 
|  | 321 | }`, | 
|  | 322 | ExpectedBazelTargets: []string{ | 
|  | 323 | MakeBazelTarget("prebuilt_file", "foo", AttrNameToString{ | 
|  | 324 | "filename": `"fooFilename"`, | 
|  | 325 | "dir":      `"etc"`, | 
|  | 326 | "src": `select({ | 
| Cole Faust | 87c0c33 | 2023-07-31 12:10:12 -0700 | [diff] [blame] | 327 | "//build/bazel/product_config/config_settings:native_coverage-arm": "nativeCoverageArmSrc", | 
| Jingwen Chen | 9c2e3ee | 2023-10-11 10:51:28 +0000 | [diff] [blame] | 328 | "//build/bazel_common_rules/platforms/arch:arm": "armSrc", | 
| Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 329 | "//conditions:default": None, | 
|  | 330 | })`, | 
|  | 331 | })}}) | 
|  | 332 | } | 
|  | 333 |  | 
|  | 334 | func TestPrebuiltEtcProductVariableError(t *testing.T) { | 
|  | 335 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 336 | Description: "", | 
|  | 337 | Filesystem:  map[string]string{}, | 
|  | 338 | Blueprint: ` | 
|  | 339 | prebuilt_etc { | 
|  | 340 | name: "foo", | 
|  | 341 | filename: "fooFilename", | 
|  | 342 | arch: { | 
|  | 343 | arm: { | 
|  | 344 | src: "armSrc", | 
|  | 345 | }, | 
|  | 346 | }, | 
|  | 347 | product_variables: { | 
|  | 348 | native_coverage: { | 
|  | 349 | src: "nativeCoverageArmSrc", | 
|  | 350 | }, | 
|  | 351 | }, | 
|  | 352 | }`, | 
|  | 353 | ExpectedErr: fmt.Errorf("label attribute could not be collapsed"), | 
|  | 354 | }) | 
|  | 355 | } | 
| Liz Kammer | d5d12d0 | 2023-09-05 09:18:50 -0400 | [diff] [blame] | 356 |  | 
|  | 357 | func TestPrebuiltEtcNoConversionIfSrcEqualsName(t *testing.T) { | 
|  | 358 | runPrebuiltEtcTestCase(t, Bp2buildTestCase{ | 
|  | 359 | Description: "", | 
|  | 360 | Filesystem:  map[string]string{}, | 
|  | 361 | Blueprint: ` | 
|  | 362 | prebuilt_etc { | 
|  | 363 | name: "foo", | 
|  | 364 | filename: "fooFilename", | 
|  | 365 | src: "foo", | 
|  | 366 | }`, | 
|  | 367 | ExpectedBazelTargets: []string{}, | 
|  | 368 | }) | 
|  | 369 | } | 
| Zi Wang | 0405414 | 2023-10-10 14:49:18 -0700 | [diff] [blame] | 370 |  | 
|  | 371 | func TestPrebuiltRootHostWithWildCardInSrc(t *testing.T) { | 
|  | 372 | runPrebuiltRootHostTestCase(t, Bp2buildTestCase{ | 
|  | 373 | Description: "prebuilt_root_host - src string has wild card", | 
|  | 374 | Filesystem: map[string]string{ | 
|  | 375 | "prh.dat": "", | 
|  | 376 | }, | 
|  | 377 | Blueprint: ` | 
|  | 378 | prebuilt_root_host { | 
|  | 379 | name: "prh_test", | 
|  | 380 | src: "*.dat", | 
|  | 381 | filename_from_src: true, | 
|  | 382 | relative_install_path: "test/install/path", | 
|  | 383 | bazel_module: { bp2build_available: true }, | 
|  | 384 | } | 
|  | 385 | `, | 
|  | 386 | ExpectedBazelTargets: []string{ | 
|  | 387 | MakeBazelTarget("prebuilt_file", "prh_test", AttrNameToString{ | 
|  | 388 | "filename": `"prh.dat"`, | 
|  | 389 | "src":      `"prh.dat"`, | 
|  | 390 | "dir":      `"./test/install/path"`, | 
|  | 391 | "target_compatible_with": `select({ | 
| Zi Wang | 7d54b3a | 2023-10-12 10:25:31 -0700 | [diff] [blame] | 392 | "//build/bazel_common_rules/platforms/os:android": ["@platforms//:incompatible"], | 
| Zi Wang | 0405414 | 2023-10-10 14:49:18 -0700 | [diff] [blame] | 393 | "//conditions:default": [], | 
|  | 394 | })`, | 
|  | 395 | })}}) | 
|  | 396 | } |