From: Shuvam Pandey <shuvampandey1@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] lib/tests: extend cmdline next_arg() coverage with mixed tokens
Date: Tue, 17 Mar 2026 02:57:49 +0545 [thread overview]
Message-ID: <20260316211249.88601-1-shuvampandey1@gmail.com> (raw)
In-Reply-To: <20260316101227.15807-1-shuvampandey1@gmail.com>
The cmdline KUnit suite now covers quoted values and the bare quote
regression path in next_arg(), but it still does not exercise a mixed
sequence containing an empty value, a bare token, and a quoted value
with '='.
Andy Shevchenko suggested covering a sequence such as
"bbb= jjj kkk=\"a=b\"". Add that case so the suite checks all three
forms in one parse stream.
Validated with the arm64 cmdline KUnit suite and a W=1 rebuild of
lib/tests/cmdline_kunit.o.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
---
lib/tests/cmdline_kunit.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/tests/cmdline_kunit.c b/lib/tests/cmdline_kunit.c
index b5c7aba65f43..af44ae9e92c3 100644
--- a/lib/tests/cmdline_kunit.c
+++ b/lib/tests/cmdline_kunit.c
@@ -175,6 +175,29 @@ static void cmdline_test_next_arg_bare_quote_regression(struct kunit *test)
KUNIT_EXPECT_STREQ(test, next, "");
}
+static void cmdline_test_next_arg_mixed_tokens(struct kunit *test)
+{
+ char in[] = "bbb= jjj kkk=\"a=b\"";
+ char *next, *param, *val;
+
+ next = next_arg(in, ¶m, &val);
+ KUNIT_EXPECT_STREQ(test, param, "bbb");
+ KUNIT_ASSERT_NOT_NULL(test, val);
+ KUNIT_EXPECT_STREQ(test, val, "");
+ KUNIT_EXPECT_STREQ(test, next, "jjj kkk=\"a=b\"");
+
+ next = next_arg(next, ¶m, &val);
+ KUNIT_EXPECT_STREQ(test, param, "jjj");
+ KUNIT_EXPECT_NULL(test, val);
+ KUNIT_EXPECT_STREQ(test, next, "kkk=\"a=b\"");
+
+ next = next_arg(next, ¶m, &val);
+ KUNIT_EXPECT_STREQ(test, param, "kkk");
+ KUNIT_ASSERT_NOT_NULL(test, val);
+ KUNIT_EXPECT_STREQ(test, val, "a=b");
+ KUNIT_EXPECT_STREQ(test, next, "");
+}
+
static struct kunit_case cmdline_test_cases[] = {
KUNIT_CASE(cmdline_test_noint),
KUNIT_CASE(cmdline_test_lead_int),
@@ -182,6 +205,7 @@ static struct kunit_case cmdline_test_cases[] = {
KUNIT_CASE(cmdline_test_range),
KUNIT_CASE(cmdline_test_next_arg_quoted_value),
KUNIT_CASE(cmdline_test_next_arg_bare_quote_regression),
+ KUNIT_CASE(cmdline_test_next_arg_mixed_tokens),
{}
};
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-03-16 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 10:12 [PATCH] lib/tests: extend cmdline KUnit with next_arg() tests Shuvam Pandey
2026-03-16 21:12 ` Shuvam Pandey [this message]
2026-03-16 21:18 ` [PATCH] lib/tests: extend cmdline next_arg() coverage with mixed tokens Andy Shevchenko
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=20260316211249.88601-1-shuvampandey1@gmail.com \
--to=shuvampandey1@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®