Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

printf: add IPv6 address format tests

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.

Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Link: https://patch.msgid.link/20260317114548.98919-1-shuvampandey1@gmail.com
[pmladek@suse.com: Removed non-necessary details from the commit message.]
Signed-off-by: Petr Mladek <pmladek@suse.com>

authored by

Shuvam Pandey and committed by
Petr Mladek
f4cf0992 db9571a6

+22
+22
lib/tests/printf_kunit.c
··· 17 17 #include <linux/dcache.h> 18 18 #include <linux/socket.h> 19 19 #include <linux/in.h> 20 + #include <linux/in6.h> 20 21 21 22 #include <linux/gfp.h> 22 23 #include <linux/mm.h> ··· 438 437 static void 439 438 ip6(struct kunit *kunittest) 440 439 { 440 + const struct in6_addr addr = { 441 + .s6_addr = { 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 442 + 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 } 443 + }; 444 + const struct in6_addr single_zero = { 445 + .s6_addr = { 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 446 + 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08 } 447 + }; 448 + struct sockaddr_in6 sa = { 449 + .sin6_family = AF_INET6, 450 + .sin6_port = cpu_to_be16(12345), 451 + .sin6_addr = addr, 452 + }; 453 + 454 + test("00010002000300040005000600070008|0001:0002:0003:0004:0005:0006:0007:0008", 455 + "%pi6|%pI6", &addr, &addr); 456 + test("00010002000300040005000600070008|0001:0002:0003:0004:0005:0006:0007:0008", 457 + "%piS|%pIS", &sa, &sa); 458 + test("1:2:3:4:5:6:7:8", "%pI6c", &addr); 459 + test("1:0:3:4:5:6:7:8", "%pI6c", &single_zero); 460 + test("[1:2:3:4:5:6:7:8]:12345", "%pISpc", &sa); 441 461 } 442 462 443 463 static void