ndk_test.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 cc
  15. import (
  16. "testing"
  17. "github.com/google/blueprint"
  18. "android/soong/android"
  19. )
  20. func TestNdkHeaderDependency(t *testing.T) {
  21. isDep := func(ctx *android.TestResult, from, toExpected android.Module) bool {
  22. foundDep := false
  23. ctx.VisitDirectDeps(from, func(toActual blueprint.Module) {
  24. if toExpected.Name() == toActual.Name() {
  25. foundDep = true
  26. }
  27. })
  28. return foundDep
  29. }
  30. bp := `
  31. ndk_library {
  32. name: "libfoo",
  33. first_version: "29",
  34. symbol_file: "libfoo.map.txt",
  35. export_header_libs: ["libfoo_headers"],
  36. }
  37. ndk_headers {
  38. name: "libfoo_headers",
  39. srcs: ["foo.h"],
  40. license: "NOTICE",
  41. }
  42. //This module is needed since Soong creates a dep edge on source
  43. cc_library {
  44. name: "libfoo",
  45. }
  46. `
  47. ctx := prepareForCcTest.RunTestWithBp(t, bp)
  48. libfoo := ctx.ModuleForTests("libfoo.ndk", "android_arm64_armv8-a_sdk_shared")
  49. libfoo_headers := ctx.ModuleForTests("libfoo_headers", "")
  50. android.AssertBoolEquals(t, "Could not find headers of ndk_library", true, isDep(ctx, libfoo.Module(), libfoo_headers.Module()))
  51. }