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