2020-01-23 06:36:59 +01:00
|
|
|
package apex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
|
|
|
|
|
|
|
"android/soong/android"
|
|
|
|
)
|
|
|
|
|
2020-03-27 08:06:55 +01:00
|
|
|
func TestVndkApexForVndkLite(t *testing.T) {
|
2021-02-17 02:55:47 +01:00
|
|
|
ctx := testApex(t, `
|
2020-03-27 08:06:55 +01:00
|
|
|
apex_vndk {
|
2021-03-02 19:15:29 +01:00
|
|
|
name: "com.android.vndk.current",
|
|
|
|
key: "com.android.vndk.current.key",
|
2021-02-16 12:40:16 +01:00
|
|
|
updatable: false,
|
2020-03-27 08:06:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
apex_key {
|
2021-03-02 19:15:29 +01:00
|
|
|
name: "com.android.vndk.current.key",
|
2020-03-27 08:06:55 +01:00
|
|
|
public_key: "testkey.avbpubkey",
|
|
|
|
private_key: "testkey.pem",
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndk",
|
|
|
|
srcs: ["mylib.cpp"],
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-03-27 08:06:55 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
2021-03-02 19:15:29 +01:00
|
|
|
apex_available: [ "com.android.vndk.current" ],
|
2020-03-27 08:06:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cc_library {
|
|
|
|
name: "libvndksp",
|
|
|
|
srcs: ["mylib.cpp"],
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-03-27 08:06:55 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
support_system_process: true,
|
|
|
|
},
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
2021-03-02 19:15:29 +01:00
|
|
|
apex_available: [ "com.android.vndk.current" ],
|
2020-03-27 08:06:55 +01:00
|
|
|
}
|
2021-03-08 12:28:25 +01:00
|
|
|
`+vndkLibrariesTxtFiles("current"),
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.DeviceVndkVersion = proptools.StringPtr("")
|
2023-08-11 03:14:43 +02:00
|
|
|
variables.KeepVndk = proptools.BoolPtr(true)
|
2021-03-08 12:28:25 +01:00
|
|
|
}),
|
|
|
|
)
|
2020-03-27 08:06:55 +01:00
|
|
|
// VNDK-Lite contains only core variants of VNDK-Sp libraries
|
2023-08-23 06:12:50 +02:00
|
|
|
ensureExactContents(t, ctx, "com.android.vndk.current", "android_common", []string{
|
2020-03-27 08:06:55 +01:00
|
|
|
"lib/libvndksp.so",
|
|
|
|
"lib/libc++.so",
|
|
|
|
"lib64/libvndksp.so",
|
|
|
|
"lib64/libc++.so",
|
2021-04-01 14:35:20 +02:00
|
|
|
"etc/llndk.libraries.29.txt",
|
|
|
|
"etc/vndkcore.libraries.29.txt",
|
|
|
|
"etc/vndksp.libraries.29.txt",
|
|
|
|
"etc/vndkprivate.libraries.29.txt",
|
|
|
|
"etc/vndkproduct.libraries.29.txt",
|
2020-03-27 08:06:55 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-01-23 06:36:59 +01:00
|
|
|
func TestVndkApexUsesVendorVariant(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
apex_vndk {
|
2021-03-02 19:15:29 +01:00
|
|
|
name: "com.android.vndk.current",
|
2020-01-23 06:36:59 +01:00
|
|
|
key: "mykey",
|
2021-02-16 12:40:16 +01:00
|
|
|
updatable: false,
|
2020-01-23 06:36:59 +01:00
|
|
|
}
|
|
|
|
apex_key {
|
|
|
|
name: "mykey",
|
|
|
|
}
|
|
|
|
cc_library {
|
|
|
|
name: "libfoo",
|
|
|
|
vendor_available: true,
|
2020-10-29 08:49:43 +01:00
|
|
|
product_available: true,
|
2020-01-23 06:36:59 +01:00
|
|
|
vndk: {
|
|
|
|
enabled: true,
|
|
|
|
},
|
|
|
|
system_shared_libs: [],
|
|
|
|
stl: "none",
|
|
|
|
}
|
|
|
|
` + vndkLibrariesTxtFiles("current")
|
|
|
|
|
|
|
|
ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) {
|
|
|
|
t.Helper()
|
|
|
|
for _, f := range files {
|
|
|
|
if f.path == path {
|
|
|
|
ensureContains(t, f.src, src)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-03-02 19:15:29 +01:00
|
|
|
t.Errorf("expected path %q not found", path)
|
2020-01-23 06:36:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
|
2021-02-17 02:55:47 +01:00
|
|
|
ctx := testApex(t, bp)
|
2020-01-23 06:36:59 +01:00
|
|
|
|
|
|
|
// libfoo doesn't have apex variants
|
|
|
|
for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
|
|
|
|
ensureNotContains(t, variant, "_myapex")
|
|
|
|
}
|
|
|
|
|
|
|
|
// VNDK APEX doesn't create apex variant
|
2023-08-23 06:12:50 +02:00
|
|
|
files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
|
2021-04-01 14:35:20 +02:00
|
|
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
|
2020-01-23 06:36:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
|
2023-09-27 09:22:10 +02:00
|
|
|
ctx := testApex(t, bp)
|
2020-01-23 06:36:59 +01:00
|
|
|
|
2023-08-23 06:12:50 +02:00
|
|
|
files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
|
2021-04-01 14:35:20 +02:00
|
|
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
|
2020-01-23 06:36:59 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
|
2021-03-08 12:28:25 +01:00
|
|
|
ctx := testApex(t, bp,
|
|
|
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
|
variables.GcovCoverage = proptools.BoolPtr(true)
|
|
|
|
variables.Native_coverage = proptools.BoolPtr(true)
|
|
|
|
}),
|
|
|
|
)
|
2020-01-23 06:36:59 +01:00
|
|
|
|
2023-08-23 06:12:50 +02:00
|
|
|
files := getFiles(t, ctx, "com.android.vndk.current", "android_common")
|
2021-04-01 14:35:20 +02:00
|
|
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
|
2020-01-23 06:36:59 +01:00
|
|
|
|
2023-08-23 06:12:50 +02:00
|
|
|
files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov")
|
2021-04-01 14:35:20 +02:00
|
|
|
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so")
|
2020-01-23 06:36:59 +01:00
|
|
|
})
|
|
|
|
}
|