Linux wireless drivers development
 help / color / mirror / Atom feed
From: Masashi Honma <masashi.honma@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Masashi Honma <masashi.honma@gmail.com>
Subject: [PATCH v9 8/9] Add KUnit test for ieee80211_mesh_prep_size_ok
Date: Sat, 30 May 2026 08:09:50 +0900	[thread overview]
Message-ID: <20260529230952.124754-8-masashi.honma@gmail.com> (raw)
In-Reply-To: <20260529230952.124754-1-masashi.honma@gmail.com>

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 net/mac80211/tests/elems.c | 53 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/net/mac80211/tests/elems.c b/net/mac80211/tests/elems.c
index 576ba746a526..b96424d5d025 100644
--- a/net/mac80211/tests/elems.c
+++ b/net/mac80211/tests/elems.c
@@ -97,6 +97,46 @@ static const struct mesh_preq_parse_test_case {
 
 KUNIT_ARRAY_PARAM_DESC(mesh_preq_parse, mesh_preq_parse_cases, desc);
 
+static const struct mesh_prep_parse_test_case {
+	const char *desc;
+	u8 len;
+	bool ae_enabled;
+	bool result;
+} mesh_prep_parse_cases[] = {
+	{
+		.desc = "shorter than header",
+		.len = 12,
+		.ae_enabled = false,
+		.result = false,
+	},
+	{
+		.desc = "non AE short",
+		.len = 30,
+		.ae_enabled = false,
+		.result = false,
+	},
+	{
+		.desc = "non AE",
+		.len = 31,
+		.ae_enabled = false,
+		.result = true,
+	},
+	{
+		.desc = "AE short",
+		.len = 36,
+		.ae_enabled = true,
+		.result = false,
+	},
+	{
+		.desc = "AE",
+		.len = 37,
+		.ae_enabled = true,
+		.result = true,
+	},
+};
+
+KUNIT_ARRAY_PARAM_DESC(mesh_prep_parse, mesh_prep_parse_cases, desc);
+
 static void mle_defrag(struct kunit *test)
 {
 	struct ieee80211_elems_parse_params parse_params = {
@@ -195,9 +235,22 @@ static void mesh_preq_parse(struct kunit *test)
 			params->result);
 }
 
+static void mesh_prep_parse(struct kunit *test)
+{
+	const struct mesh_prep_parse_test_case *params = test->param_value;
+	u8 data[64] = {};
+	struct ieee80211_mesh_hwmp_prep_top *top = (void *)data;
+	top->flags = params->ae_enabled ? AE_F : 0;
+
+	KUNIT_EXPECT_EQ(test,
+			ieee80211_mesh_prep_size_ok(data, params->len),
+			params->result);
+}
+
 static struct kunit_case element_parsing_test_cases[] = {
 	KUNIT_CASE(mle_defrag),
 	KUNIT_CASE_PARAM(mesh_preq_parse, mesh_preq_parse_gen_params),
+	KUNIT_CASE_PARAM(mesh_prep_parse, mesh_prep_parse_gen_params),
 	{}
 };
 
-- 
2.43.0


  parent reply	other threads:[~2026-05-29 23:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 23:09 [PATCH v9 1/9] wifi: mac80211: Use struct instead of macro for PREQ frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 2/9] wifi: mac80211: Use struct instead of macro for PREP frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 3/9] wifi: mac80211: Use struct instead of macro for PERR frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 4/9] wifi: mac80211: Fix overread in PREQ frame processing Masashi Honma
2026-05-29 23:09 ` [PATCH v9 5/9] wifi: mac80211: Fix overread in PREP " Masashi Honma
2026-05-29 23:09 ` [PATCH v9 6/9] wifi: mac80211: Fix PERR " Masashi Honma
2026-05-29 23:09 ` [PATCH v9 7/9] Add KUnit test for ieee80211_mesh_preq_size_ok Masashi Honma
2026-05-29 23:09 ` Masashi Honma [this message]
2026-05-29 23:09 ` [PATCH v9 9/9] Add KUnit test for ieee80211_mesh_perr_size_ok Masashi Honma

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=20260529230952.124754-8-masashi.honma@gmail.com \
    --to=masashi.honma@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /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