Linux Audio

Check our new training course

Loading...
Note: File does not exist in v5.14.15.
 1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 2/*
 3 * KUnit tests for the iwlwifi device info table
 4 *
 5 * Copyright (C) 2023 Intel Corporation
 6 */
 7#include <kunit/test.h>
 8#include "iwl-drv.h"
 9#include "iwl-config.h"
10
11MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING);
12
13static void iwl_pci_print_dev_info(const char *pfx, const struct iwl_dev_info *di)
14{
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,
18	       di->cores);
19}
20
21static void devinfo_table_order(struct kunit *test)
22{
23	int idx;
24
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;
28
29		ret = iwl_pci_find_dev_info(di->device, di->subdevice,
30					    di->mac_type, di->mac_step,
31					    di->rf_type, di->cdb,
32					    di->jacket, di->rf_id,
33					    di->no_160, di->cores, di->rf_step);
34		if (ret != di) {
35			iwl_pci_print_dev_info("searched: ", di);
36			iwl_pci_print_dev_info("found:    ", ret);
37			KUNIT_FAIL(test,
38				   "unusable entry at index %d (found index %d instead)\n",
39				   idx, (int)(ret - iwl_dev_info_table));
40		}
41	}
42}
43
44static struct kunit_case devinfo_test_cases[] = {
45	KUNIT_CASE(devinfo_table_order),
46	{}
47};
48
49static struct kunit_suite iwlwifi_devinfo = {
50	.name = "iwlwifi-devinfo",
51	.test_cases = devinfo_test_cases,
52};
53
54kunit_test_suite(iwlwifi_devinfo);