Re: [PATCH 2/2] lib/test_printf.c: Add escaped string tests
From: Rasmus Villemoes
Date: Tue Aug 30 2022 - 03:51:45 EST
On 30/08/2022 02.31, Kent Overstreet wrote:
> 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);
Is there a reason that one is commented out?
> + /* 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);
> }
Perhaps also include a few byte values >= 128. Otherwise looks good.
Rasmus