1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* KUnit tests for channel helper functions
*
* Copyright (C) 2024 Intel Corporation
*/
#include <kunit/test.h>
#include <iwl-trans.h>
#include "mld.h"
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
static void test_hcmd_names_sorted(struct kunit *test)
{
int i;
for (i = 0; i < global_iwl_mld_goups_size; i++) {
const struct iwl_hcmd_arr *arr = &iwl_mld_groups[i];
int j;
if (!arr->arr)
continue;
for (j = 0; j < arr->size - 1; j++)
KUNIT_EXPECT_LE(test, arr->arr[j].cmd_id,
arr->arr[j + 1].cmd_id);
}
}
static void test_hcmd_names_for_rx(struct kunit *test)
{
static struct iwl_trans t = {
.command_groups = iwl_mld_groups,
};
t.command_groups_size = global_iwl_mld_goups_size;
for (unsigned int i = 0; i < iwl_mld_rx_handlers_num; i++) {
const struct iwl_rx_handler *rxh;
const char *name;
rxh = &iwl_mld_rx_handlers[i];
name = iwl_get_cmd_string(&t, rxh->cmd_id);
KUNIT_EXPECT_NOT_NULL(test, name);
KUNIT_EXPECT_NE_MSG(test, strcmp(name, "UNKNOWN"), 0,
"ID 0x%04x is UNKNOWN", rxh->cmd_id);
}
}
static struct kunit_case hcmd_names_cases[] = {
KUNIT_CASE(test_hcmd_names_sorted),
KUNIT_CASE(test_hcmd_names_for_rx),
{},
};
static struct kunit_suite hcmd_names = {
.name = "iwlmld-hcmd-names",
.test_cases = hcmd_names_cases,
};
kunit_test_suite(hcmd_names);
|