Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 7fa0696 | 2021-10-25 10:28:33 -0400 | [diff] [blame^] | 1 | package bp2build |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "android/soong/cc" |
| 7 | ) |
| 8 | |
| 9 | func TestSharedPrebuiltLibrary(t *testing.T) { |
| 10 | runBp2BuildTestCaseSimple(t, |
| 11 | bp2buildTestCase{ |
| 12 | description: "prebuilt library shared simple", |
| 13 | moduleTypeUnderTest: "cc_prebuilt_library_shared", |
| 14 | moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory, |
| 15 | moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build, |
| 16 | filesystem: map[string]string{ |
| 17 | "libf.so": "", |
| 18 | }, |
| 19 | blueprint: ` |
| 20 | cc_prebuilt_library_shared { |
| 21 | name: "libtest", |
| 22 | srcs: ["libf.so"], |
| 23 | bazel_module: { bp2build_available: true }, |
| 24 | }`, |
| 25 | expectedBazelTargets: []string{ |
| 26 | `prebuilt_library_shared( |
| 27 | name = "libtest", |
| 28 | shared_library = "libf.so", |
| 29 | )`, |
| 30 | }, |
| 31 | }) |
| 32 | } |
| 33 | |
| 34 | func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) { |
| 35 | runBp2BuildTestCaseSimple(t, |
| 36 | bp2buildTestCase{ |
| 37 | description: "prebuilt library shared with arch variance", |
| 38 | moduleTypeUnderTest: "cc_prebuilt_library_shared", |
| 39 | moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory, |
| 40 | moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build, |
| 41 | filesystem: map[string]string{ |
| 42 | "libf.so": "", |
| 43 | "libg.so": "", |
| 44 | }, |
| 45 | blueprint: ` |
| 46 | cc_prebuilt_library_shared { |
| 47 | name: "libtest", |
| 48 | arch: { |
| 49 | arm64: { srcs: ["libf.so"], }, |
| 50 | arm: { srcs: ["libg.so"], }, |
| 51 | }, |
| 52 | bazel_module: { bp2build_available: true }, |
| 53 | }`, |
| 54 | expectedBazelTargets: []string{ |
| 55 | `prebuilt_library_shared( |
| 56 | name = "libtest", |
| 57 | shared_library = select({ |
| 58 | "//build/bazel/platforms/arch:arm": "libg.so", |
| 59 | "//build/bazel/platforms/arch:arm64": "libf.so", |
| 60 | "//conditions:default": None, |
| 61 | }), |
| 62 | )`, |
| 63 | }, |
| 64 | }) |
| 65 | } |