Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 1 | package apex |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/google/blueprint/proptools" |
| 7 | |
| 8 | "android/soong/android" |
| 9 | ) |
| 10 | |
| 11 | func TestVndkApexUsesVendorVariant(t *testing.T) { |
| 12 | bp := ` |
| 13 | apex_vndk { |
| 14 | name: "myapex", |
| 15 | key: "mykey", |
| 16 | } |
| 17 | apex_key { |
| 18 | name: "mykey", |
| 19 | } |
| 20 | cc_library { |
| 21 | name: "libfoo", |
| 22 | vendor_available: true, |
| 23 | vndk: { |
| 24 | enabled: true, |
| 25 | }, |
| 26 | system_shared_libs: [], |
| 27 | stl: "none", |
| 28 | notice: "custom_notice", |
| 29 | } |
| 30 | ` + vndkLibrariesTxtFiles("current") |
| 31 | |
| 32 | ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) { |
| 33 | t.Helper() |
| 34 | for _, f := range files { |
| 35 | if f.path == path { |
| 36 | ensureContains(t, f.src, src) |
| 37 | return |
| 38 | } |
| 39 | } |
| 40 | t.Fail() |
| 41 | } |
| 42 | |
| 43 | t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) { |
| 44 | ctx, _ := testApex(t, bp) |
| 45 | |
| 46 | // libfoo doesn't have apex variants |
| 47 | for _, variant := range ctx.ModuleVariantsForTests("libfoo") { |
| 48 | ensureNotContains(t, variant, "_myapex") |
| 49 | } |
| 50 | |
| 51 | // VNDK APEX doesn't create apex variant |
| 52 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 53 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 54 | }) |
| 55 | |
| 56 | t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) { |
| 57 | ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) { |
| 58 | // Now product variant is available |
| 59 | config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current") |
| 60 | }) |
| 61 | |
| 62 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 63 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 64 | }) |
| 65 | |
| 66 | t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { |
| 67 | ctx, _ := testApex(t, bp+` |
| 68 | cc_library { |
| 69 | name: "libprofile-extras", |
| 70 | vendor_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 71 | recovery_available: true, |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 72 | native_coverage: false, |
| 73 | system_shared_libs: [], |
| 74 | stl: "none", |
| 75 | notice: "custom_notice", |
| 76 | } |
| 77 | cc_library { |
| 78 | name: "libprofile-clang-extras", |
| 79 | vendor_available: true, |
Colin Cross | f9aabd7 | 2020-02-15 11:29:50 -0800 | [diff] [blame] | 80 | recovery_available: true, |
| 81 | native_coverage: false, |
| 82 | system_shared_libs: [], |
| 83 | stl: "none", |
| 84 | notice: "custom_notice", |
| 85 | } |
| 86 | cc_library { |
| 87 | name: "libprofile-extras_ndk", |
| 88 | vendor_available: true, |
| 89 | native_coverage: false, |
| 90 | system_shared_libs: [], |
| 91 | stl: "none", |
| 92 | notice: "custom_notice", |
| 93 | } |
| 94 | cc_library { |
| 95 | name: "libprofile-clang-extras_ndk", |
| 96 | vendor_available: true, |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 97 | native_coverage: false, |
| 98 | system_shared_libs: [], |
| 99 | stl: "none", |
| 100 | notice: "custom_notice", |
| 101 | } |
| 102 | `, func(fs map[string][]byte, config android.Config) { |
Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 103 | config.TestProductVariables.Native_coverage = proptools.BoolPtr(true) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 104 | }) |
| 105 | |
| 106 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 107 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 108 | |
| 109 | files = getFiles(t, ctx, "myapex", "android_common_cov_image") |
| 110 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so") |
| 111 | }) |
| 112 | } |