From: ChenXiaoSong <chenxiaosong@kylinos.cn>
The KUnit test are executed when cifs.ko is loaded.
The mapping_table_ERRDOS_check_search() checks whether all elements can be
correctly found in the array.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
fs/smb/client/netmisc_test.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/fs/smb/client/netmisc_test.c b/fs/smb/client/netmisc_test.c
index caa0892ec119..eae6c0c09519 100644
--- a/fs/smb/client/netmisc_test.c
+++ b/fs/smb/client/netmisc_test.c
@@ -67,10 +67,20 @@ static void test_cmp_nt_err_code_struct(struct kunit *test,
KUNIT_EXPECT_EQ(test, expect->nt_errcode, result->nt_errcode);
}
+static void test_cmp_smb_to_posix_error(struct kunit *test,
+ struct smb_to_posix_error *expect,
+ struct smb_to_posix_error *result)
+{
+ KUNIT_EXPECT_EQ(test, expect->smb_err, result->smb_err);
+ KUNIT_EXPECT_EQ(test, expect->posix_code, result->posix_code);
+}
+
/* ntstatus_to_dos_map_check_search */
DEFINE_CHECK_SEARCH_FUNC(ntstatus_to_dos, ntstatus, ntstatus_to_dos_map, ntstatus_to_dos_num);
/* nt_errs_check_search */
DEFINE_CHECK_SEARCH_FUNC(nt_err_code_struct, nt_errcode, nt_errs, nt_err_num);
+/* mapping_table_ERRDOS_check_search */
+DEFINE_CHECK_SEARCH_FUNC(smb_to_posix_error, smb_err, mapping_table_ERRDOS, errdos_num);
/*
* Before running these test cases, the smb_init_maperror()
@@ -84,6 +94,7 @@ static struct kunit_case maperror_test_cases[] = {
/* check search */
KUNIT_CASE(ntstatus_to_dos_map_check_search),
KUNIT_CASE(nt_errs_check_search),
+ KUNIT_CASE(mapping_table_ERRDOS_check_search),
{}
};
--
2.43.0