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 | 1c46056 | 2021-02-16 17:55:47 -0800 | [diff] [blame] | 12 | ctx := testApex(t, ` |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 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 | } |
Paul Duffin | 0a49fdc | 2021-03-08 11:28:25 +0000 | [diff] [blame] | 51 | `+vndkLibrariesTxtFiles("current"), |
| 52 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 53 | variables.DeviceVndkVersion = proptools.StringPtr("") |
Kiyoung Kim | a2d6dee | 2023-08-11 10:14:43 +0900 | [diff] [blame] | 54 | variables.KeepVndk = proptools.BoolPtr(true) |
Paul Duffin | 0a49fdc | 2021-03-08 11:28:25 +0000 | [diff] [blame] | 55 | }), |
| 56 | ) |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 57 | // VNDK-Lite contains only core variants of VNDK-Sp libraries |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 58 | ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{ |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 59 | "lib/libvndksp.so", |
| 60 | "lib/libc++.so", |
| 61 | "lib64/libvndksp.so", |
| 62 | "lib64/libc++.so", |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 63 | "etc/llndk.libraries.29.txt", |
| 64 | "etc/vndkcore.libraries.29.txt", |
| 65 | "etc/vndksp.libraries.29.txt", |
| 66 | "etc/vndkprivate.libraries.29.txt", |
| 67 | "etc/vndkproduct.libraries.29.txt", |
Jooyung Han | 73d20d0 | 2020-03-27 16:06:55 +0900 | [diff] [blame] | 68 | }) |
| 69 | } |
| 70 | |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 71 | func TestVndkApexUsesVendorVariant(t *testing.T) { |
| 72 | bp := ` |
| 73 | apex_vndk { |
Colin Cross | 2807f00 | 2021-03-02 10:15:29 -0800 | [diff] [blame] | 74 | name: "com.android.vndk.current", |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 75 | key: "mykey", |
Mathew Inwood | f8dcf5e | 2021-02-16 11:40:16 +0000 | [diff] [blame] | 76 | updatable: false, |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 77 | } |
| 78 | apex_key { |
| 79 | name: "mykey", |
| 80 | } |
| 81 | cc_library { |
| 82 | name: "libfoo", |
| 83 | vendor_available: true, |
Justin Yun | 63e9ec7 | 2020-10-29 16:49:43 +0900 | [diff] [blame] | 84 | product_available: true, |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 85 | vndk: { |
| 86 | enabled: true, |
| 87 | }, |
| 88 | system_shared_libs: [], |
| 89 | stl: "none", |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 90 | } |
| 91 | ` + vndkLibrariesTxtFiles("current") |
| 92 | |
| 93 | ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) { |
| 94 | t.Helper() |
| 95 | for _, f := range files { |
| 96 | if f.path == path { |
| 97 | ensureContains(t, f.src, src) |
| 98 | return |
| 99 | } |
| 100 | } |
Colin Cross | 2807f00 | 2021-03-02 10:15:29 -0800 | [diff] [blame] | 101 | t.Errorf("expected path %q not found", path) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) { |
Colin Cross | 1c46056 | 2021-02-16 17:55:47 -0800 | [diff] [blame] | 105 | ctx := testApex(t, bp) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 106 | |
| 107 | // libfoo doesn't have apex variants |
| 108 | for _, variant := range ctx.ModuleVariantsForTests("libfoo") { |
| 109 | ensureNotContains(t, variant, "_myapex") |
| 110 | } |
| 111 | |
| 112 | // VNDK APEX doesn't create apex variant |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 113 | files := getFiles(t, ctx, "com.android.vndk.current", "android_common") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 114 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 115 | }) |
| 116 | |
| 117 | t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) { |
Justin Yun | af1fde4 | 2023-09-27 16:22:10 +0900 | [diff] [blame] | 118 | ctx := testApex(t, bp) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 119 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 120 | files := getFiles(t, ctx, "com.android.vndk.current", "android_common") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 121 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 122 | }) |
| 123 | |
| 124 | t.Run("VNDK APEX supports coverage variants", func(t *testing.T) { |
Paul Duffin | 0a49fdc | 2021-03-08 11:28:25 +0000 | [diff] [blame] | 125 | ctx := testApex(t, bp, |
| 126 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 127 | variables.GcovCoverage = proptools.BoolPtr(true) |
| 128 | variables.Native_coverage = proptools.BoolPtr(true) |
| 129 | }), |
| 130 | ) |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 131 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 132 | files := getFiles(t, ctx, "com.android.vndk.current", "android_common") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 133 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so") |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 134 | |
Jooyung Han | a0503a5 | 2023-08-23 13:12:50 +0900 | [diff] [blame] | 135 | files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov") |
Jiyong Park | f58c46e | 2021-04-01 21:35:20 +0900 | [diff] [blame] | 136 | ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so") |
Jooyung Han | a57af4a | 2020-01-23 05:36:59 +0000 | [diff] [blame] | 137 | }) |
| 138 | } |