[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251208062100.3268777-16-chenxiaosong.chenxiaosong@linux.dev>
Date: Mon, 8 Dec 2025 14:20:45 +0800
From: chenxiaosong.chenxiaosong@...ux.dev
To: sfrench@...ba.org,
smfrench@...il.com,
linkinjeon@...nel.org,
linkinjeon@...ba.org
Cc: linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org,
liuzhengyuan@...inos.cn,
huhai@...inos.cn,
liuyun01@...inos.cn,
ChenXiaoSong <chenxiaosong@...inos.cn>
Subject: [PATCH 15/30] smb/client: introduce KUnit test to check search result of ntstatus_to_dos_map array
From: ChenXiaoSong <chenxiaosong@...inos.cn>
The KUnit test are executed when cifs.ko is loaded.
The ntstatus_to_dos_map_check_search() checks whether all elements can be
correctly found in the array.
Signed-off-by: ChenXiaoSong <chenxiaosong@...inos.cn>
---
fs/smb/client/netmisc_test.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/smb/client/netmisc_test.c b/fs/smb/client/netmisc_test.c
index b682098d2fc5..ade5005fecb7 100644
--- a/fs/smb/client/netmisc_test.c
+++ b/fs/smb/client/netmisc_test.c
@@ -46,6 +46,18 @@ static void __array ## _check_search(struct kunit *test) \
} \
}
+static void test_cmp_ntstatus_to_dos(struct kunit *test,
+ struct ntstatus_to_dos *expect,
+ struct ntstatus_to_dos *result)
+{
+ KUNIT_EXPECT_EQ(test, expect->dos_class, result->dos_class);
+ KUNIT_EXPECT_EQ(test, expect->dos_code, result->dos_code);
+ KUNIT_EXPECT_EQ(test, expect->ntstatus, result->ntstatus);
+}
+
+/* ntstatus_to_dos_map_check_search */
+DEFINE_CHECK_SEARCH_FUNC(ntstatus_to_dos, ntstatus, ntstatus_to_dos_map, ntstatus_to_dos_num);
+
/*
* Before running these test cases, the smb_init_maperror()
* function is called first.
@@ -53,6 +65,8 @@ static void __array ## _check_search(struct kunit *test) \
static struct kunit_case maperror_test_cases[] = {
/* check sort */
KUNIT_CASE(ntstatus_to_dos_map_check_sort),
+ /* check search */
+ KUNIT_CASE(ntstatus_to_dos_map_check_search),
{}
};
--
2.43.0
Powered by blists - more mailing lists