linker_config_conversion_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. "fmt"
  17. "testing"
  18. "android/soong/linkerconfig"
  19. )
  20. func runLinkerConfigTestCase(t *testing.T, tc Bp2buildTestCase) {
  21. t.Helper()
  22. (&tc).ModuleTypeUnderTest = "linker_config"
  23. (&tc).ModuleTypeUnderTestFactory = linkerconfig.LinkerConfigFactory
  24. RunBp2BuildTestCaseSimple(t, tc)
  25. }
  26. func TestLinkerConfigConvertsSrc(t *testing.T) {
  27. runLinkerConfigTestCase(t,
  28. Bp2buildTestCase{
  29. Blueprint: `
  30. linker_config {
  31. name: "foo",
  32. src: "a.json",
  33. }
  34. `,
  35. ExpectedBazelTargets: []string{MakeBazelTarget("linker_config", "foo", AttrNameToString{
  36. "src": `"a.json"`,
  37. })},
  38. })
  39. }
  40. func TestLinkerConfigNoSrc(t *testing.T) {
  41. runLinkerConfigTestCase(t,
  42. Bp2buildTestCase{
  43. Blueprint: `
  44. linker_config {
  45. name: "foo",
  46. }
  47. `,
  48. ExpectedBazelTargets: []string{},
  49. ExpectedErr: fmt.Errorf("Android.bp:2:1: module \"foo\": src: empty src is not supported"),
  50. })
  51. }