public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Rob Clark <robdclark@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] video: test: Helper for writing strings
Date: Mon, 25 Sep 2017 15:45:08 -0400	[thread overview]
Message-ID: <20170925194511.15872-1-robdclark@gmail.com> (raw)

I'll need some more of this, let's not just copy-pasta the
vidconsole_put_char() loop.

Named to match vidconsole_put_char() in case that is ever useful
outside of the tests.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 test/dm/video.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/test/dm/video.c b/test/dm/video.c
index 4d000fa1be..6a5626c5e3 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -100,6 +100,14 @@ static int select_vidconsole(struct unit_test_state *uts, const char *drv_name)
 	return 0;
 }
 
+static void vidconsole_put_string(struct udevice *dev, const char *str)
+{
+	const char *s;
+
+	for (s = str; *s; s++)
+		vidconsole_put_char(dev, *s);
+}
+
 /* Test text output works on the video console */
 static int dm_test_video_text(struct unit_test_state *uts)
 {
@@ -140,13 +148,11 @@ static int dm_test_video_chars(struct unit_test_state *uts)
 {
 	struct udevice *dev, *con;
 	const char *test_string = "Well\b\b\b\bxhe is\r \n\ta very \amodest  \bman\n\t\tand Has much to\b\bto be modest about.";
-	const char *s;
 
 	ut_assertok(select_vidconsole(uts, "vidconsole0"));
 	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
 	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
-	for (s = test_string; *s; s++)
-		vidconsole_put_char(con, *s);
+	vidconsole_put_string(con, test_string);
 	ut_asserteq(466, compress_frame_buffer(dev));
 
 	return 0;
@@ -294,12 +300,10 @@ static int dm_test_video_truetype(struct unit_test_state *uts)
 {
 	struct udevice *dev, *con;
 	const char *test_string = "Criticism may not be agreeable, but it is necessary. It fulfils the same function as pain in the human body. It calls attention to an unhealthy state of things. Some see private enterprise as a predatory target to be shot, others as a cow to be milked, but few are those who see it as a sturdy horse pulling the wagon. The \aprice OF\b\bof greatness\n\tis responsibility.\n\nBye";
-	const char *s;
 
 	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
 	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
-	for (s = test_string; *s; s++)
-		vidconsole_put_char(con, *s);
+	vidconsole_put_string(con, test_string);
 	ut_asserteq(12619, compress_frame_buffer(dev));
 
 	return 0;
@@ -312,7 +316,6 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
 	struct sandbox_sdl_plat *plat;
 	struct udevice *dev, *con;
 	const char *test_string = "Criticism may not be agreeable, but it is necessary. It fulfils the same function as pain in the human body. It calls attention to an unhealthy state of things. Some see private enterprise as a predatory target to be shot, others as a cow to be milked, but few are those who see it as a sturdy horse pulling the wagon. The \aprice OF\b\bof greatness\n\tis responsibility.\n\nBye";
-	const char *s;
 
 	ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
 	ut_assert(!device_active(dev));
@@ -321,8 +324,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts)
 
 	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
 	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
-	for (s = test_string; *s; s++)
-		vidconsole_put_char(con, *s);
+	vidconsole_put_string(con, test_string);
 	ut_asserteq(33849, compress_frame_buffer(dev));
 
 	return 0;
@@ -335,7 +337,6 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
 	struct sandbox_sdl_plat *plat;
 	struct udevice *dev, *con;
 	const char *test_string = "...Criticism may or may\b\b\b\b\b\bnot be agreeable, but seldom it is necessary\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\bit is necessary. It fulfils the same function as pain in the human body. It calls attention to an unhealthy state of things.";
-	const char *s;
 
 	ut_assertok(uclass_find_device(UCLASS_VIDEO, 0, &dev));
 	ut_assert(!device_active(dev));
@@ -344,8 +345,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts)
 
 	ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev));
 	ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
-	for (s = test_string; *s; s++)
-		vidconsole_put_char(con, *s);
+	vidconsole_put_string(con, test_string);
 	ut_asserteq(34871, compress_frame_buffer(dev));
 
 	return 0;
-- 
2.13.5

             reply	other threads:[~2017-09-25 19:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25 19:45 Rob Clark [this message]
2017-09-25 19:45 ` [U-Boot] [PATCH 2/2] video: test: Add ANSI escape sequence tests Rob Clark
2017-09-29 20:51   ` Anatolij Gustschin
2017-09-29 19:51 ` [U-Boot] [PATCH 1/2] video: test: Helper for writing strings Anatolij Gustschin

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=20170925194511.15872-1-robdclark@gmail.com \
    --to=robdclark@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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