wifi: iwlwifi: mvm: add command order checks to kunit

We can test this with kunit instead of having the runtime
checks, add a test here to remove the runtime check next.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250502155404.581b60b0833f.I624fb3efc3fa0b155a5da69d7efc39207f133331@changeid
This commit is contained in:
Johannes Berg
2025-05-02 15:56:30 +03:00
committed by Miri Korenblit
parent 332fbf871d
commit 0b897fbd90
4 changed files with 50 additions and 2 deletions

View File

@@ -2129,6 +2129,10 @@ bool iwl_mvm_mld_valid_link_pair(struct ieee80211_vif *vif,
const struct iwl_mvm_link_sel_data *b);
s8 iwl_mvm_average_dbm_values(const struct iwl_umac_scan_channel_survey_notif *notif);
extern const struct iwl_hcmd_arr iwl_mvm_groups[];
extern const unsigned int iwl_mvm_groups_size;
#endif
/* AP and IBSS */

View File

@@ -777,7 +777,8 @@ static const struct iwl_hcmd_names iwl_mvm_bt_coex_names[] = {
HCMD_NAME(PROFILE_NOTIF),
};
static const struct iwl_hcmd_arr iwl_mvm_groups[] = {
VISIBLE_IF_IWLWIFI_KUNIT
const struct iwl_hcmd_arr iwl_mvm_groups[] = {
[LEGACY_GROUP] = HCMD_ARR(iwl_mvm_legacy_names),
[LONG_GROUP] = HCMD_ARR(iwl_mvm_legacy_names),
[SYSTEM_GROUP] = HCMD_ARR(iwl_mvm_system_names),
@@ -793,6 +794,11 @@ static const struct iwl_hcmd_arr iwl_mvm_groups[] = {
[DEBUG_GROUP] = HCMD_ARR(iwl_mvm_debug_names),
[STATISTICS_GROUP] = HCMD_ARR(iwl_mvm_statistics_names),
};
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mvm_groups);
#if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS)
const unsigned int iwl_mvm_groups_size = ARRAY_SIZE(iwl_mvm_groups);
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_mvm_groups_size);
#endif
/* this forward declaration can avoid to export the function */
static void iwl_mvm_async_handlers_wk(struct work_struct *wk);

View File

@@ -1,3 +1,3 @@
iwlmvm-tests-y += module.o links.o scan.o
iwlmvm-tests-y += module.o links.o scan.o hcmd.o
obj-$(CONFIG_IWLWIFI_KUNIT_TESTS) += iwlmvm-tests.o

View File

@@ -0,0 +1,38 @@
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* KUnit tests for channel helper functions
*
* Copyright (C) 2025 Intel Corporation
*/
#include <kunit/test.h>
#include <iwl-trans.h>
#include "../mvm.h"
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
static void test_hcmd_names_sorted(struct kunit *test)
{
for (int i = 0; i < iwl_mvm_groups_size; i++) {
const struct iwl_hcmd_arr *arr = &iwl_mvm_groups[i];
if (!arr->arr)
continue;
for (int j = 0; j < arr->size - 1; j++)
KUNIT_EXPECT_LE(test, arr->arr[j].cmd_id,
arr->arr[j + 1].cmd_id);
}
}
static struct kunit_case hcmd_names_cases[] = {
KUNIT_CASE(test_hcmd_names_sorted),
{},
};
static struct kunit_suite hcmd_names = {
.name = "iwlmvm-hcmd-names",
.test_cases = hcmd_names_cases,
};
kunit_test_suite(hcmd_names);