1 // SPDX-License-Identifier: LGPL-2.1 2 /* 3 * 4 * KUnit tests of SMB2 maperror 5 * 6 * Copyright (C) 2025 KylinSoft Co., Ltd. All rights reserved. 7 * Author(s): ChenXiaoSong <chenxiaosong@kylinos.cn> 8 * 9 */ 10 11 #include <kunit/test.h> 12 13 static void 14 test_cmp_map(struct kunit *test, const struct status_to_posix_error *expect) 15 { 16 const struct status_to_posix_error *result; 17 18 result = smb2_get_err_map(expect->smb2_status); 19 KUNIT_EXPECT_PTR_NE(test, NULL, result); 20 KUNIT_EXPECT_EQ(test, expect->smb2_status, result->smb2_status); 21 KUNIT_EXPECT_EQ(test, expect->posix_error, result->posix_error); 22 KUNIT_EXPECT_STREQ(test, expect->status_string, result->status_string); 23 } 24 25 static void maperror_test_check_search(struct kunit *test) 26 { 27 unsigned int i; 28 29 for (i = 0; i < ARRAY_SIZE(smb2_error_map_table); i++) 30 test_cmp_map(test, &smb2_error_map_table[i]); 31 } 32 33 static struct kunit_case maperror_test_cases[] = { 34 KUNIT_CASE(maperror_test_check_search), 35 {} 36 }; 37 38 static struct kunit_suite maperror_suite = { 39 .name = "smb2_maperror", 40 .test_cases = maperror_test_cases, 41 }; 42 43 kunit_test_suite(maperror_suite); 44 45 MODULE_LICENSE("GPL"); 46