From patchwork Mon Sep 25 19:45:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 818344 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N5z5/gov"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1F1N1kTDz9s76 for ; Tue, 26 Sep 2017 05:45:26 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9E073C21EE4; Mon, 25 Sep 2017 19:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EACCAC21C71; Mon, 25 Sep 2017 19:45:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 635BFC21C71; Mon, 25 Sep 2017 19:45:17 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by lists.denx.de (Postfix) with ESMTPS id C5473C21C4C for ; Mon, 25 Sep 2017 19:45:16 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id e69so4005501pfg.4 for ; Mon, 25 Sep 2017 12:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2weSJ7A3VlrR4ib2bR1EVwP+8+m94eTaJX+BuWYXcp4=; b=N5z5/govOkio/Im6uZApDcou8v8U8npmNxp7cXUdYXJo0BF2UUAkMWGH9m2FmNk4Kd 9uZQeFKOAT6IgofsCl8d2tSRiheD06vLmidhzFOanluBbUEiCel+b/RPc0BYece2ual5 DGBkeysMR3Ez7kPu1W0ApwTXe+EJ1iHo/08hQv8qR5peO6SkwVyjzal0+JxXG5bgEgGl jqo/BdbiD78yH5SI6/wmeIckIyWZ2Y9Lr4ObdtBGEuB8zTZ7e1XvXnbz3/S4Ti5HKKcL 0lmMEMd/80Jz17lfxWztoE4/wh7+LGqjfAQatKiSNUrm4WleC4pkd6Xg0eFGX0rDHa3Q 8s5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2weSJ7A3VlrR4ib2bR1EVwP+8+m94eTaJX+BuWYXcp4=; b=cjt5Zuu4liUbpLmU8yDUQpi0a7zABDBFtJrofSx4DusTovcM3JqpMQ/OGXMrZ6y4r/ WqhziYFSVVrTQKVmYh+1+d0OXc/iGvTETDWb0bLBxZNtL98g0FYm9ZLhlfKhbTCibBn4 Km4fZyJceo1C1w7lE3LQ7VdFTeeNWVvyroNZPCUe43Td29fgzRuNFJZra2T/PMDqnCFo DbRpS+5tHFpZ4ithItefUVezRk2RP489vXrVdypPh08jat3snc0w03MBZx9fND0lauJw FvyUrKguzt/KvnFKNXP2RRS9Pf7eCI76TWjXck9w8PcILSXp+fb2qXmBB5zgEzBO/jUK xRbA== X-Gm-Message-State: AHPjjUg8GgyKG1TeDmDZDUkWMMPwc9TfMyfJNswokF8k3IlHWx/PDkut NvMe3CnOX6L9rEzYCdLnD+god7f1 X-Google-Smtp-Source: AOwi7QA2sH2QyAhTz1wmvvbJH3pwMp/TwCYrbabN/8q6mrqR1/8GMqDGXsR9dcn5NC35V628rxlrjA== X-Received: by 10.84.235.6 with SMTP id o6mr8431780plk.295.1506368714645; Mon, 25 Sep 2017 12:45:14 -0700 (PDT) Received: from localhost (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id a7sm12000326pgc.40.2017.09.25.12.45.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 12:45:13 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Mon, 25 Sep 2017 15:45:08 -0400 Message-Id: <20170925194511.15872-1-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 Subject: [U-Boot] [PATCH 1/2] video: test: Helper for writing strings X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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; From patchwork Mon Sep 25 19:45:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 818345 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZaAJK9Qt"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1F2K4Ptcz9s76 for ; Tue, 26 Sep 2017 05:46:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 47A78C21E2C; Mon, 25 Sep 2017 19:45:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B0F80C21F51; Mon, 25 Sep 2017 19:45:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 59308C21EA9; Mon, 25 Sep 2017 19:45:24 +0000 (UTC) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by lists.denx.de (Postfix) with ESMTPS id 9112BC21E33 for ; Mon, 25 Sep 2017 19:45:20 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id h4so4020643pfk.0 for ; Mon, 25 Sep 2017 12:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dcWIGPXIp7dpOTAUog3myQC7lIeU5olZ9bpaykv5qCo=; b=ZaAJK9Qtg6MHhwGKnEowgvFMncXoAGq8ucRvJbd9ITVBxhlUwUTt3TvdImPv74+K1H TtHs/nCpX5cZjvWzpwCHF9bHt9F+hflMwOiMmTOjca20ERNruyHxgzW7RY7/F3i4onwH inKFYMlUS0JGbaLmg/q/A3jnY0ZkTwGxEOi+9W0r//1t01Xv/fx6VOvMVPKZ0mlwJlEB 2ZbFWtY4i6ifKKeNg8VwMKpeqpm17Y6AGG2jchjQeWJ0hq/E0yoREAuhtUMEnu4fN1u+ FBSgehLaiWfYMcJ39rmh0dTa6lrvl/fi17wu9Js3xtvEs1dQR0Pruq2Sxrsg8OWFXMx6 HWpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dcWIGPXIp7dpOTAUog3myQC7lIeU5olZ9bpaykv5qCo=; b=VcXef3184+oY3+06FuOUO0KQOgjbtZOWELZ0wGYN8Va8IA/4iv2M377I7BhnVIu1De 7JRi7UmE8eDTIabMLTW9TXI6Izl8vM3AruCTmfGvLtChQyfHaXrKZutIE3QtZmK4+3Gk VRoBHhwf5Nr7Ay4IOYeAhUl5WsPENOwEp7H6GoOVsZ0H5CAQ1ort4rp/Dt6p6Rn2o1JT 7+3UdBgDBiM+AB6IXwAhItYt9FvTKrHjZnMnVe4XpdlL+KJz3iGnUztIEcyO20XLZpxb ZI6EWb5S+WRZJEAO4bRv1Yi898btXDnVvSz+yO1ws84mF38IaDxEiAv98G/EwTQisGFb tXVw== X-Gm-Message-State: AHPjjUhtKMyii08P6fYRsZCZSG8SygznAFbqEc4owZ/DfKP0BXdResv0 Gmq7L4W0qC+uAvP7Vcw3OJ6yHmED X-Google-Smtp-Source: AOwi7QCxqLHwzmkJD9dQZvGdP9SF6qyLkfUiKue0NL5//IyEMSO2B8s8/c96HScQkVu9/FKiiZSzNw== X-Received: by 10.99.130.198 with SMTP id w189mr8530253pgd.175.1506368718880; Mon, 25 Sep 2017 12:45:18 -0700 (PDT) Received: from localhost (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id m13sm13065957pgc.58.2017.09.25.12.45.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Sep 2017 12:45:17 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Mon, 25 Sep 2017 15:45:09 -0400 Message-Id: <20170925194511.15872-2-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170925194511.15872-1-robdclark@gmail.com> References: <20170925194511.15872-1-robdclark@gmail.com> Subject: [U-Boot] [PATCH 2/2] video: test: Add ANSI escape sequence tests X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Rob Clark --- 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 *