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 2/2] video: test: Add ANSI escape sequence tests
Date: Mon, 25 Sep 2017 15:45:09 -0400	[thread overview]
Message-ID: <20170925194511.15872-2-robdclark@gmail.com> (raw)
In-Reply-To: <20170925194511.15872-1-robdclark@gmail.com>

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
Not sure if there is a way to inject a -l arg when test.py runs
sanbox somehow, to visually confirm the results?  It is not really
possible to do manually since 'echo' command doesn't handle escape
sequences properly.  At any rate, efi_console uses all the same
escape sequences, and at least with a 32bpp display they look
correct.

 test/dm/video.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/test/dm/video.c b/test/dm/video.c
index 6a5626c5e3..29917d0c2d 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -159,6 +159,40 @@ static int dm_test_video_chars(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_video_chars, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
+#ifdef CONFIG_VIDEO_ANSI
+#define ANSI_ESC "\x1b"
+/* Test handling of ANSI escape sequences */
+static int dm_test_video_ansi(struct unit_test_state *uts)
+{
+	struct udevice *dev, *con;
+
+	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));
+
+	/* reference clear: */
+	video_clear(con->parent);
+	video_sync(con->parent);
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	/* test clear escape sequence: [2J */
+	vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J");
+	ut_asserteq(46, compress_frame_buffer(dev));
+
+	/* test set-cursor: [%d;%df */
+	vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd");
+	ut_asserteq(142, compress_frame_buffer(dev));
+
+	/* test colors (30-37 fg color, 40-47 bg color) */
+	vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */
+	vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */
+	ut_asserteq(268, compress_frame_buffer(dev));
+
+	return 0;
+}
+DM_TEST(dm_test_video_ansi, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+#endif
+
 /**
  * check_vidconsole_output() - Run a text console test
  *
-- 
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 [U-Boot] [PATCH 1/2] video: test: Helper for writing strings Rob Clark
2017-09-25 19:45 ` Rob Clark [this message]
2017-09-29 20:51   ` [U-Boot] [PATCH 2/2] video: test: Add ANSI escape sequence tests 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-2-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