smb/client: Use EXPORT_SYMBOL_IF_KUNIT() to export symbols
Subsystems (2)
PATCH 1/1 smb/client: Use EXPORT_SYMBOL_IF_KUNIT() to export symbols
Replace EXPORT_SYMBOL_FOR_MODULES() with EXPORT_SYMBOL_IF_KUNIT() to mark the symbols as visible only if CONFIG_KUNIT is enabled.
Kunit test should import the namespace EXPORTED_FOR_KUNIT_TESTING to use these marked symbols. This is the standard way for all KUnit tests.
--- fs/smb/client/smb1maperror.c | 24 ++++++++++++------------ fs/smb/client/smb1maperror_test.c | 1 + 2 files changed, 13 insertions(+), 12 deletions(-)
fs/smb/client/smb1maperror.c +12 -12
@@ -10,6 +10,9 @@*/ #include <linux/bsearch.h> + +#include <kunit/visibility.h> +#include "cifsproto.h" #include "smb1proto.h" #include "smberr.h"
@@ -239,48 +242,45 @@ int __init smb1_init_maperror(void) }#if IS_ENABLED (CONFIG_SMB1_KUNIT_TESTS ) -#define EXPORT_SYMBOL_FOR_SMB_TEST (sym) \ - EXPORT_SYMBOL_FOR_MODULES(sym, "smb1maperror_test") -const struct ntstatus_to_dos_err *search_ntstatus_to_dos_map_test (__u32 ntstatus) {return search_ntstatus_to_dos_map (ntstatus); } -EXPORT_SYMBOL_FOR_SMB_TEST (search_ntstatus_to_dos_map_test); +EXPORT_SYMBOL_IF_KUNIT (search_ntstatus_to_dos_map_test);const struct ntstatus_to_dos_err * ntstatus_to_dos_map_test = ntstatus_to_dos_map; -EXPORT_SYMBOL_FOR_SMB_TEST (ntstatus_to_dos_map_test); +EXPORT_SYMBOL_IF_KUNIT (ntstatus_to_dos_map_test);unsigned int ntstatus_to_dos_num =ARRAY_SIZE (ntstatus_to_dos_map); -EXPORT_SYMBOL_FOR_SMB_TEST (ntstatus_to_dos_num); +EXPORT_SYMBOL_IF_KUNIT (ntstatus_to_dos_num);const struct smb_to_posix_error *search_mapping_table_ERRDOS_test (__u16 smb_err) {return search_mapping_table_ERRDOS (smb_err); } -EXPORT_SYMBOL_FOR_SMB_TEST (search_mapping_table_ERRDOS_test); +EXPORT_SYMBOL_IF_KUNIT (search_mapping_table_ERRDOS_test);const struct smb_to_posix_error * mapping_table_ERRDOS_test = mapping_table_ERRDOS; -EXPORT_SYMBOL_FOR_SMB_TEST (mapping_table_ERRDOS_test); +EXPORT_SYMBOL_IF_KUNIT (mapping_table_ERRDOS_test);unsigned int mapping_table_ERRDOS_num =ARRAY_SIZE (mapping_table_ERRDOS); -EXPORT_SYMBOL_FOR_SMB_TEST (mapping_table_ERRDOS_num); +EXPORT_SYMBOL_IF_KUNIT (mapping_table_ERRDOS_num);const struct smb_to_posix_error *search_mapping_table_ERRSRV_test (__u16 smb_err) {return search_mapping_table_ERRSRV (smb_err); } -EXPORT_SYMBOL_FOR_SMB_TEST (search_mapping_table_ERRSRV_test); +EXPORT_SYMBOL_IF_KUNIT (search_mapping_table_ERRSRV_test);const struct smb_to_posix_error * mapping_table_ERRSRV_test = mapping_table_ERRSRV; -EXPORT_SYMBOL_FOR_SMB_TEST (mapping_table_ERRSRV_test); +EXPORT_SYMBOL_IF_KUNIT (mapping_table_ERRSRV_test);unsigned int mapping_table_ERRSRV_num =ARRAY_SIZE (mapping_table_ERRSRV); -EXPORT_SYMBOL_FOR_SMB_TEST (mapping_table_ERRSRV_num); +EXPORT_SYMBOL_IF_KUNIT (mapping_table_ERRSRV_num);#endif
fs/smb/client/smb1maperror_test.c +1 -0
@@ -75,3 +75,4 @@ kunit_test_suite(maperror_suite);MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("KUnit tests of SMB1 maperror" ); +MODULE_IMPORT_NS ("EXPORTED_FOR_KUNIT_TESTING" );
Signature · 1 line
2.50.1
Andy, could you also submit a patch to update fs/smb/client/smb2maperror.c as well?
Quoted 12 lines · Andy Shevchenko
Replace
EXPORT_SYMBOL_FOR_MODULES()withEXPORT_SYMBOL_IF_KUNIT()to mark the symbols as visible only ifCONFIG_KUNITis enabled.Kunit test should import the namespace
EXPORTED_FOR_KUNIT_TESTINGto use these marked symbols. This is the standard way for all KUnit tests.Signed-off-by Andy Shevchenko<[email protected]>--- fs/smb/client/smb1maperror.c | 24 ++++++++++++------------ fs/smb/client/smb1maperror_test.c | 1 + 2 files changed, 13 insertions(+), 12 deletions(-)
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
Quoted 1 line · ChenXiaoSong
Reviewed-by ChenXiaoSong <[email protected]>
Thanks!
Quoted 2 lines
Andy, could you also submit a patch to update
fs/smb/client/smb2maperror.cas well?
Sure.
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines
Replace
EXPORT_SYMBOL_FOR_MODULES()withEXPORT_SYMBOL_IF_KUNIT()to mark the symbols as visible only ifCONFIG_KUNITis enabled.Kunit test should import the namespace
EXPORTED_FOR_KUNIT_TESTINGto use these marked symbols. This is the standard way for all KUnit tests.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Steve French
Appliedmerged into cifs-2.6.git for-next
Quoted 26 lines · ChenXiaoSong via samba-technical
Reviewed-by ChenXiaoSong <[email protected]>Andy, could you also submit a patch to update
fs/smb/client/smb2maperror.cas well?Quoted 7 lines · Andy Shevchenko
Replace
EXPORT_SYMBOL_FOR_MODULES()withEXPORT_SYMBOL_IF_KUNIT()to mark the symbols as visible only ifCONFIG_KUNITis enabled.Kunit test should import the namespace
EXPORTED_FOR_KUNIT_TESTINGto use these marked symbols. This is the standard way for all KUnit tests.Quoted 5 lines
Signed-off-by Andy Shevchenko<[email protected]>--- fs/smb/client/smb1maperror.c | 24 ++++++++++++------------ fs/smb/client/smb1maperror_test.c | 1 + 2 files changed, 13 insertions(+), 12 deletions(-)--
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
Signature · 3 lines
Thanks, Steve