xref: /freebsd/sys/contrib/dev/iwlwifi/mvm/tests/hcmd.c (revision 6b627f88584ce13118e0a24951b503c0b1f2d5a7)
1*6b627f88SBjoern A. Zeeb // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2*6b627f88SBjoern A. Zeeb /*
3*6b627f88SBjoern A. Zeeb  * KUnit tests for channel helper functions
4*6b627f88SBjoern A. Zeeb  *
5*6b627f88SBjoern A. Zeeb  * Copyright (C) 2025 Intel Corporation
6*6b627f88SBjoern A. Zeeb  */
7*6b627f88SBjoern A. Zeeb #include <kunit/test.h>
8*6b627f88SBjoern A. Zeeb 
9*6b627f88SBjoern A. Zeeb #include <iwl-trans.h>
10*6b627f88SBjoern A. Zeeb #include "../mvm.h"
11*6b627f88SBjoern A. Zeeb 
12*6b627f88SBjoern A. Zeeb MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
13*6b627f88SBjoern A. Zeeb 
test_hcmd_names_sorted(struct kunit * test)14*6b627f88SBjoern A. Zeeb static void test_hcmd_names_sorted(struct kunit *test)
15*6b627f88SBjoern A. Zeeb {
16*6b627f88SBjoern A. Zeeb 	for (int i = 0; i < iwl_mvm_groups_size; i++) {
17*6b627f88SBjoern A. Zeeb 		const struct iwl_hcmd_arr *arr = &iwl_mvm_groups[i];
18*6b627f88SBjoern A. Zeeb 
19*6b627f88SBjoern A. Zeeb 		if (!arr->arr)
20*6b627f88SBjoern A. Zeeb 			continue;
21*6b627f88SBjoern A. Zeeb 
22*6b627f88SBjoern A. Zeeb 		for (int j = 0; j < arr->size - 1; j++)
23*6b627f88SBjoern A. Zeeb 			KUNIT_EXPECT_LE(test, arr->arr[j].cmd_id,
24*6b627f88SBjoern A. Zeeb 					arr->arr[j + 1].cmd_id);
25*6b627f88SBjoern A. Zeeb 	}
26*6b627f88SBjoern A. Zeeb }
27*6b627f88SBjoern A. Zeeb 
28*6b627f88SBjoern A. Zeeb static struct kunit_case hcmd_names_cases[] = {
29*6b627f88SBjoern A. Zeeb 	KUNIT_CASE(test_hcmd_names_sorted),
30*6b627f88SBjoern A. Zeeb 	{},
31*6b627f88SBjoern A. Zeeb };
32*6b627f88SBjoern A. Zeeb 
33*6b627f88SBjoern A. Zeeb static struct kunit_suite hcmd_names = {
34*6b627f88SBjoern A. Zeeb 	.name = "iwlmvm-hcmd-names",
35*6b627f88SBjoern A. Zeeb 	.test_cases = hcmd_names_cases,
36*6b627f88SBjoern A. Zeeb };
37*6b627f88SBjoern A. Zeeb 
38*6b627f88SBjoern A. Zeeb kunit_test_suite(hcmd_names);
39