| 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 <[email protected]> |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
#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; |
| 17 |
|
| 18 |
static void |
| 19 |
test_cmp_map(struct kunit *test, const struct status_to_posix_error *expect) |
| 20 |
{ |
| 21 |
const struct status_to_posix_error *result; |
| 22 |
|
| 23 |
result = smb2_get_err_map_test(expect->smb2_status); |
| 24 |
KUNIT_EXPECT_PTR_NE(test, NULL, result); |
| 25 |
KUNIT_EXPECT_EQ(test, expect->smb2_status, result->smb2_status); |
| 26 |
KUNIT_EXPECT_EQ(test, expect->posix_error, result->posix_error); |
| 27 |
KUNIT_EXPECT_STREQ(test, expect->status_string, result->status_string); |
| 28 |
} |
| 29 |
|
| 30 |
static void maperror_test_check_search(struct kunit *test) |
| 31 |
{ |
| 32 |
unsigned int i; |
| 33 |
|
| 34 |
for (i = 0; i < smb2_error_map_num; i++) |
| 35 |
test_cmp_map(test, &smb2_error_map_table_test[i]); |
| 36 |
} |
| 37 |
|
| 38 |
static struct kunit_case maperror_test_cases[] = { |
| 39 |
KUNIT_CASE(maperror_test_check_search), |
| 40 |
{} |
| 41 |
}; |
| 42 |
|
| 43 |
static struct kunit_suite maperror_suite = { |
| 44 |
.name = "smb2_maperror", |
| 45 |
.test_cases = maperror_test_cases, |
| 46 |
}; |
| 47 |
|
| 48 |
kunit_test_suite(maperror_suite); |
| 49 |
|
| 50 |
MODULE_LICENSE("GPL"); |
| 51 |
MODULE_DESCRIPTION("KUnit tests of SMB2 maperror"); |