1 // SPDX-License-Identifier: GPL-2.0-only
3 * KUnit tests for channel helper functions
5 * Copyright (C) 2024 Intel Corporation
7 #include <net/mac80211.h>
9 #include <kunit/test.h>
11 MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
13 static const struct acs_average_db_case {
17 } acs_average_db_cases[] = {
19 .desc = "Smallest possible value, all filled",
21 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
22 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
28 .desc = "Biggest possible value, all filled",
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37 .desc = "Smallest possible value, partial filled",
39 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
40 0xff, 0xff, 0xff, 0xff, 0xff,
41 0xff, 0xff, 0xff, 0xff, 0xff,
47 .desc = "Biggest possible value, partial filled",
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0xff, 0xff, 0xff, 0xff, 0xff,
51 0xff, 0xff, 0xff, 0xff, 0xff,
57 .desc = "Adding -80dBm to -75dBm until it is still rounded to -79dBm",
59 75, 80, 80, 80, 80, 80, 80, 80, 80, 80,
60 80, 80, 80, 80, 80, 80, 80, 0xff, 0xff, 0xff,
66 .desc = "Adding -80dBm to -75dBm until it is just rounded to -80dBm",
68 75, 80, 80, 80, 80, 80, 80, 80, 80, 80,
69 80, 80, 80, 80, 80, 80, 80, 80, 0xff, 0xff,
76 KUNIT_ARRAY_PARAM_DESC(acs_average_db, acs_average_db_cases, desc)
78 static void test_acs_average_db(struct kunit *test)
80 const struct acs_average_db_case *params = test->param_value;
81 struct iwl_umac_scan_channel_survey_notif notif;
84 /* Test the values in the given order */
85 for (i = 0; i < ARRAY_SIZE(params->neg_dbm); i++)
86 notif.noise[i] = params->neg_dbm[i];
88 iwl_mvm_average_dbm_values(¬if),
91 /* Test in reverse order */
92 for (i = 0; i < ARRAY_SIZE(params->neg_dbm); i++)
93 notif.noise[ARRAY_SIZE(params->neg_dbm) - i - 1] =
96 iwl_mvm_average_dbm_values(¬if),
100 static struct kunit_case acs_average_db_case[] = {
101 KUNIT_CASE_PARAM(test_acs_average_db, acs_average_db_gen_params),
105 static struct kunit_suite acs_average_db = {
106 .name = "iwlmvm-acs-average-db",
107 .test_cases = acs_average_db_case,
110 kunit_test_suite(acs_average_db);