1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * KUnit tests for the iwlwifi device info table
5 * Copyright (C) 2023 Intel Corporation
7 #include <kunit/test.h>
9 #include "iwl-config.h"
11 MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);
13 static void iwl_pci_print_dev_info(const char *pfx, const struct iwl_dev_info *di)
15 printk(KERN_DEBUG "%sdev=%.4x,subdev=%.4x,mac_type=%.4x,mac_step=%.4x,rf_type=%.4x,cdb=%d,jacket=%d,rf_id=%.2x,no_160=%d,cores=%.2x\n",
16 pfx, di->device, di->subdevice, di->mac_type, di->mac_step,
17 di->rf_type, di->cdb, di->jacket, di->rf_id, di->no_160,
21 static void devinfo_table_order(struct kunit *test)
25 for (idx = 0; idx < iwl_dev_info_table_size; idx++) {
26 const struct iwl_dev_info *di = &iwl_dev_info_table[idx];
27 const struct iwl_dev_info *ret;
29 ret = iwl_pci_find_dev_info(di->device, di->subdevice,
30 di->mac_type, di->mac_step,
32 di->jacket, di->rf_id,
33 di->no_160, di->cores, di->rf_step);
35 iwl_pci_print_dev_info("searched: ", di);
36 iwl_pci_print_dev_info("found: ", ret);
38 "unusable entry at index %d (found index %d instead)\n",
39 idx, (int)(ret - iwl_dev_info_table));
44 static struct kunit_case devinfo_test_cases[] = {
45 KUNIT_CASE(devinfo_table_order),
49 static struct kunit_suite iwlwifi_devinfo = {
50 .name = "iwlwifi-devinfo",
51 .test_cases = devinfo_test_cases,
54 kunit_test_suite(iwlwifi_devinfo);