mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] printf: add escaped-string format tests
@ 2026-04-06  0:42 Shuvam Pandey
  2026-04-06 18:34 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Shuvam Pandey @ 2026-04-06  0:42 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt
  Cc: Andy Shevchenko, Rasmus Villemoes, Sergey Senozhatsky,
	Andrew Morton, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] printf: add escaped-string format tests
  2026-04-06  0:42 [PATCH] printf: add escaped-string format tests Shuvam Pandey
@ 2026-04-06 18:34 ` Andy Shevchenko
  2026-04-06 18:35   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-04-06 18:34 UTC (permalink / raw)
  To: Shuvam Pandey
  Cc: Petr Mladek, Steven Rostedt, Rasmus Villemoes,
	Sergey Senozhatsky, Andrew Morton, linux-kernel

On Mon, Apr 06, 2026 at 06:27:37AM +0545, Shuvam Pandey wrote:
> 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.

NAK. We have much more of them already. Check if they need to be translated
to KUnit, though.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] printf: add escaped-string format tests
  2026-04-06 18:34 ` Andy Shevchenko
@ 2026-04-06 18:35   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-04-06 18:35 UTC (permalink / raw)
  To: Shuvam Pandey
  Cc: Petr Mladek, Steven Rostedt, Rasmus Villemoes,
	Sergey Senozhatsky, Andrew Morton, linux-kernel

On Mon, Apr 06, 2026 at 09:35:01PM +0300, Andy Shevchenko wrote:
> On Mon, Apr 06, 2026 at 06:27:37AM +0545, Shuvam Pandey wrote:
> > 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.
> 
> NAK. We have much more of them already. Check if they need to be translated
> to KUnit, though.

Really, guys, if you have a mentor, ask them how to use `git grep ...`.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-06 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-06  0:42 [PATCH] printf: add escaped-string format tests Shuvam Pandey
2026-04-06 18:34 ` Andy Shevchenko
2026-04-06 18:35   ` Andy Shevchenko

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®