From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-kernel@vger.kernel.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>,
Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 1/2] lib/test_printf.c: Add ip6 tests
Date: Mon, 29 Aug 2022 20:31:18 -0400 [thread overview]
Message-ID: <20220830003119.1793219-2-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20220830003119.1793219-1-kent.overstreet@linux.dev>
This adds missing tests for ip6 address: both bare address and
sockaddr_in6, as well as the additional flags for compressed address,
port, scope and flow.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
lib/test_printf.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 4bd15a593f..6a56dbf076 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -18,6 +18,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>
@@ -61,6 +62,9 @@ do_test(int bufsize, const char *expect, int elen,
pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n",
bufsize, fmt, ret, elen);
return 1;
+ pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d (%s != %s)\n",
+ bufsize, fmt, ret, elen, test_buffer, expect);
+ return 1;
}
if (memchr_inv(alloced_buffer, FILL_CHAR, PAD_SIZE)) {
@@ -452,6 +456,31 @@ ip4(void)
static void __init
ip6(void)
{
+ struct sockaddr_in6 sa = { .sin6_family = AF_INET6 };
+
+ sa.sin6_port = cpu_to_be16(12345);
+ sa.sin6_addr.in6_u.u6_addr16[0] = cpu_to_be16(1);
+ sa.sin6_addr.in6_u.u6_addr16[1] = cpu_to_be16(2);
+ sa.sin6_addr.in6_u.u6_addr16[6] = cpu_to_be16(7);
+ sa.sin6_addr.in6_u.u6_addr16[7] = cpu_to_be16(8);
+ sa.sin6_flowinfo = cpu_to_be32(8008);
+ sa.sin6_scope_id = 4004;
+
+ test("00010002000000000000000000070008", "%pi6", &sa.sin6_addr);
+ test("00010002000000000000000000070008", "%piS", &sa);
+ test("0001:0002:0000:0000:0000:0000:0007:0008", "%pI6", &sa.sin6_addr);
+ test("0001:0002:0000:0000:0000:0000:0007:0008", "%pIS", &sa);
+ test("1:2::7:8", "%pISc", &sa);
+
+ test("[0001:0002:0000:0000:0000:0000:0007:0008]:12345", "%pISp", &sa);
+ test("[0001:0002:0000:0000:0000:0000:0007:0008]%4004", "%pISs", &sa);
+ test("[0001:0002:0000:0000:0000:0000:0007:0008]/8008", "%pISf", &sa);
+
+ test("[1:2::7:8]:12345", "%pIScp", &sa);
+ test("[1:2::7:8]%4004", "%pIScs", &sa);
+ test("[1:2::7:8]/8008", "%pIScf", &sa);
+
+ test("[1:2::7:8]:12345/8008%4004", "%pIScpsf", &sa);
}
static void __init
--
2.36.1
next prev parent reply other threads:[~2022-08-30 0:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-30 0:31 ip6, escaped_string tests Kent Overstreet
2022-08-30 0:31 ` Kent Overstreet [this message]
2022-08-30 1:47 ` [PATCH 1/2] lib/test_printf.c: Add ip6 tests Sergey Senozhatsky
2022-08-30 7:32 ` Rasmus Villemoes
2022-08-30 16:34 ` Kent Overstreet
2022-08-30 0:31 ` [PATCH 2/2] lib/test_printf.c: Add escaped string tests Kent Overstreet
2022-08-30 7:51 ` Rasmus Villemoes
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=20220830003119.1793219-2-kent.overstreet@linux.dev \
--to=kent.overstreet@linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.