blob: e2aee96e77038443a05247026c1366c3f526b554 [file] [log] [blame]
Jooyung Hana57af4a2020-01-23 05:36:59 +00001package apex
2
3import (
4 "testing"
5
6 "github.com/google/blueprint/proptools"
7
8 "android/soong/android"
9)
10
Jooyung Han73d20d02020-03-27 16:06:55 +090011func TestVndkApexForVndkLite(t *testing.T) {
Colin Cross1c460562021-02-16 17:55:47 -080012 ctx := testApex(t, `
Jooyung Han73d20d02020-03-27 16:06:55 +090013 apex_vndk {
Colin Cross2807f002021-03-02 10:15:29 -080014 name: "com.android.vndk.current",
15 key: "com.android.vndk.current.key",
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +000016 updatable: false,
Jooyung Han73d20d02020-03-27 16:06:55 +090017 }
18
19 apex_key {
Colin Cross2807f002021-03-02 10:15:29 -080020 name: "com.android.vndk.current.key",
Jooyung Han73d20d02020-03-27 16:06:55 +090021 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 Yun63e9ec72020-10-29 16:49:43 +090029 product_available: true,
Jooyung Han73d20d02020-03-27 16:06:55 +090030 vndk: {
31 enabled: true,
32 },
33 system_shared_libs: [],
34 stl: "none",
Colin Cross2807f002021-03-02 10:15:29 -080035 apex_available: [ "com.android.vndk.current" ],
Jooyung Han73d20d02020-03-27 16:06:55 +090036 }
37
38 cc_library {
39 name: "libvndksp",
40 srcs: ["mylib.cpp"],
41 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090042 product_available: true,
Jooyung Han73d20d02020-03-27 16:06:55 +090043 vndk: {
44 enabled: true,
45 support_system_process: true,
46 },
47 system_shared_libs: [],
48 stl: "none",
Colin Cross2807f002021-03-02 10:15:29 -080049 apex_available: [ "com.android.vndk.current" ],
Jooyung Han73d20d02020-03-27 16:06:55 +090050 }
Paul Duffin0a49fdc2021-03-08 11:28:25 +000051 `+vndkLibrariesTxtFiles("current"),
52 android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
53 variables.DeviceVndkVersion = proptools.StringPtr("")
Kiyoung Kima2d6dee2023-08-11 10:14:43 +090054 variables.KeepVndk = proptools.BoolPtr(true)
Paul Duffin0a49fdc2021-03-08 11:28:25 +000055 }),
56 )
Jooyung Han73d20d02020-03-27 16:06:55 +090057 // VNDK-Lite contains only core variants of VNDK-Sp libraries
Jooyung Hana0503a52023-08-23 13:12:50 +090058 ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{
Jooyung Han73d20d02020-03-27 16:06:55 +090059 "lib/libvndksp.so",
60 "lib/libc++.so",
61 "lib64/libvndksp.so",
62 "lib64/libc++.so",
Jiyong Parkf58c46e2021-04-01 21:35:20 +090063 "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 Han73d20d02020-03-27 16:06:55 +090068 })
69}
70
Jooyung Hana57af4a2020-01-23 05:36:59 +000071func TestVndkApexUsesVendorVariant(t *testing.T) {
72 bp := `
73 apex_vndk {
Colin Cross2807f002021-03-02 10:15:29 -080074 name: "com.android.vndk.current",
Jooyung Hana57af4a2020-01-23 05:36:59 +000075 key: "mykey",
Mathew Inwoodf8dcf5e2021-02-16 11:40:16 +000076 updatable: false,
Jooyung Hana57af4a2020-01-23 05:36:59 +000077 }
78 apex_key {
79 name: "mykey",
80 }
81 cc_library {
82 name: "libfoo",
83 vendor_available: true,
Justin Yun63e9ec72020-10-29 16:49:43 +090084 product_available: true,
Jooyung Hana57af4a2020-01-23 05:36:59 +000085 vndk: {
86 enabled: true,
87 },
88 system_shared_libs: [],
89 stl: "none",
Jooyung Hana57af4a2020-01-23 05:36:59 +000090 }
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 Cross2807f002021-03-02 10:15:29 -0800101 t.Errorf("expected path %q not found", path)
Jooyung Hana57af4a2020-01-23 05:36:59 +0000102 }
103
104 t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
Colin Cross1c460562021-02-16 17:55:47 -0800105 ctx := testApex(t, bp)
Jooyung Hana57af4a2020-01-23 05:36:59 +0000106
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 Hana0503a52023-08-23 13:12:50 +0900113 files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
Jiyong Parkf58c46e2021-04-01 21:35:20 +0900114 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
Jooyung Hana57af4a2020-01-23 05:36:59 +0000115 })
116
117 t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
Justin Yunaf1fde42023-09-27 16:22:10 +0900118 ctx := testApex(t, bp)
Jooyung Hana57af4a2020-01-23 05:36:59 +0000119
Jooyung Hana0503a52023-08-23 13:12:50 +0900120 files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
Jiyong Parkf58c46e2021-04-01 21:35:20 +0900121 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
Jooyung Hana57af4a2020-01-23 05:36:59 +0000122 })
123
124 t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
Paul Duffin0a49fdc2021-03-08 11:28:25 +0000125 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 Hana57af4a2020-01-23 05:36:59 +0000131
Jooyung Hana0503a52023-08-23 13:12:50 +0900132 files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
Jiyong Parkf58c46e2021-04-01 21:35:20 +0900133 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
Jooyung Hana57af4a2020-01-23 05:36:59 +0000134
Jooyung Hana0503a52023-08-23 13:12:50 +0900135 files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov")
Jiyong Parkf58c46e2021-04-01 21:35:20 +0900136 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so")
Jooyung Hana57af4a2020-01-23 05:36:59 +0000137 })
138}