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 | |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 11 | func TestVndkApexForVndkLite(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame^] | 12 | t.Parallel() |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 13 | ctx, _ := testApex(t, ` |
| 14 | apex_vndk { |
| 15 | name: "myapex", |
| 16 | key: "myapex.key", |
| 17 | } |
| 18 | |
| 19 | apex_key { |
| 20 | name: "myapex.key", |
| 21 | public_key: "testkey.avbpubkey", |
| 22 | private_key: "testkey.pem", |
| 23 | } |
| 24 | |
| 25 | cc_library { |
| 26 | name: "libvndk", |
| 27 | srcs: ["mylib.cpp"], |
| 28 | vendor_available: true, |
| 29 | vndk: { |
| 30 | enabled: true, |
| 31 | }, |
| 32 | system_shared_libs: [], |
| 33 | stl: "none", |
| 34 | apex_available: [ "myapex" ], |
| 35 | } |
| 36 | |
| 37 | cc_library { |
| 38 | name: "libvndksp", |
| 39 | srcs: ["mylib.cpp"], |
| 40 | vendor_available: true, |
| 41 | vndk: { |
| 42 | enabled: true, |
| 43 | support_system_process: true, |
| 44 | }, |
| 45 | system_shared_libs: [], |
| 46 | stl: "none", |
| 47 | apex_available: [ "myapex" ], |
| 48 | } |
| 49 | `+vndkLibrariesTxtFiles("current"), func(fs map[string][]byte, config android.Config) { |
| 50 | config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("") |
| 51 | }) |
| 52 | // VNDK-Lite contains only core variants of VNDK-Sp libraries |
| 53 | ensureExactContents(t, ctx, "myapex", "android_common_image", []string{ |
| 54 | "lib/libvndksp.so", |
| 55 | "lib/libc++.so", |
| 56 | "lib64/libvndksp.so", |
| 57 | "lib64/libc++.so", |
| 58 | "etc/llndk.libraries.VER.txt", |
| 59 | "etc/vndkcore.libraries.VER.txt", |
| 60 | "etc/vndksp.libraries.VER.txt", |
| 61 | "etc/vndkprivate.libraries.VER.txt", |
| 62 | }) |
| 63 | } |
| 64 | |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 65 | func TestVndkApexUsesVendorVariant(t *testing.T) { |
Colin Cross | 323dc60 | 2020-09-18 14:25:31 -0700 | [diff] [blame^] | 66 | t.Parallel() |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 67 | bp := ` |
| 68 | apex_vndk { |
| 69 | name: "myapex", |
| 70 | key: "mykey", |
| 71 | } |
| 72 | apex_key { |
| 73 | name: "mykey", |
| 74 | } |
| 75 | cc_library { |
| 76 | name: "libfoo", |
| 77 | vendor_available: true, |
| 78 | vndk: { |
| 79 | enabled: true, |
| 80 | }, |
| 81 | system_shared_libs: [], |
| 82 | stl: "none", |
| 83 | notice: "custom_notice", |
| 84 | } |
| 85 | ` + vndkLibrariesTxtFiles("current") |
| 86 | |
| 87 | ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) { |
| 88 | t.Helper() |
| 89 | for _, f := range files { |
| 90 | if f.path == path { |
| 91 | ensureContains(t, f.src, src) |
| 92 | return |
| 93 | } |
| 94 | } |
| 95 | t.Fail() |
| 96 | } |
| 97 | |
| 98 | t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) { |
| 99 | ctx, _ := testApex(t, bp) |
| 100 | |
| 101 | // libfoo doesn't have apex variants |
| 102 | for _, variant := range ctx.ModuleVariantsForTests("libfoo") { |
| 103 | ensureNotContains(t, variant, "_myapex") |
| 104 | } |
| 105 | |
| 106 | // VNDK APEX doesn't create apex variant |
| 107 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 108 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 109 | }) |
| 110 | |
| 111 | t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) { |
| 112 | ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) { |
| 113 | // Now product variant is available |
| 114 | config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current") |
| 115 | }) |
| 116 | |
| 117 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 118 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 119 | }) |
| 120 | |
| 121 | t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 122 | ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) { |
Colin Cross | 1a6acd4 | 2020-06-16 17:51:46 -0700 | [diff] [blame] | 123 | config.TestProductVariables.GcovCoverage = proptools.BoolPtr(true) |
Colin Cross | d9a121b | 2020-01-27 13:26:42 -0800 | [diff] [blame] | 124 | config.TestProductVariables.Native_coverage = proptools.BoolPtr(true) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 125 | }) |
| 126 | |
| 127 | files := getFiles(t, ctx, "myapex", "android_common_image") |
| 128 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so") |
| 129 | |
| 130 | files = getFiles(t, ctx, "myapex", "android_common_cov_image") |
| 131 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so") |
| 132 | }) |
| 133 | } |