iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 4/4] unit: add invalid channels/freqs to test-band
Date: Thu, 29 Dec 2022 16:24:28 -0800	[thread overview]
Message-ID: <20221230002428.2870506-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20221230002428.2870506-1-prestwoj@gmail.com>

Tests some channels and frequencies that are not in E-4 and
would pass the conversion without validation.
---
 unit/test-band.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/unit/test-band.c b/unit/test-band.c
index c47069f7..caddbcdd 100644
--- a/unit/test-band.c
+++ b/unit/test-band.c
@@ -650,6 +650,26 @@ static void test_6ghz_freqs(const void *data)
 	}
 }
 
+static void test_conversions(const void *data)
+{
+	/*
+	 * Test a few invalid channels/frequencies that appear valid but are
+	 * not in the E-4 table. The checks in band.c seem to cover 2.4Ghz and
+	 * 6Ghz very well since there are no gaps, but the 5GHz band has some
+	 * segmentation.
+	 */
+
+	/* Gap in 5GHz channels between 68 and 96 */
+	assert(!band_channel_to_freq(72, BAND_FREQ_5_GHZ));
+	assert(!band_freq_to_channel(5360, NULL));
+
+	/* Invalid channel using 4000mhz starting frequency */
+	assert(!band_channel_to_freq(183, BAND_FREQ_5_GHZ));
+	assert(!band_freq_to_channel(4915, NULL));
+
+	assert(!band_channel_to_freq(192, BAND_FREQ_5_GHZ));
+}
+
 int main(int argc, char *argv[])
 {
 	l_test_init(&argc, &argv);
@@ -715,5 +735,7 @@ int main(int argc, char *argv[])
 	l_test_add("/band/6ghz/channels", test_6ghz_channels, NULL);
 	l_test_add("/band/6ghz/freq", test_6ghz_freqs, NULL);
 
+	l_test_add("/band/conversions", test_conversions, NULL);
+
 	return l_test_run();
 }
-- 
2.34.3


  parent reply	other threads:[~2022-12-30  0:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-30  0:24 [PATCH 1/4] monitor: fix buffer overrun parsing country IE James Prestwood
2022-12-30  0:24 ` [PATCH 2/4] unit: fix test-band for 6ghz frequencies James Prestwood
2022-12-30  0:24 ` [PATCH 3/4] band: validate channel/freq conversions with E-4 James Prestwood
2022-12-30  0:24 ` James Prestwood [this message]
2022-12-30 18:05 ` [PATCH 1/4] monitor: fix buffer overrun parsing country IE Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221230002428.2870506-4-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).