summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-08-29 15:21:21 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-08-29 18:39:11 -0400
commitb895f4fd824c4c1626523c0756214854c9b5640b (patch)
tree14a4faf82c00fc29238a6684431a5c5e3a7c66a0
parentca47f1b1e82bd1bfdda2fa2fcd74c681047f95bd (diff)
lib/test_printf.c: Add escaped string tests
This adds missing tests for %pE, escaped strings. 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>
-rw-r--r--lib/test_printf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 6a56dbf076ab..247b1adbbe0f 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