vndk_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package apex
  2. import (
  3. "testing"
  4. "github.com/google/blueprint/proptools"
  5. "android/soong/android"
  6. )
  7. func TestVndkApexForVndkLite(t *testing.T) {
  8. ctx, _ := testApex(t, `
  9. apex_vndk {
  10. name: "myapex",
  11. key: "myapex.key",
  12. }
  13. apex_key {
  14. name: "myapex.key",
  15. public_key: "testkey.avbpubkey",
  16. private_key: "testkey.pem",
  17. }
  18. cc_library {
  19. name: "libvndk",
  20. srcs: ["mylib.cpp"],
  21. vendor_available: true,
  22. vndk: {
  23. enabled: true,
  24. },
  25. system_shared_libs: [],
  26. stl: "none",
  27. apex_available: [ "myapex" ],
  28. }
  29. cc_library {
  30. name: "libvndksp",
  31. srcs: ["mylib.cpp"],
  32. vendor_available: true,
  33. vndk: {
  34. enabled: true,
  35. support_system_process: true,
  36. },
  37. system_shared_libs: [],
  38. stl: "none",
  39. apex_available: [ "myapex" ],
  40. }
  41. `+vndkLibrariesTxtFiles("current"), func(fs map[string][]byte, config android.Config) {
  42. config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("")
  43. })
  44. // VNDK-Lite contains only core variants of VNDK-Sp libraries
  45. ensureExactContents(t, ctx, "myapex", "android_common_image", []string{
  46. "lib/libvndksp.so",
  47. "lib/libc++.so",
  48. "lib64/libvndksp.so",
  49. "lib64/libc++.so",
  50. "etc/llndk.libraries.VER.txt",
  51. "etc/vndkcore.libraries.VER.txt",
  52. "etc/vndksp.libraries.VER.txt",
  53. "etc/vndkprivate.libraries.VER.txt",
  54. })
  55. }
  56. func TestVndkApexUsesVendorVariant(t *testing.T) {
  57. bp := `
  58. apex_vndk {
  59. name: "myapex",
  60. key: "mykey",
  61. }
  62. apex_key {
  63. name: "mykey",
  64. }
  65. cc_library {
  66. name: "libfoo",
  67. vendor_available: true,
  68. vndk: {
  69. enabled: true,
  70. },
  71. system_shared_libs: [],
  72. stl: "none",
  73. notice: "custom_notice",
  74. }
  75. ` + vndkLibrariesTxtFiles("current")
  76. ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) {
  77. t.Helper()
  78. for _, f := range files {
  79. if f.path == path {
  80. ensureContains(t, f.src, src)
  81. return
  82. }
  83. }
  84. t.Fail()
  85. }
  86. t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
  87. ctx, _ := testApex(t, bp)
  88. // libfoo doesn't have apex variants
  89. for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
  90. ensureNotContains(t, variant, "_myapex")
  91. }
  92. // VNDK APEX doesn't create apex variant
  93. files := getFiles(t, ctx, "myapex", "android_common_image")
  94. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
  95. })
  96. t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
  97. ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
  98. // Now product variant is available
  99. config.TestProductVariables.ProductVndkVersion = proptools.StringPtr("current")
  100. })
  101. files := getFiles(t, ctx, "myapex", "android_common_image")
  102. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
  103. })
  104. t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
  105. ctx, _ := testApex(t, bp, func(fs map[string][]byte, config android.Config) {
  106. config.TestProductVariables.GcovCoverage = proptools.BoolPtr(true)
  107. config.TestProductVariables.Native_coverage = proptools.BoolPtr(true)
  108. })
  109. files := getFiles(t, ctx, "myapex", "android_common_image")
  110. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
  111. files = getFiles(t, ctx, "myapex", "android_common_cov_image")
  112. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so")
  113. })
  114. }