Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 1 | // Copyright 2021 The Android Open Source Project |
| 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 rust |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "path/filepath" |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 20 | "reflect" |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 21 | "strings" |
| 22 | "testing" |
| 23 | |
| 24 | "android/soong/android" |
| 25 | "android/soong/cc" |
| 26 | ) |
| 27 | |
| 28 | func TestVendorSnapshotCapture(t *testing.T) { |
| 29 | bp := ` |
| 30 | rust_ffi { |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 31 | name: "libffivendor_available", |
| 32 | crate_name: "ffivendor_available", |
| 33 | srcs: ["lib.rs"], |
| 34 | vendor_available: true, |
| 35 | include_dirs: ["rust_headers/"], |
| 36 | } |
| 37 | |
| 38 | rust_ffi { |
| 39 | name: "libffivendor", |
| 40 | crate_name: "ffivendor", |
| 41 | srcs: ["lib.rs"], |
| 42 | vendor: true, |
| 43 | include_dirs: ["rust_headers/"], |
| 44 | } |
| 45 | |
| 46 | rust_library { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 47 | name: "librustvendor_available", |
| 48 | crate_name: "rustvendor_available", |
| 49 | srcs: ["lib.rs"], |
| 50 | vendor_available: true, |
| 51 | include_dirs: ["rust_headers/"], |
| 52 | } |
| 53 | |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 54 | rust_library_rlib { |
| 55 | name: "librustvendor", |
| 56 | crate_name: "rustvendor", |
| 57 | srcs: ["lib.rs"], |
| 58 | vendor: true, |
| 59 | include_dirs: ["rust_headers/"], |
| 60 | } |
| 61 | |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 62 | rust_binary { |
| 63 | name: "vendor_available_bin", |
| 64 | vendor_available: true, |
| 65 | srcs: ["srcs/lib.rs"], |
| 66 | } |
| 67 | |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 68 | rust_binary { |
| 69 | name: "vendor_bin", |
| 70 | vendor: true, |
| 71 | srcs: ["srcs/lib.rs"], |
| 72 | } |
| 73 | ` |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 74 | skipTestIfOsNotSupported(t) |
| 75 | result := android.GroupFixturePreparers( |
| 76 | prepareForRustTest, |
| 77 | rustMockedFiles.AddToFixture(), |
| 78 | android.FixtureModifyProductVariables( |
| 79 | func(variables android.FixtureProductVariables) { |
| 80 | variables.DeviceVndkVersion = StringPtr("current") |
| 81 | variables.Platform_vndk_version = StringPtr("29") |
| 82 | }, |
| 83 | ), |
| 84 | ).RunTestWithBp(t, bp) |
| 85 | ctx := result.TestContext |
| 86 | |
| 87 | // Check Vendor snapshot output. |
| 88 | |
| 89 | snapshotDir := "vendor-snapshot" |
| 90 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
| 91 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 92 | var jsonFiles []string |
| 93 | for _, arch := range [][]string{ |
| 94 | []string{"arm64", "armv8-a"}, |
| 95 | []string{"arm", "armv7-a-neon"}, |
| 96 | } { |
| 97 | archType := arch[0] |
| 98 | archVariant := arch[1] |
| 99 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 100 | |
| 101 | // For shared libraries, only non-VNDK vendor_available modules are captured |
| 102 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
| 103 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 104 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "libffivendor_available", "libffivendor_available.so", sharedDir, sharedVariant) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 105 | jsonFiles = append(jsonFiles, |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 106 | filepath.Join(sharedDir, "libffivendor_available.so.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 107 | |
| 108 | // For static libraries, all vendor:true and vendor_available modules (including VNDK) are captured. |
| 109 | staticVariant := fmt.Sprintf("android_vendor.29_%s_%s_static", archType, archVariant) |
| 110 | staticDir := filepath.Join(snapshotVariantPath, archDir, "static") |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 111 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "libffivendor_available", "libffivendor_available.a", staticDir, staticVariant) |
| 112 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "libffivendor", "libffivendor.a", staticDir, staticVariant) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 113 | jsonFiles = append(jsonFiles, |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 114 | filepath.Join(staticDir, "libffivendor_available.a.json")) |
| 115 | jsonFiles = append(jsonFiles, |
| 116 | filepath.Join(staticDir, "libffivendor.a.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 117 | |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 118 | // For rlib libraries, all vendor:true and vendor_available modules (including VNDK) are captured. |
| 119 | rlibVariant := fmt.Sprintf("android_vendor.29_%s_%s_rlib_rlib-std", archType, archVariant) |
| 120 | rlibDir := filepath.Join(snapshotVariantPath, archDir, "rlib") |
| 121 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "librustvendor_available", "librustvendor_available.rlib", rlibDir, rlibVariant) |
| 122 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "librustvendor", "librustvendor.rlib", rlibDir, rlibVariant) |
| 123 | jsonFiles = append(jsonFiles, |
| 124 | filepath.Join(rlibDir, "librustvendor_available.rlib.json")) |
| 125 | jsonFiles = append(jsonFiles, |
| 126 | filepath.Join(rlibDir, "librustvendor.rlib.json")) |
| 127 | |
| 128 | // For binary executables, all vendor:true and vendor_available modules are captured. |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 129 | if archType == "arm64" { |
| 130 | binaryVariant := fmt.Sprintf("android_vendor.29_%s_%s", archType, archVariant) |
| 131 | binaryDir := filepath.Join(snapshotVariantPath, archDir, "binary") |
| 132 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "vendor_available_bin", "vendor_available_bin", binaryDir, binaryVariant) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 133 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "vendor_bin", "vendor_bin", binaryDir, binaryVariant) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 134 | jsonFiles = append(jsonFiles, |
| 135 | filepath.Join(binaryDir, "vendor_available_bin.json")) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 136 | jsonFiles = append(jsonFiles, |
| 137 | filepath.Join(binaryDir, "vendor_bin.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
| 141 | for _, jsonFile := range jsonFiles { |
| 142 | // verify all json files exist |
| 143 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 144 | t.Errorf("%q expected but not found; #%v", jsonFile, jsonFiles) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | // fake snapshot should have all outputs in the normal snapshot. |
| 149 | fakeSnapshotSingleton := ctx.SingletonForTests("vendor-fake-snapshot") |
| 150 | |
| 151 | for _, output := range snapshotSingleton.AllOutputs() { |
| 152 | fakeOutput := strings.Replace(output, "/vendor-snapshot/", "/fake/vendor-snapshot/", 1) |
| 153 | if fakeSnapshotSingleton.MaybeOutput(fakeOutput).Rule == nil { |
| 154 | t.Errorf("%q expected but not found", fakeOutput) |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | func TestVendorSnapshotDirected(t *testing.T) { |
| 160 | bp := ` |
| 161 | rust_ffi_shared { |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 162 | name: "libffivendor_available", |
| 163 | crate_name: "ffivendor_available", |
| 164 | srcs: ["lib.rs"], |
| 165 | vendor_available: true, |
| 166 | } |
| 167 | |
| 168 | rust_library { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 169 | name: "librustvendor_available", |
| 170 | crate_name: "rustvendor_available", |
| 171 | srcs: ["lib.rs"], |
| 172 | vendor_available: true, |
| 173 | } |
| 174 | |
| 175 | rust_ffi_shared { |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 176 | name: "libffivendor_exclude", |
| 177 | crate_name: "ffivendor_exclude", |
| 178 | srcs: ["lib.rs"], |
| 179 | vendor_available: true, |
| 180 | } |
| 181 | |
| 182 | rust_library { |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 183 | name: "librustvendor_exclude", |
| 184 | crate_name: "rustvendor_exclude", |
| 185 | srcs: ["lib.rs"], |
| 186 | vendor_available: true, |
| 187 | } |
| 188 | ` |
| 189 | ctx := testRustVndk(t, bp) |
| 190 | ctx.Config().TestProductVariables.VendorSnapshotModules = make(map[string]bool) |
| 191 | ctx.Config().TestProductVariables.VendorSnapshotModules["librustvendor_available"] = true |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 192 | ctx.Config().TestProductVariables.VendorSnapshotModules["libffivendor_available"] = true |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 193 | ctx.Config().TestProductVariables.DirectedVendorSnapshot = true |
| 194 | |
| 195 | // Check Vendor snapshot output. |
| 196 | |
| 197 | snapshotDir := "vendor-snapshot" |
| 198 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
| 199 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 200 | |
| 201 | var includeJsonFiles []string |
| 202 | |
| 203 | for _, arch := range [][]string{ |
| 204 | []string{"arm64", "armv8-a"}, |
| 205 | []string{"arm", "armv7-a-neon"}, |
| 206 | } { |
| 207 | archType := arch[0] |
| 208 | archVariant := arch[1] |
| 209 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 210 | |
| 211 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 212 | rlibVariant := fmt.Sprintf("android_vendor.29_%s_%s_rlib_rlib-std", archType, archVariant) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 213 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 214 | rlibDir := filepath.Join(snapshotVariantPath, archDir, "rlib") |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 215 | |
| 216 | // Included modules |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 217 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "librustvendor_available", "librustvendor_available.rlib", rlibDir, rlibVariant) |
| 218 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "libffivendor_available", "libffivendor_available.so", sharedDir, sharedVariant) |
| 219 | includeJsonFiles = append(includeJsonFiles, filepath.Join(rlibDir, "librustvendor_available.rlib.json")) |
| 220 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libffivendor_available.so.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 221 | |
| 222 | // Excluded modules. Modules not included in the directed vendor snapshot |
| 223 | // are still include as fake modules. |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 224 | cc.CheckSnapshotRule(t, ctx, snapshotSingleton, "librustvendor_exclude", "librustvendor_exclude.rlib", rlibDir, rlibVariant) |
| 225 | cc.CheckSnapshotRule(t, ctx, snapshotSingleton, "libffivendor_exclude", "libffivendor_exclude.so", sharedDir, sharedVariant) |
| 226 | includeJsonFiles = append(includeJsonFiles, filepath.Join(rlibDir, "librustvendor_exclude.rlib.json")) |
| 227 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libffivendor_exclude.so.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | // Verify that each json file for an included module has a rule. |
| 231 | for _, jsonFile := range includeJsonFiles { |
| 232 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 233 | t.Errorf("include json file %q not found", jsonFile) |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | func TestVendorSnapshotExclude(t *testing.T) { |
| 239 | |
| 240 | // This test verifies that the exclude_from_vendor_snapshot property |
| 241 | // makes its way from the Android.bp source file into the module data |
| 242 | // structure. It also verifies that modules are correctly included or |
| 243 | // excluded in the vendor snapshot based on their path (framework or |
| 244 | // vendor) and the exclude_from_vendor_snapshot property. |
| 245 | |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 246 | frameworkBp := ` |
| 247 | rust_ffi_shared { |
| 248 | name: "libinclude", |
| 249 | crate_name: "include", |
| 250 | srcs: ["include.rs"], |
| 251 | vendor_available: true, |
| 252 | } |
| 253 | |
| 254 | rust_ffi_shared { |
| 255 | name: "libexclude", |
| 256 | crate_name: "exclude", |
| 257 | srcs: ["exclude.rs"], |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 258 | vendor: true, |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 259 | exclude_from_vendor_snapshot: true, |
| 260 | } |
| 261 | |
| 262 | rust_ffi_shared { |
| 263 | name: "libavailable_exclude", |
| 264 | crate_name: "available_exclude", |
| 265 | srcs: ["lib.rs"], |
| 266 | vendor_available: true, |
| 267 | exclude_from_vendor_snapshot: true, |
| 268 | } |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 269 | |
| 270 | rust_library { |
| 271 | name: "librust_include", |
| 272 | crate_name: "rust_include", |
| 273 | srcs: ["include.rs"], |
| 274 | vendor_available: true, |
| 275 | } |
| 276 | |
| 277 | rust_library_rlib { |
| 278 | name: "librust_exclude", |
| 279 | crate_name: "rust_exclude", |
| 280 | srcs: ["exclude.rs"], |
| 281 | vendor: true, |
| 282 | exclude_from_vendor_snapshot: true, |
| 283 | } |
| 284 | |
| 285 | rust_library { |
| 286 | name: "librust_available_exclude", |
| 287 | crate_name: "rust_available_exclude", |
| 288 | srcs: ["lib.rs"], |
| 289 | vendor_available: true, |
| 290 | exclude_from_vendor_snapshot: true, |
| 291 | } |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 292 | ` |
| 293 | |
| 294 | mockFS := map[string][]byte{ |
| 295 | "framework/Android.bp": []byte(frameworkBp), |
| 296 | "framework/include.rs": nil, |
| 297 | "framework/exclude.rs": nil, |
| 298 | } |
| 299 | |
| 300 | ctx := testRustVndkFs(t, "", mockFS) |
| 301 | |
| 302 | // Test an include and exclude framework module. |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 303 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false, sharedVendorVariant) |
| 304 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true, sharedVendorVariant) |
| 305 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true, sharedVendorVariant) |
| 306 | |
| 307 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "librust_include", false, rlibVendorVariant) |
| 308 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "librust_exclude", true, rlibVendorVariant) |
| 309 | cc.AssertExcludeFromVendorSnapshotIs(t, ctx, "librust_available_exclude", true, rlibVendorVariant) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 310 | |
| 311 | // Verify the content of the vendor snapshot. |
| 312 | |
| 313 | snapshotDir := "vendor-snapshot" |
| 314 | snapshotVariantPath := filepath.Join("out/soong", snapshotDir, "arm64") |
| 315 | snapshotSingleton := ctx.SingletonForTests("vendor-snapshot") |
| 316 | |
| 317 | var includeJsonFiles []string |
| 318 | var excludeJsonFiles []string |
| 319 | |
| 320 | for _, arch := range [][]string{ |
| 321 | []string{"arm64", "armv8-a"}, |
| 322 | []string{"arm", "armv7-a-neon"}, |
| 323 | } { |
| 324 | archType := arch[0] |
| 325 | archVariant := arch[1] |
| 326 | archDir := fmt.Sprintf("arch-%s-%s", archType, archVariant) |
| 327 | |
| 328 | sharedVariant := fmt.Sprintf("android_vendor.29_%s_%s_shared", archType, archVariant) |
| 329 | sharedDir := filepath.Join(snapshotVariantPath, archDir, "shared") |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 330 | rlibVariant := fmt.Sprintf("android_vendor.29_%s_%s_rlib_rlib-std", archType, archVariant) |
| 331 | rlibDir := filepath.Join(snapshotVariantPath, archDir, "rlib") |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 332 | |
| 333 | // Included modules |
| 334 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "libinclude", "libinclude.so", sharedDir, sharedVariant) |
| 335 | includeJsonFiles = append(includeJsonFiles, filepath.Join(sharedDir, "libinclude.so.json")) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 336 | cc.CheckSnapshot(t, ctx, snapshotSingleton, "librust_include", "librust_include.rlib", rlibDir, rlibVariant) |
| 337 | includeJsonFiles = append(includeJsonFiles, filepath.Join(rlibDir, "librust_include.rlib.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 338 | |
| 339 | // Excluded modules |
| 340 | cc.CheckSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant) |
| 341 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json")) |
| 342 | cc.CheckSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant) |
| 343 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json")) |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 344 | cc.CheckSnapshotExclude(t, ctx, snapshotSingleton, "librust_exclude", "librust_exclude.rlib", rlibDir, rlibVariant) |
| 345 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(rlibDir, "librust_exclude.rlib.json")) |
| 346 | cc.CheckSnapshotExclude(t, ctx, snapshotSingleton, "librust_available_exclude", "librust_available_exclude.rlib", rlibDir, rlibVariant) |
| 347 | excludeJsonFiles = append(excludeJsonFiles, filepath.Join(rlibDir, "librust_available_exclude.rlib.json")) |
Ivan Lozano | 1921e80 | 2021-05-20 13:39:16 -0400 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | // Verify that each json file for an included module has a rule. |
| 351 | for _, jsonFile := range includeJsonFiles { |
| 352 | if snapshotSingleton.MaybeOutput(jsonFile).Rule == nil { |
| 353 | t.Errorf("include json file %q not found", jsonFile) |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | // Verify that each json file for an excluded module has no rule. |
| 358 | for _, jsonFile := range excludeJsonFiles { |
| 359 | if snapshotSingleton.MaybeOutput(jsonFile).Rule != nil { |
| 360 | t.Errorf("exclude json file %q found", jsonFile) |
| 361 | } |
| 362 | } |
| 363 | } |
Ivan Lozano | 3149e6e | 2021-06-01 15:09:53 -0400 | [diff] [blame^] | 364 | |
| 365 | func TestVendorSnapshotUse(t *testing.T) { |
| 366 | frameworkBp := ` |
| 367 | cc_library { |
| 368 | name: "libvndk", |
| 369 | vendor_available: true, |
| 370 | product_available: true, |
| 371 | vndk: { |
| 372 | enabled: true, |
| 373 | }, |
| 374 | nocrt: true, |
| 375 | } |
| 376 | |
| 377 | cc_library { |
| 378 | name: "libvendor", |
| 379 | vendor: true, |
| 380 | nocrt: true, |
| 381 | no_libcrt: true, |
| 382 | stl: "none", |
| 383 | system_shared_libs: [], |
| 384 | } |
| 385 | |
| 386 | cc_library { |
| 387 | name: "libvendor_available", |
| 388 | vendor_available: true, |
| 389 | nocrt: true, |
| 390 | no_libcrt: true, |
| 391 | stl: "none", |
| 392 | system_shared_libs: [], |
| 393 | } |
| 394 | |
| 395 | cc_library { |
| 396 | name: "lib32", |
| 397 | vendor: true, |
| 398 | nocrt: true, |
| 399 | no_libcrt: true, |
| 400 | stl: "none", |
| 401 | system_shared_libs: [], |
| 402 | compile_multilib: "32", |
| 403 | } |
| 404 | |
| 405 | cc_library { |
| 406 | name: "lib64", |
| 407 | vendor: true, |
| 408 | nocrt: true, |
| 409 | no_libcrt: true, |
| 410 | stl: "none", |
| 411 | system_shared_libs: [], |
| 412 | compile_multilib: "64", |
| 413 | } |
| 414 | |
| 415 | rust_binary { |
| 416 | name: "bin", |
| 417 | vendor: true, |
| 418 | srcs: ["bin.rs"], |
| 419 | } |
| 420 | |
| 421 | rust_binary { |
| 422 | name: "bin32", |
| 423 | vendor: true, |
| 424 | compile_multilib: "32", |
| 425 | srcs: ["bin.rs"], |
| 426 | } |
| 427 | ` |
| 428 | |
| 429 | vndkBp := ` |
| 430 | vndk_prebuilt_shared { |
| 431 | name: "libvndk", |
| 432 | version: "30", |
| 433 | target_arch: "arm64", |
| 434 | vendor_available: true, |
| 435 | product_available: true, |
| 436 | vndk: { |
| 437 | enabled: true, |
| 438 | }, |
| 439 | arch: { |
| 440 | arm64: { |
| 441 | srcs: ["libvndk.so"], |
| 442 | export_include_dirs: ["include/libvndk"], |
| 443 | }, |
| 444 | arm: { |
| 445 | srcs: ["libvndk.so"], |
| 446 | export_include_dirs: ["include/libvndk"], |
| 447 | }, |
| 448 | }, |
| 449 | } |
| 450 | |
| 451 | // old snapshot module which has to be ignored |
| 452 | vndk_prebuilt_shared { |
| 453 | name: "libvndk", |
| 454 | version: "26", |
| 455 | target_arch: "arm64", |
| 456 | vendor_available: true, |
| 457 | product_available: true, |
| 458 | vndk: { |
| 459 | enabled: true, |
| 460 | }, |
| 461 | arch: { |
| 462 | arm64: { |
| 463 | srcs: ["libvndk.so"], |
| 464 | export_include_dirs: ["include/libvndk"], |
| 465 | }, |
| 466 | arm: { |
| 467 | srcs: ["libvndk.so"], |
| 468 | export_include_dirs: ["include/libvndk"], |
| 469 | }, |
| 470 | }, |
| 471 | } |
| 472 | |
| 473 | // different arch snapshot which has to be ignored |
| 474 | vndk_prebuilt_shared { |
| 475 | name: "libvndk", |
| 476 | version: "30", |
| 477 | target_arch: "arm", |
| 478 | vendor_available: true, |
| 479 | product_available: true, |
| 480 | vndk: { |
| 481 | enabled: true, |
| 482 | }, |
| 483 | arch: { |
| 484 | arm: { |
| 485 | srcs: ["libvndk.so"], |
| 486 | export_include_dirs: ["include/libvndk"], |
| 487 | }, |
| 488 | }, |
| 489 | } |
| 490 | ` |
| 491 | |
| 492 | vendorProprietaryBp := ` |
| 493 | cc_library { |
| 494 | name: "libvendor_without_snapshot", |
| 495 | vendor: true, |
| 496 | nocrt: true, |
| 497 | no_libcrt: true, |
| 498 | stl: "none", |
| 499 | system_shared_libs: [], |
| 500 | } |
| 501 | |
| 502 | rust_library { |
| 503 | name: "librust_vendor_available", |
| 504 | crate_name: "rust_vendor", |
| 505 | vendor_available: true, |
| 506 | srcs: ["client.rs"], |
| 507 | } |
| 508 | |
| 509 | rust_ffi_shared { |
| 510 | name: "libclient", |
| 511 | crate_name: "client", |
| 512 | vendor: true, |
| 513 | shared_libs: ["libvndk", "libvendor_available"], |
| 514 | static_libs: ["libvendor", "libvendor_without_snapshot"], |
| 515 | rustlibs: ["librust_vendor_available"], |
| 516 | arch: { |
| 517 | arm64: { |
| 518 | shared_libs: ["lib64"], |
| 519 | }, |
| 520 | arm: { |
| 521 | shared_libs: ["lib32"], |
| 522 | }, |
| 523 | }, |
| 524 | srcs: ["client.rs"], |
| 525 | } |
| 526 | |
| 527 | rust_library_rlib { |
| 528 | name: "libclient_rust", |
| 529 | crate_name: "client_rust", |
| 530 | vendor: true, |
| 531 | shared_libs: ["libvndk", "libvendor_available"], |
| 532 | static_libs: ["libvendor", "libvendor_without_snapshot"], |
| 533 | rustlibs: ["librust_vendor_available"], |
| 534 | arch: { |
| 535 | arm64: { |
| 536 | shared_libs: ["lib64"], |
| 537 | }, |
| 538 | arm: { |
| 539 | shared_libs: ["lib32"], |
| 540 | }, |
| 541 | }, |
| 542 | srcs: ["client.rs"], |
| 543 | } |
| 544 | |
| 545 | rust_binary { |
| 546 | name: "bin_without_snapshot", |
| 547 | vendor: true, |
| 548 | static_libs: ["libvndk"], |
| 549 | srcs: ["bin.rs"], |
| 550 | rustlibs: ["librust_vendor_available"], |
| 551 | } |
| 552 | |
| 553 | vendor_snapshot { |
| 554 | name: "vendor_snapshot", |
| 555 | version: "30", |
| 556 | arch: { |
| 557 | arm64: { |
| 558 | vndk_libs: [ |
| 559 | "libvndk", |
| 560 | ], |
| 561 | static_libs: [ |
| 562 | "libvendor", |
| 563 | "libvndk", |
| 564 | "libclang_rt.builtins-aarch64-android", |
| 565 | ], |
| 566 | shared_libs: [ |
| 567 | "libvendor_available", |
| 568 | "lib64", |
| 569 | ], |
| 570 | rlibs: [ |
| 571 | "libstd", |
| 572 | "libtest", |
| 573 | "librust_vendor_available", |
| 574 | ], |
| 575 | binaries: [ |
| 576 | "bin", |
| 577 | ], |
| 578 | objects: [ |
| 579 | "crtend_so", |
| 580 | "crtbegin_so", |
| 581 | "crtbegin_dynamic", |
| 582 | "crtend_android" |
| 583 | ], |
| 584 | }, |
| 585 | arm: { |
| 586 | vndk_libs: [ |
| 587 | "libvndk", |
| 588 | ], |
| 589 | static_libs: [ |
| 590 | "libvendor", |
| 591 | "libvndk", |
| 592 | "libclang_rt.builtins-arm-android", |
| 593 | ], |
| 594 | shared_libs: [ |
| 595 | "libvendor_available", |
| 596 | "lib32", |
| 597 | ], |
| 598 | rlibs: [ |
| 599 | "libstd", |
| 600 | "libtest", |
| 601 | "librust_vendor_available", |
| 602 | ], |
| 603 | binaries: [ |
| 604 | "bin32", |
| 605 | ], |
| 606 | objects: [ |
| 607 | "crtend_so", |
| 608 | "crtbegin_so", |
| 609 | "crtbegin_dynamic", |
| 610 | "crtend_android" |
| 611 | ], |
| 612 | |
| 613 | }, |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | vendor_snapshot_object { |
| 618 | name: "crtend_so", |
| 619 | version: "30", |
| 620 | target_arch: "arm64", |
| 621 | vendor: true, |
| 622 | stl: "none", |
| 623 | crt: true, |
| 624 | arch: { |
| 625 | arm64: { |
| 626 | src: "crtend_so.o", |
| 627 | }, |
| 628 | arm: { |
| 629 | src: "crtend_so.o", |
| 630 | }, |
| 631 | }, |
| 632 | } |
| 633 | |
| 634 | vendor_snapshot_object { |
| 635 | name: "crtbegin_so", |
| 636 | version: "30", |
| 637 | target_arch: "arm64", |
| 638 | vendor: true, |
| 639 | stl: "none", |
| 640 | crt: true, |
| 641 | arch: { |
| 642 | arm64: { |
| 643 | src: "crtbegin_so.o", |
| 644 | }, |
| 645 | arm: { |
| 646 | src: "crtbegin_so.o", |
| 647 | }, |
| 648 | }, |
| 649 | } |
| 650 | |
| 651 | vendor_snapshot_rlib { |
| 652 | name: "libstd", |
| 653 | version: "30", |
| 654 | target_arch: "arm64", |
| 655 | vendor: true, |
| 656 | sysroot: true, |
| 657 | arch: { |
| 658 | arm64: { |
| 659 | src: "libstd.rlib", |
| 660 | }, |
| 661 | arm: { |
| 662 | src: "libstd.rlib", |
| 663 | }, |
| 664 | }, |
| 665 | } |
| 666 | |
| 667 | vendor_snapshot_rlib { |
| 668 | name: "libtest", |
| 669 | version: "30", |
| 670 | target_arch: "arm64", |
| 671 | vendor: true, |
| 672 | sysroot: true, |
| 673 | arch: { |
| 674 | arm64: { |
| 675 | src: "libtest.rlib", |
| 676 | }, |
| 677 | arm: { |
| 678 | src: "libtest.rlib", |
| 679 | }, |
| 680 | }, |
| 681 | } |
| 682 | |
| 683 | vendor_snapshot_rlib { |
| 684 | name: "librust_vendor_available", |
| 685 | version: "30", |
| 686 | target_arch: "arm64", |
| 687 | vendor: true, |
| 688 | arch: { |
| 689 | arm64: { |
| 690 | src: "librust_vendor_available.rlib", |
| 691 | }, |
| 692 | arm: { |
| 693 | src: "librust_vendor_available.rlib", |
| 694 | }, |
| 695 | }, |
| 696 | } |
| 697 | |
| 698 | vendor_snapshot_object { |
| 699 | name: "crtend_android", |
| 700 | version: "30", |
| 701 | target_arch: "arm64", |
| 702 | vendor: true, |
| 703 | stl: "none", |
| 704 | crt: true, |
| 705 | arch: { |
| 706 | arm64: { |
| 707 | src: "crtend_so.o", |
| 708 | }, |
| 709 | arm: { |
| 710 | src: "crtend_so.o", |
| 711 | }, |
| 712 | }, |
| 713 | } |
| 714 | |
| 715 | vendor_snapshot_object { |
| 716 | name: "crtbegin_dynamic", |
| 717 | version: "30", |
| 718 | target_arch: "arm64", |
| 719 | vendor: true, |
| 720 | stl: "none", |
| 721 | crt: true, |
| 722 | arch: { |
| 723 | arm64: { |
| 724 | src: "crtbegin_so.o", |
| 725 | }, |
| 726 | arm: { |
| 727 | src: "crtbegin_so.o", |
| 728 | }, |
| 729 | }, |
| 730 | } |
| 731 | |
| 732 | vendor_snapshot_static { |
| 733 | name: "libvndk", |
| 734 | version: "30", |
| 735 | target_arch: "arm64", |
| 736 | compile_multilib: "both", |
| 737 | vendor: true, |
| 738 | arch: { |
| 739 | arm64: { |
| 740 | src: "libvndk.a", |
| 741 | }, |
| 742 | arm: { |
| 743 | src: "libvndk.a", |
| 744 | }, |
| 745 | }, |
| 746 | shared_libs: ["libvndk"], |
| 747 | export_shared_lib_headers: ["libvndk"], |
| 748 | } |
| 749 | |
| 750 | vendor_snapshot_static { |
| 751 | name: "libclang_rt.builtins-aarch64-android", |
| 752 | version: "30", |
| 753 | target_arch: "arm64", |
| 754 | vendor: true, |
| 755 | arch: { |
| 756 | arm64: { |
| 757 | src: "libclang_rt.builtins-aarch64-android.a", |
| 758 | }, |
| 759 | }, |
| 760 | } |
| 761 | |
| 762 | vendor_snapshot_static { |
| 763 | name: "libclang_rt.builtins-arm-android", |
| 764 | version: "30", |
| 765 | target_arch: "arm64", |
| 766 | vendor: true, |
| 767 | arch: { |
| 768 | arm: { |
| 769 | src: "libclang_rt.builtins-arm-android.a", |
| 770 | }, |
| 771 | }, |
| 772 | } |
| 773 | |
| 774 | vendor_snapshot_shared { |
| 775 | name: "lib32", |
| 776 | version: "30", |
| 777 | target_arch: "arm64", |
| 778 | compile_multilib: "32", |
| 779 | vendor: true, |
| 780 | arch: { |
| 781 | arm: { |
| 782 | src: "lib32.so", |
| 783 | }, |
| 784 | }, |
| 785 | } |
| 786 | |
| 787 | vendor_snapshot_shared { |
| 788 | name: "lib64", |
| 789 | version: "30", |
| 790 | target_arch: "arm64", |
| 791 | compile_multilib: "64", |
| 792 | vendor: true, |
| 793 | arch: { |
| 794 | arm64: { |
| 795 | src: "lib64.so", |
| 796 | }, |
| 797 | }, |
| 798 | } |
| 799 | vendor_snapshot_shared { |
| 800 | name: "liblog", |
| 801 | version: "30", |
| 802 | target_arch: "arm64", |
| 803 | compile_multilib: "64", |
| 804 | vendor: true, |
| 805 | arch: { |
| 806 | arm64: { |
| 807 | src: "liblog.so", |
| 808 | }, |
| 809 | }, |
| 810 | } |
| 811 | |
| 812 | vendor_snapshot_static { |
| 813 | name: "libvendor", |
| 814 | version: "30", |
| 815 | target_arch: "arm64", |
| 816 | compile_multilib: "both", |
| 817 | vendor: true, |
| 818 | arch: { |
| 819 | arm64: { |
| 820 | src: "libvendor.a", |
| 821 | export_include_dirs: ["include/libvendor"], |
| 822 | }, |
| 823 | arm: { |
| 824 | src: "libvendor.a", |
| 825 | export_include_dirs: ["include/libvendor"], |
| 826 | }, |
| 827 | }, |
| 828 | } |
| 829 | |
| 830 | vendor_snapshot_shared { |
| 831 | name: "libvendor_available", |
| 832 | version: "30", |
| 833 | target_arch: "arm64", |
| 834 | compile_multilib: "both", |
| 835 | vendor: true, |
| 836 | arch: { |
| 837 | arm64: { |
| 838 | src: "libvendor_available.so", |
| 839 | export_include_dirs: ["include/libvendor"], |
| 840 | }, |
| 841 | arm: { |
| 842 | src: "libvendor_available.so", |
| 843 | export_include_dirs: ["include/libvendor"], |
| 844 | }, |
| 845 | }, |
| 846 | } |
| 847 | |
| 848 | vendor_snapshot_binary { |
| 849 | name: "bin", |
| 850 | version: "30", |
| 851 | target_arch: "arm64", |
| 852 | compile_multilib: "64", |
| 853 | vendor: true, |
| 854 | arch: { |
| 855 | arm64: { |
| 856 | src: "bin", |
| 857 | }, |
| 858 | }, |
| 859 | } |
| 860 | |
| 861 | vendor_snapshot_binary { |
| 862 | name: "bin32", |
| 863 | version: "30", |
| 864 | target_arch: "arm64", |
| 865 | compile_multilib: "32", |
| 866 | vendor: true, |
| 867 | arch: { |
| 868 | arm: { |
| 869 | src: "bin32", |
| 870 | }, |
| 871 | }, |
| 872 | } |
| 873 | |
| 874 | // old snapshot module which has to be ignored |
| 875 | vendor_snapshot_binary { |
| 876 | name: "bin", |
| 877 | version: "26", |
| 878 | target_arch: "arm64", |
| 879 | compile_multilib: "first", |
| 880 | vendor: true, |
| 881 | arch: { |
| 882 | arm64: { |
| 883 | src: "bin", |
| 884 | }, |
| 885 | }, |
| 886 | } |
| 887 | |
| 888 | // different arch snapshot which has to be ignored |
| 889 | vendor_snapshot_binary { |
| 890 | name: "bin", |
| 891 | version: "30", |
| 892 | target_arch: "arm", |
| 893 | compile_multilib: "first", |
| 894 | vendor: true, |
| 895 | arch: { |
| 896 | arm64: { |
| 897 | src: "bin", |
| 898 | }, |
| 899 | }, |
| 900 | } |
| 901 | ` |
| 902 | |
| 903 | mockFS := android.MockFS{ |
| 904 | "framework/Android.bp": []byte(frameworkBp), |
| 905 | "framework/bin.rs": nil, |
| 906 | "vendor/Android.bp": []byte(vendorProprietaryBp), |
| 907 | "vendor/bin": nil, |
| 908 | "vendor/bin32": nil, |
| 909 | "vendor/bin.rs": nil, |
| 910 | "vendor/client.rs": nil, |
| 911 | "vendor/include/libvndk/a.h": nil, |
| 912 | "vendor/include/libvendor/b.h": nil, |
| 913 | "vendor/libvndk.a": nil, |
| 914 | "vendor/libvendor.a": nil, |
| 915 | "vendor/libvendor.so": nil, |
| 916 | "vendor/lib32.so": nil, |
| 917 | "vendor/lib64.so": nil, |
| 918 | "vendor/liblog.so": nil, |
| 919 | "vendor/libstd.rlib": nil, |
| 920 | "vendor/libtest.rlib": nil, |
| 921 | "vendor/librust_vendor_available.rlib": nil, |
| 922 | "vendor/crtbegin_so.o": nil, |
| 923 | "vendor/crtend_so.o": nil, |
| 924 | "vendor/libclang_rt.builtins-aarch64-android.a": nil, |
| 925 | "vendor/libclang_rt.builtins-arm-android.a": nil, |
| 926 | "vndk/Android.bp": []byte(vndkBp), |
| 927 | "vndk/include/libvndk/a.h": nil, |
| 928 | "vndk/libvndk.so": nil, |
| 929 | } |
| 930 | |
| 931 | sharedVariant := "android_vendor.30_arm64_armv8-a_shared" |
| 932 | rlibVariant := "android_vendor.30_arm64_armv8-a_rlib_rlib-std" |
| 933 | staticVariant := "android_vendor.30_arm64_armv8-a_static" |
| 934 | binaryVariant := "android_vendor.30_arm64_armv8-a" |
| 935 | |
| 936 | shared32Variant := "android_vendor.30_arm_armv7-a-neon_shared" |
| 937 | binary32Variant := "android_vendor.30_arm_armv7-a-neon" |
| 938 | |
| 939 | ctx := testRustVndkFsVersions(t, "", mockFS, "30", "current", "31") |
| 940 | |
| 941 | // libclient uses libvndk.vndk.30.arm64, libvendor.vendor_static.30.arm64, libvendor_without_snapshot |
| 942 | libclientLdFlags := ctx.ModuleForTests("libclient", sharedVariant).Rule("rustc").Args["linkFlags"] |
| 943 | for _, input := range [][]string{ |
| 944 | []string{sharedVariant, "libvndk.vndk.30.arm64"}, |
| 945 | []string{staticVariant, "libvendor.vendor_static.30.arm64"}, |
| 946 | []string{staticVariant, "libvendor_without_snapshot"}, |
| 947 | } { |
| 948 | outputPaths := cc.GetOutputPaths(ctx, input[0] /* variant */, []string{input[1]} /* module name */) |
| 949 | if !strings.Contains(libclientLdFlags, outputPaths[0].String()) { |
| 950 | t.Errorf("libflags for libclient must contain %#v, but was %#v", outputPaths[0], libclientLdFlags) |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | libclientAndroidMkSharedLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkSharedLibs |
| 955 | if g, w := libclientAndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "lib64", "liblog.vendor", "libc.vendor", "libm.vendor", "libdl.vendor"}; !reflect.DeepEqual(g, w) { |
| 956 | t.Errorf("wanted libclient AndroidMkSharedLibs %q, got %q", w, g) |
| 957 | } |
| 958 | |
| 959 | libclientAndroidMkStaticLibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkStaticLibs |
| 960 | if g, w := libclientAndroidMkStaticLibs, []string{"libvendor", "libvendor_without_snapshot", "libclang_rt.builtins-aarch64-android.vendor"}; !reflect.DeepEqual(g, w) { |
| 961 | t.Errorf("wanted libclient AndroidMkStaticLibs %q, got %q", w, g) |
| 962 | } |
| 963 | |
| 964 | libclientAndroidMkRlibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkRlibs |
| 965 | if g, w := libclientAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64", "libtest.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) { |
| 966 | t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g) |
| 967 | } |
| 968 | |
| 969 | libclientAndroidMkDylibs := ctx.ModuleForTests("libclient", sharedVariant).Module().(*Module).Properties.AndroidMkDylibs |
| 970 | if len(libclientAndroidMkDylibs) > 0 { |
| 971 | t.Errorf("wanted libclient libclientAndroidMkDylibs [], got %q", libclientAndroidMkDylibs) |
| 972 | } |
| 973 | |
| 974 | libclient32AndroidMkSharedLibs := ctx.ModuleForTests("libclient", shared32Variant).Module().(*Module).Properties.AndroidMkSharedLibs |
| 975 | if g, w := libclient32AndroidMkSharedLibs, []string{"libvndk.vendor", "libvendor_available.vendor", "lib32", "liblog.vendor", "libc.vendor", "libm.vendor", "libdl.vendor"}; !reflect.DeepEqual(g, w) { |
| 976 | t.Errorf("wanted libclient32 AndroidMkSharedLibs %q, got %q", w, g) |
| 977 | } |
| 978 | |
| 979 | libclientRustAndroidMkRlibs := ctx.ModuleForTests("libclient_rust", rlibVariant).Module().(*Module).Properties.AndroidMkRlibs |
| 980 | if g, w := libclientRustAndroidMkRlibs, []string{"librust_vendor_available.vendor_rlib.30.arm64.rlib-std", "libstd.vendor_rlib.30.arm64", "libtest.vendor_rlib.30.arm64"}; !reflect.DeepEqual(g, w) { |
| 981 | t.Errorf("wanted libclient libclientAndroidMkRlibs %q, got %q", w, g) |
| 982 | } |
| 983 | |
| 984 | binWithoutSnapshotLdFlags := ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Rule("rustc").Args["linkFlags"] |
| 985 | libVndkStaticOutputPaths := cc.GetOutputPaths(ctx, staticVariant, []string{"libvndk.vendor_static.30.arm64"}) |
| 986 | if !strings.Contains(binWithoutSnapshotLdFlags, libVndkStaticOutputPaths[0].String()) { |
| 987 | t.Errorf("libflags for bin_without_snapshot must contain %#v, but was %#v", |
| 988 | libVndkStaticOutputPaths[0], binWithoutSnapshotLdFlags) |
| 989 | } |
| 990 | |
| 991 | // bin is installed by bin.vendor_binary.30.arm64 |
| 992 | ctx.ModuleForTests("bin.vendor_binary.30.arm64", binaryVariant).Output("bin") |
| 993 | |
| 994 | // bin32 is installed by bin32.vendor_binary.30.arm64 |
| 995 | ctx.ModuleForTests("bin32.vendor_binary.30.arm64", binary32Variant).Output("bin32") |
| 996 | |
| 997 | // bin_without_snapshot is installed by bin_without_snapshot |
| 998 | ctx.ModuleForTests("bin_without_snapshot", binaryVariant).Output("bin_without_snapshot") |
| 999 | |
| 1000 | // libvendor, libvendor_available and bin don't have vendor.30 variant |
| 1001 | libvendorVariants := ctx.ModuleVariantsForTests("libvendor") |
| 1002 | if android.InList(sharedVariant, libvendorVariants) { |
| 1003 | t.Errorf("libvendor must not have variant %#v, but it does", sharedVariant) |
| 1004 | } |
| 1005 | |
| 1006 | libvendorAvailableVariants := ctx.ModuleVariantsForTests("libvendor_available") |
| 1007 | if android.InList(sharedVariant, libvendorAvailableVariants) { |
| 1008 | t.Errorf("libvendor_available must not have variant %#v, but it does", sharedVariant) |
| 1009 | } |
| 1010 | |
| 1011 | binVariants := ctx.ModuleVariantsForTests("bin") |
| 1012 | if android.InList(binaryVariant, binVariants) { |
| 1013 | t.Errorf("bin must not have variant %#v, but it does", sharedVariant) |
| 1014 | } |
| 1015 | } |