From: Shuvam Pandey <shuvampandey1@gmail.com>
To: Petr Mladek <pmladek@suse.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] printf: add IPv6 address format tests
Date: Tue, 17 Mar 2026 17:30:48 +0545 [thread overview]
Message-ID: <20260317114548.98919-1-shuvampandey1@gmail.com> (raw)
printf_kunit already covers IPv4 address formatting, but the ip6()
test case is empty even though printk-formats.rst documents %pI6,
%pi6, %pI6c, and generic %pIS variants.
Add focused IPv6 checks for raw and generic formatting, compressed
output, the single-zero %pI6c corner case, and bracketed port
formatting for sockaddr_in6.
Validated with the arm64 printf KUnit suite and a W=1 rebuild of
lib/tests/printf_kunit.o.
Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
---
lib/tests/printf_kunit.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
index c64bfe79652e..739c755dd1ab 100644
--- a/lib/tests/printf_kunit.c
+++ b/lib/tests/printf_kunit.c
@@ -17,6 +17,7 @@
#include <linux/dcache.h>
#include <linux/socket.h>
#include <linux/in.h>
+#include <linux/in6.h>
#include <linux/gfp.h>
#include <linux/mm.h>
@@ -437,6 +438,27 @@ ip4(struct kunit *kunittest)
static void
ip6(struct kunit *kunittest)
{
+ const struct in6_addr addr = {
+ .s6_addr = { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 }
+ };
+ const struct in6_addr single_zero = {
+ .s6_addr = { 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04,
+ 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 }
+ };
+ struct sockaddr_in6 sa = {
+ .sin6_family = AF_INET6,
+ .sin6_port = cpu_to_be16(12345),
+ .sin6_addr = addr,
+ };
+
+ test("00010002000300040005000600070008|0001:0002:0003:0004:0005:0006:0007:0008",
+ "%pi6|%pI6", &addr, &addr);
+ test("00010002000300040005000600070008|0001:0002:0003:0004:0005:0006:0007:0008",
+ "%piS|%pIS", &sa, &sa);
+ test("1:2:3:4:5:6:7:8", "%pI6c", &addr);
+ test("1:0:3:4:5:6:7:8", "%pI6c", &single_zero);
+ test("[1:2:3:4:5:6:7:8]:12345", "%pISpc", &sa);
}
static void
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-03-17 11:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 11:45 Shuvam Pandey [this message]
2026-03-17 14:14 ` Andy Shevchenko
2026-03-24 13:43 ` Petr Mladek
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=20260317114548.98919-1-shuvampandey1@gmail.com \
--to=shuvampandey1@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.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®