mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] printf: add escaped-string format tests
Date: Mon,  6 Apr 2026 06:27:37 +0545	[thread overview]
Message-ID: <20260406004237.16189-1-shuvampandey1@gmail.com> (raw)

printf_kunit leaves escaped_str() empty even though printk-formats.rst
documents %*pE conversions and says that omitting the field width
escapes one byte only.

Add tests for the documented %*pE, %*pEhp, and %*pEa conversions, and
for the single-byte %pE default when the field width is omitted.

Signed-off-by: Shuvam Pandey <shuvampandey1@gmail.com>
---
 lib/tests/printf_kunit.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
index f6f21b445..8ea67abf1 100644
--- a/lib/tests/printf_kunit.c
+++ b/lib/tests/printf_kunit.c
@@ -394,6 +394,14 @@ addr(struct kunit *kunittest)
 static void
 escaped_str(struct kunit *kunittest)
 {
+	const u8 buf[] = { 0x1b, 0x62, 0x20, 0x5c, 0x43,
+			   0x07, 0x22, 0x90, 0x0d, 0x5d };
+
+	test("\\eb \\C\\a\"\\220\\r]", "%*pE", 10, buf);
+	test("\\x1bb \\C\\x07\"\\x90\\x0d]", "%*pEhp", 10, buf);
+	test("\\e\\142\\040\\\\\\103\\a\\\"\\220\\r\\135",
+	     "%*pEa", 10, buf);
+	test("\\e", "%pE", buf);
 }
 
 static void

             reply	other threads:[~2026-04-06  0:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-06  0:42 Shuvam Pandey [this message]
2026-04-06 18:34 ` Andy Shevchenko
2026-04-06 18:35   ` 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=20260406004237.16189-1-shuvampandey1@gmail.com \
    --to=shuvampandey1@gmail.com \
    --cc=akpm@linux-foundation.org \
    --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®