This modifier was recently added. Turn the description from its commit
message into a test.

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 test/self/printf.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/test/self/printf.c b/test/self/printf.c
index ec74df32ee4b..7a74660868c2 100644
--- a/test/self/printf.c
+++ b/test/self/printf.c
@@ -277,6 +277,23 @@ errptr(void)
        test("Requested probe deferral", "%pe", ERR_PTR(-EPROBE_DEFER));
 }
 
+static void __init
+test_hexstr(void)
+{
+       u8 buf[4] = { 0, 1, 2, 3 };
+
+       if (!IS_ENABLED(CONFIG_PRINTF_HEXSTR)) {
+               pr_info("skipping hexstr tests: disabled in config\n");
+               skipped_tests += 4;
+               return;
+       }
+
+       test("[00 01 02 03]", "[%*ph]",  (int)sizeof(buf), buf);
+       test("[00:01:02:03]", "[%*phC]", (int)sizeof(buf), buf);
+       test("[00-01-02-03]", "[%*phD]", (int)sizeof(buf), buf);
+       test("[00010203]",    "[%*phN]", (int)sizeof(buf), buf);
+}
+
 static void __init
 test_pointer(void)
 {
@@ -299,6 +316,7 @@ static void __init test_printf(void)
        test_number();
        test_string();
        test_pointer();
+       test_hexstr();
 
        free(alloced_buffer);
 }
-- 
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to