blob: 391072ec861b8bdd0826b67cb877540b6450f992 [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
11func TestVndkApexUsesVendorVariant(t *testing.T) {
12 bp := `
13 apex_vndk {
14 name: "myapex",
15 key: "mykey",
16 }
17 apex_key {
18 name: "mykey",
19 }
20 cc_library {
21 name: "libfoo",
22 vendor_available: true,
23 vndk: {
24 enabled: true,
25 },
26 system_shared_libs: [],
27 stl: "none",
28 notice: "custom_notice",
29 }
30 ` + vndkLibrariesTxtFiles("current")
31
32 ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) {
33 t.Helper()
34 for _, f := range files {
35 if f.path == path {
36 ensureContains(t, f.src, src)
37 return
38 }
39 }
40 t.Fail()
41 }
42
43 t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
44 ctx, _ := testApex(t, bp)
45
46 // libfoo doesn't have apex variants
47 for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
48 ensureNotContains(t, variant, "_myapex")
49 }
50
51 // VNDK APEX doesn't create apex variant
52 files := getFiles(t, ctx, "myapex", "android_common_image")
53 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
54 })
55
56 t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
57 ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
58 // Now product variant is available
59 config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
60 })
61
62 files := getFiles(t, ctx, "myapex", "android_common_image")
63 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
64 })
65
66 t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
67 ctx, _ := testApex(t, bp+`
68 cc_library {
69 name: "libprofile-extras",
70 vendor_available: true,
71 native_coverage: false,
72 system_shared_libs: [],
73 stl: "none",
74 notice: "custom_notice",
75 }
76 cc_library {
77 name: "libprofile-clang-extras",
78 vendor_available: true,
79 native_coverage: false,
80 system_shared_libs: [],
81 stl: "none",
82 notice: "custom_notice",
83 }
84 `, func(fs map[string][]byte, config android.Config) {
85 config.TestProductVariables.NativeCoverage = proptools.BoolPtr(true)
86 })
87
88 files := getFiles(t, ctx, "myapex", "android_common_image")
89 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
90
91 files = getFiles(t, ctx, "myapex", "android_common_cov_image")
92 ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so")
93 })
94}