platform_build_soong/apex/vndk_test.go
Colin Cross f8e80229fe Revert "Add sdk mutator for native modules"
Revert submission 1242911-sdk_version_variant

Reason for revert: b/153394225
Reverted Changes:
Ife99745fb:Use libnativewindow for platform variant of libagq...
I1bae84c43:Use libnativewindow for platform variant of androi...
I6e6021ed3:Use stl to depend on libc++
Ife99745fb:Use libnativewindow for platform variant of libRSS...
I2c9f439b9:Fix static dependency on libprotobuf-cpp-lite-ndk
Iff2aff9cf:Set sdk_version for cc_genrules used by modules wi...
I7d72934aa:Add sdk mutator for native modules
Ief378a007:Use sdk variant of Soong modules when LOCAL_SDK_VE...

Bug: 149591340
Change-Id: I798fa902c779469c6382b6699351e5d12bf14785
Fixes: 153394225
2020-04-07 04:21:21 +00:00

112 lines
3 KiB
Go

package apex
import (
"testing"
"github.com/google/blueprint/proptools"
"android/soong/android"
)
func TestVndkApexUsesVendorVariant(t *testing.T) {
bp := `
apex_vndk {
name: "myapex",
key: "mykey",
}
apex_key {
name: "mykey",
}
cc_library {
name: "libfoo",
vendor_available: true,
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
}
}
t.Fail()
}
t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
ctx, _ := testApex(t, bp)
// libfoo doesn't have apex variants
for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
ensureNotContains(t, variant, "_myapex")
}
// VNDK APEX doesn't create apex variant
files := getFiles(t, ctx, "myapex", "android_common_image")
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) {
ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
// Now product variant is available
config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
})
files := getFiles(t, ctx, "myapex", "android_common_image")
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) {
ctx, _ := testApex(t, bp+`
cc_library {
name: "libprofile-extras",
vendor_available: true,
recovery_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
notice: "custom_notice",
}
cc_library {
name: "libprofile-clang-extras",
vendor_available: true,
recovery_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
notice: "custom_notice",
}
cc_library {
name: "libprofile-extras_ndk",
vendor_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
notice: "custom_notice",
}
cc_library {
name: "libprofile-clang-extras_ndk",
vendor_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
notice: "custom_notice",
}
`, func(fs map[string][]byte, config android.Config) {
config.TestProductVariables.Native_coverage = proptools.BoolPtr(true)
})
files := getFiles(t, ctx, "myapex", "android_common_image")
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
files = getFiles(t, ctx, "myapex", "android_common_cov_image")
ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so")
})
}