mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/5] test: self: printf: add tests for %*ph prints
Date: Mon,  7 Feb 2022 08:56:18 +0100	[thread overview]
Message-ID: <20220207075621.1014381-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220207075621.1014381-1-a.fatoum@pengutronix.de>

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

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2022-02-07  7:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07  7:56 [PATCH 1/5] test: self: printf: log skipped tests Ahmad Fatoum
2022-02-07  7:56 ` Ahmad Fatoum [this message]
2022-02-07  7:56 ` [PATCH 3/5] of: report whether of_diff found differences in return code Ahmad Fatoum
2022-02-07  7:56 ` [PATCH 4/5] of: silence of_diff output for negative indents Ahmad Fatoum
2022-02-07  8:17   ` Sascha Hauer
2022-02-07  8:22     ` Sascha Hauer
2022-02-07  8:23       ` Ahmad Fatoum
2022-02-07  7:56 ` [PATCH 5/5] test: self: add device tree manipulation test Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220207075621.1014381-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox