vndk_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: "com.android.vndk.current",
  11. key: "com.android.vndk.current.key",
  12. updatable: false,
  13. }
  14. apex_key {
  15. name: "com.android.vndk.current.key",
  16. public_key: "testkey.avbpubkey",
  17. private_key: "testkey.pem",
  18. }
  19. cc_library {
  20. name: "libvndk",
  21. srcs: ["mylib.cpp"],
  22. vendor_available: true,
  23. product_available: true,
  24. vndk: {
  25. enabled: true,
  26. },
  27. system_shared_libs: [],
  28. stl: "none",
  29. apex_available: [ "com.android.vndk.current" ],
  30. }
  31. cc_library {
  32. name: "libvndksp",
  33. srcs: ["mylib.cpp"],
  34. vendor_available: true,
  35. product_available: true,
  36. vndk: {
  37. enabled: true,
  38. support_system_process: true,
  39. },
  40. system_shared_libs: [],
  41. stl: "none",
  42. apex_available: [ "com.android.vndk.current" ],
  43. }
  44. `+vndkLibrariesTxtFiles("current"),
  45. android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
  46. variables.DeviceVndkVersion = proptools.StringPtr("")
  47. }),
  48. )
  49. // VNDK-Lite contains only core variants of VNDK-Sp libraries
  50. ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", []string{
  51. "lib/libvndksp.so",
  52. "lib/libc++.so",
  53. "lib64/libvndksp.so",
  54. "lib64/libc++.so",
  55. "etc/llndk.libraries.29.txt",
  56. "etc/vndkcore.libraries.29.txt",
  57. "etc/vndksp.libraries.29.txt",
  58. "etc/vndkprivate.libraries.29.txt",
  59. "etc/vndkproduct.libraries.29.txt",
  60. })
  61. }
  62. func TestVndkApexUsesVendorVariant(t *testing.T) {
  63. bp := `
  64. apex_vndk {
  65. name: "com.android.vndk.current",
  66. key: "mykey",
  67. updatable: false,
  68. }
  69. apex_key {
  70. name: "mykey",
  71. }
  72. cc_library {
  73. name: "libfoo",
  74. vendor_available: true,
  75. product_available: true,
  76. vndk: {
  77. enabled: true,
  78. },
  79. system_shared_libs: [],
  80. stl: "none",
  81. }
  82. ` + vndkLibrariesTxtFiles("current")
  83. ensureFileSrc := func(t *testing.T, files []fileInApex, path, src string) {
  84. t.Helper()
  85. for _, f := range files {
  86. if f.path == path {
  87. ensureContains(t, f.src, src)
  88. return
  89. }
  90. }
  91. t.Errorf("expected path %q not found", path)
  92. }
  93. t.Run("VNDK lib doesn't have an apex variant", func(t *testing.T) {
  94. ctx := testApex(t, bp)
  95. // libfoo doesn't have apex variants
  96. for _, variant := range ctx.ModuleVariantsForTests("libfoo") {
  97. ensureNotContains(t, variant, "_myapex")
  98. }
  99. // VNDK APEX doesn't create apex variant
  100. files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
  101. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
  102. })
  103. t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
  104. ctx := testApex(t, bp,
  105. android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
  106. // Now product variant is available
  107. variables.ProductVndkVersion = proptools.StringPtr("current")
  108. }),
  109. )
  110. files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
  111. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
  112. })
  113. t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
  114. ctx := testApex(t, bp,
  115. android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
  116. variables.GcovCoverage = proptools.BoolPtr(true)
  117. variables.Native_coverage = proptools.BoolPtr(true)
  118. }),
  119. )
  120. files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
  121. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
  122. files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov_image")
  123. ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so")
  124. })
  125. }