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