visibility.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * KUnit API to allow symbols to be conditionally visible during KUnit
  4. * testing
  5. *
  6. * Copyright (C) 2022, Google LLC.
  7. * Author: Rae Moar <rmoar@google.com>
  8. */
  9. #ifndef _KUNIT_VISIBILITY_H
  10. #define _KUNIT_VISIBILITY_H
  11. #if IS_ENABLED(CONFIG_KUNIT)
  12. /**
  13. * VISIBLE_IF_KUNIT - A macro that sets symbols to be static if
  14. * CONFIG_KUNIT is not enabled. Otherwise if CONFIG_KUNIT is enabled
  15. * there is no change to the symbol definition.
  16. */
  17. #define VISIBLE_IF_KUNIT
  18. /**
  19. * EXPORT_SYMBOL_IF_KUNIT(symbol) - Exports symbol into
  20. * EXPORTED_FOR_KUNIT_TESTING namespace only if CONFIG_KUNIT is
  21. * enabled. Must use MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING)
  22. * in test file in order to use symbols.
  23. * @symbol: the symbol identifier to export
  24. */
  25. #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \
  26. EXPORTED_FOR_KUNIT_TESTING)
  27. #else
  28. #define VISIBLE_IF_KUNIT static
  29. #define EXPORT_SYMBOL_IF_KUNIT(symbol)
  30. #endif
  31. #endif /* _KUNIT_VISIBILITY_H */