[PATCH 2/2] lib/test_printf.c: Add escaped string tests
From: Kent Overstreet
Date: Mon Aug 29 2022 - 20:31:38 EST
This adds missing tests for %pE, escaped strings.
Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
Cc: Petr Mladek <pmladek@xxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
lib/test_printf.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 6a56dbf076..247b1adbbe 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -413,6 +413,21 @@ addr(void)
static void __init
escaped_str(void)
{
+ const char buf[] = "test \f\n\r\t\v \"\\\a\e \0 end";
+ unsigned n = strlen(buf), with_embedded_nul = sizeof(buf) - 1;
+
+ /* ESCAPE_ANY_NP: */
+ test("test \\f\\n\\r\\t\\v \"\\\\a\\e ", "%*pE", n, buf);
+ /* ESCAPE_ANY: */
+ //test("test \\f\\n\\r\\t\\v \"\\\\a\\e end", "%*pEa", n, buf);
+ /* ESCAPE_SPACE: */
+ test("test \\f\\n\\r\\t\\v \"\\\x07\x1b ", "%*pEs", n, buf);
+
+ /* ESCAPE_SPECIAL: */
+ test("test \f\n\r\t\v \\\"\\\\\\a\\e ", "%*pEc", n, buf);
+
+ /* ESCAPE_NULL: */
+ test("test \f\n\r\t\v \"\\\a\e \\0 end", "%*pEn", with_embedded_nul, buf);
}
static void __init
--
2.36.1