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