162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * KUnit API to allow symbols to be conditionally visible during KUnit 462306a36Sopenharmony_ci * testing 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (C) 2022, Google LLC. 762306a36Sopenharmony_ci * Author: Rae Moar <rmoar@google.com> 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _KUNIT_VISIBILITY_H 1162306a36Sopenharmony_ci#define _KUNIT_VISIBILITY_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_KUNIT) 1462306a36Sopenharmony_ci /** 1562306a36Sopenharmony_ci * VISIBLE_IF_KUNIT - A macro that sets symbols to be static if 1662306a36Sopenharmony_ci * CONFIG_KUNIT is not enabled. Otherwise if CONFIG_KUNIT is enabled 1762306a36Sopenharmony_ci * there is no change to the symbol definition. 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci #define VISIBLE_IF_KUNIT 2062306a36Sopenharmony_ci /** 2162306a36Sopenharmony_ci * EXPORT_SYMBOL_IF_KUNIT(symbol) - Exports symbol into 2262306a36Sopenharmony_ci * EXPORTED_FOR_KUNIT_TESTING namespace only if CONFIG_KUNIT is 2362306a36Sopenharmony_ci * enabled. Must use MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING) 2462306a36Sopenharmony_ci * in test file in order to use symbols. 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_ci #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \ 2762306a36Sopenharmony_ci EXPORTED_FOR_KUNIT_TESTING) 2862306a36Sopenharmony_ci#else 2962306a36Sopenharmony_ci #define VISIBLE_IF_KUNIT static 3062306a36Sopenharmony_ci #define EXPORT_SYMBOL_IF_KUNIT(symbol) 3162306a36Sopenharmony_ci#endif 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#endif /* _KUNIT_VISIBILITY_H */ 34