File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,4 +56,6 @@ $(obj)/smb2maperror.o: $(obj)/smb2_mapping_table.c
5656quiet_cmd_gen_smb2_mapping = GEN $@
5757 cmd_gen_smb2_mapping = perl $(src ) /gen_smb2_mapping $< $@
5858
59+ obj-$(CONFIG_SMB_KUNIT_TESTS) += smb2maperror_test.o
60+
5961clean-files += smb2_mapping_table.c
Original file line number Diff line number Diff line change @@ -46,4 +46,16 @@ enum smb2_compound_ops {
4646#define END_OF_CHAIN 4
4747#define RELATED_REQUEST 8
4848
49+ /*
50+ *****************************************************************
51+ * Struct definitions go here
52+ *****************************************************************
53+ */
54+
55+ struct status_to_posix_error {
56+ __u32 smb2_status ;
57+ int posix_error ;
58+ char * status_string ;
59+ };
60+
4961#endif /* _SMB2_GLOB_H */
Original file line number Diff line number Diff line change 88 *
99 */
1010#include <linux/errno.h>
11- #include "cifsglob.h"
1211#include "cifsproto.h"
1312#include "cifs_debug.h"
1413#include "smb2proto.h"
1514#include "smb2glob.h"
1615#include "../common/smb2status.h"
1716#include "trace.h"
1817
19- struct status_to_posix_error {
20- __u32 smb2_status ;
21- int posix_error ;
22- char * status_string ;
23- };
24-
2518static const struct status_to_posix_error smb2_error_map_table [] = {
2619/*
2720 * Automatically generated by the `gen_smb2_mapping` script,
@@ -115,10 +108,19 @@ int __init smb2_init_maperror(void)
115108 return 0 ;
116109}
117110
118- #define SMB_CLIENT_KUNIT_AVAILABLE \
119- ((IS_MODULE(CONFIG_CIFS) && IS_ENABLED(CONFIG_KUNIT)) || \
120- (IS_BUILTIN(CONFIG_CIFS) && IS_BUILTIN(CONFIG_KUNIT)))
111+ #if IS_ENABLED (CONFIG_SMB_KUNIT_TESTS )
112+ /* Previous prototype for eliminating the build warning. */
113+ const struct status_to_posix_error * smb2_get_err_map_test (__u32 smb2_status );
114+
115+ const struct status_to_posix_error * smb2_get_err_map_test (__u32 smb2_status )
116+ {
117+ return smb2_get_err_map (smb2_status );
118+ }
119+ EXPORT_SYMBOL_GPL (smb2_get_err_map_test );
120+
121+ const struct status_to_posix_error * smb2_error_map_table_test = smb2_error_map_table ;
122+ EXPORT_SYMBOL_GPL (smb2_error_map_table_test );
121123
122- #if SMB_CLIENT_KUNIT_AVAILABLE && IS_ENABLED ( CONFIG_SMB_KUNIT_TESTS )
123- #include "smb2maperror_test.c"
124- #endif /* CONFIG_SMB_KUNIT_TESTS */
124+ unsigned int smb2_error_map_num = ARRAY_SIZE ( smb2_error_map_table );
125+ EXPORT_SYMBOL_GPL ( smb2_error_map_num );
126+ #endif
Original file line number Diff line number Diff line change 99 */
1010
1111#include <kunit/test.h>
12+ #include "smb2glob.h"
13+
14+ const struct status_to_posix_error * smb2_get_err_map_test (__u32 smb2_status );
15+ extern const struct status_to_posix_error * smb2_error_map_table_test ;
16+ extern unsigned int smb2_error_map_num ;
1217
1318static void
1419test_cmp_map (struct kunit * test , const struct status_to_posix_error * expect )
1520{
1621 const struct status_to_posix_error * result ;
1722
18- result = smb2_get_err_map (expect -> smb2_status );
23+ result = smb2_get_err_map_test (expect -> smb2_status );
1924 KUNIT_EXPECT_PTR_NE (test , NULL , result );
2025 KUNIT_EXPECT_EQ (test , expect -> smb2_status , result -> smb2_status );
2126 KUNIT_EXPECT_EQ (test , expect -> posix_error , result -> posix_error );
@@ -26,8 +31,8 @@ static void maperror_test_check_search(struct kunit *test)
2631{
2732 unsigned int i ;
2833
29- for (i = 0 ; i < ARRAY_SIZE ( smb2_error_map_table ) ; i ++ )
30- test_cmp_map (test , & smb2_error_map_table [i ]);
34+ for (i = 0 ; i < smb2_error_map_num ; i ++ )
35+ test_cmp_map (test , & smb2_error_map_table_test [i ]);
3136}
3237
3338static struct kunit_case maperror_test_cases [] = {
@@ -43,3 +48,4 @@ static struct kunit_suite maperror_suite = {
4348kunit_test_suite (maperror_suite );
4449
4550MODULE_LICENSE ("GPL" );
51+ MODULE_DESCRIPTION ("KUnit tests of SMB2 maperror" );
You can’t perform that action at this time.
0 commit comments