summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-02-07 09:27:58 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-02-07 09:35:41 +0100
commit616ff0948058b96c258caa95c93b2b61ec746ca7 (patch)
tree9bf8d0fa530f96046acedcc2b95e91fa080850e1 /test
parentfb069fb87df4f767635a3d5688f1933b2433418c (diff)
downloadbarebox-616ff0948058b96c258caa95c93b2b61ec746ca7.tar.gz
barebox-616ff0948058b96c258caa95c93b2b61ec746ca7.tar.xz
test: self: printf: add tests for %*ph prints
This modifier was recently added. Turn the description from its commit message into a test. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220207082801.1052894-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'test')
-rw-r--r--test/self/printf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/self/printf.c b/test/self/printf.c
index ec74df32ee..7a74660868 100644
--- a/test/self/printf.c
+++ b/test/self/printf.c
@@ -278,6 +278,23 @@ errptr(void)
}
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)
{
null_pointer();
@@ -299,6 +316,7 @@ static void __init test_printf(void)
test_number();
test_string();
test_pointer();
+ test_hexstr();
free(alloced_buffer);
}