sysprop_library_conversion_test.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Copyright 2022 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package sysprop
  15. import (
  16. "testing"
  17. "android/soong/bp2build"
  18. )
  19. func TestSyspropLibrarySimple(t *testing.T) {
  20. bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{
  21. Description: "sysprop_library simple",
  22. ModuleTypeUnderTest: "sysprop_library",
  23. ModuleTypeUnderTestFactory: syspropLibraryFactory,
  24. Filesystem: map[string]string{
  25. "foo.sysprop": "",
  26. "bar.sysprop": "",
  27. },
  28. Blueprint: `
  29. sysprop_library {
  30. name: "sysprop_foo",
  31. srcs: [
  32. "foo.sysprop",
  33. "bar.sysprop",
  34. ],
  35. property_owner: "Platform",
  36. }
  37. `,
  38. ExpectedBazelTargets: []string{
  39. bp2build.MakeBazelTargetNoRestrictions("sysprop_library",
  40. "sysprop_foo",
  41. bp2build.AttrNameToString{
  42. "srcs": `[
  43. "foo.sysprop",
  44. "bar.sysprop",
  45. ]`,
  46. }),
  47. bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared",
  48. "libsysprop_foo",
  49. bp2build.AttrNameToString{
  50. "dep": `":sysprop_foo"`,
  51. }),
  52. bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static",
  53. "libsysprop_foo_bp2build_cc_library_static",
  54. bp2build.AttrNameToString{
  55. "dep": `":sysprop_foo"`,
  56. }),
  57. },
  58. })
  59. }
  60. func TestSyspropLibraryCppMinSdkVersion(t *testing.T) {
  61. bp2build.RunBp2BuildTestCaseSimple(t, bp2build.Bp2buildTestCase{
  62. Description: "sysprop_library with min_sdk_version",
  63. ModuleTypeUnderTest: "sysprop_library",
  64. ModuleTypeUnderTestFactory: syspropLibraryFactory,
  65. Filesystem: map[string]string{
  66. "foo.sysprop": "",
  67. "bar.sysprop": "",
  68. },
  69. Blueprint: `
  70. sysprop_library {
  71. name: "sysprop_foo",
  72. srcs: [
  73. "foo.sysprop",
  74. "bar.sysprop",
  75. ],
  76. cpp: {
  77. min_sdk_version: "5",
  78. },
  79. property_owner: "Platform",
  80. }
  81. `,
  82. ExpectedBazelTargets: []string{
  83. bp2build.MakeBazelTargetNoRestrictions("sysprop_library",
  84. "sysprop_foo",
  85. bp2build.AttrNameToString{
  86. "srcs": `[
  87. "foo.sysprop",
  88. "bar.sysprop",
  89. ]`,
  90. }),
  91. bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_shared",
  92. "libsysprop_foo",
  93. bp2build.AttrNameToString{
  94. "dep": `":sysprop_foo"`,
  95. "min_sdk_version": `"5"`,
  96. }),
  97. bp2build.MakeBazelTargetNoRestrictions("cc_sysprop_library_static",
  98. "libsysprop_foo_bp2build_cc_library_static",
  99. bp2build.AttrNameToString{
  100. "dep": `":sysprop_foo"`,
  101. "min_sdk_version": `"5"`,
  102. }),
  103. },
  104. })
  105. }