bpf_conversion_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 bp2build
  15. import (
  16. "android/soong/android"
  17. "android/soong/bpf"
  18. "testing"
  19. )
  20. func runBpfTestCase(t *testing.T, tc Bp2buildTestCase) {
  21. t.Helper()
  22. (&tc).ModuleTypeUnderTest = "bpf"
  23. (&tc).ModuleTypeUnderTestFactory = bpf.BpfFactory
  24. RunBp2BuildTestCase(t, registerBpfModuleTypes, tc)
  25. }
  26. func registerBpfModuleTypes(ctx android.RegistrationContext) {}
  27. func TestBpfSupportedAttrs(t *testing.T) {
  28. runBpfTestCase(t, Bp2buildTestCase{
  29. Description: "Bpf module only converts supported attributes",
  30. Filesystem: map[string]string{},
  31. Blueprint: `
  32. bpf {
  33. name: "bpfTestOut.o",
  34. srcs: ["bpfTestSrcOne.c",
  35. "bpfTestSrcTwo.c"],
  36. btf: true,
  37. cflags: ["-bpfCflagOne",
  38. "-bpfCflagTwo"],
  39. include_dirs: ["ia/ib/ic"],
  40. sub_dir: "sa/ab",
  41. }
  42. `,
  43. ExpectedBazelTargets: []string{
  44. MakeBazelTarget("bpf", "bpfTestOut.o", AttrNameToString{
  45. "absolute_includes": `["ia/ib/ic"]`,
  46. "btf": `True`,
  47. "copts": `[
  48. "-bpfCflagOne",
  49. "-bpfCflagTwo",
  50. ]`,
  51. "srcs": `[
  52. "bpfTestSrcOne.c",
  53. "bpfTestSrcTwo.c",
  54. ]`,
  55. "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
  56. }),
  57. },
  58. })
  59. }