From patchwork Sat Jan 17 00:56:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1560 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611517; bh=CgRDcT74QYaDTlqE613tftQ7Vwf7wXPUl8k6KjJiVqU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=B003qdfMTqrzid430sgQwWyAHj0sGEnIXOP1RTyv9Q/A0pofDJU3nrQvWVAgntBDz I/LkokzWnfZLiC3q/k9DpJ9qjzGYfuIpvXUzybdSzmneOopidj9hQUoFq31j1wJrqE irCFltLScgVOUDk/SXlOR/gsjQc1f/wyvpvOZx10WpEshgXt3z2CC28uVyV3OAmC84 rwEd05kL4U2ti533NVuAFvygR72s0P/ZG8pCWcJXhOsl5LyqpBIcoyYprsDJgOUQFg TYvhoofHzPdkg+mQHbms6v8ELpYFL1KhiRNR4ZcB5oiegf5boRfiVhCRzawlPolMqi V0/1Phg31Cy0w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F775693E9 for ; Fri, 16 Jan 2026 17:58:37 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id mR2fw6m4Sxzp for ; Fri, 16 Jan 2026 17:58:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611517; bh=CgRDcT74QYaDTlqE613tftQ7Vwf7wXPUl8k6KjJiVqU=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=B003qdfMTqrzid430sgQwWyAHj0sGEnIXOP1RTyv9Q/A0pofDJU3nrQvWVAgntBDz I/LkokzWnfZLiC3q/k9DpJ9qjzGYfuIpvXUzybdSzmneOopidj9hQUoFq31j1wJrqE irCFltLScgVOUDk/SXlOR/gsjQc1f/wyvpvOZx10WpEshgXt3z2CC28uVyV3OAmC84 rwEd05kL4U2ti533NVuAFvygR72s0P/ZG8pCWcJXhOsl5LyqpBIcoyYprsDJgOUQFg TYvhoofHzPdkg+mQHbms6v8ELpYFL1KhiRNR4ZcB5oiegf5boRfiVhCRzawlPolMqi V0/1Phg31Cy0w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4F340693D7 for ; Fri, 16 Jan 2026 17:58:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611515; bh=pxviyNhzuuR8spvraPWARtWMnJr7Fi+quJXKpbCCmX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+tyHG0dUyCQ2FvJoyB5Vw2qVlEWW7XCg5bZ7zICeDRa6aKswkG3CTX+Tn8R3kxmy FPX7k80gNk8/WJYz7DyjW0CHNarniCKFf+2j6zD98FnSV9CDbC9Jj51pVsjBDiqpyi 0nRn07zxZDbdlLj6Nwrf99/rHrCUebIyvday6JavmfgNSxwl7GD4kBG/O/w6v5ko7A udU3RpL9WV1FAZ8jAjHiLza8UOQsb9E5I0gu3L3wcKhEGiV6Fjve3cxMvaZOJ5bfse 6RZhBXiZQ1uyGo7BDOhV+fzjq25QK0fUeLC8TobgzYCreJTI6KnsxkYoikzn4rYbZs TgN40Wh2PxrGQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5162D693D7; Fri, 16 Jan 2026 17:58:35 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 6ikxdRkSFB9j; Fri, 16 Jan 2026 17:58:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611511; bh=8M8wtqWuAke80OToOUojJRKzT8LltwxyZoHLmo05IyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OSleWQxYGr+Z3yBMyszQJjNZdswEGblzWFabM5CPrOD6l4PPc0mZeHKIQPTo4KqV2 oxRnqCrmPe57D0KwB8WaDW1WR+ONOkXezqcIccEswS4V/YW+jf+TJRpOIKSsfHE4QG E+i0aOTpJY9hBmRZLg6RzW6eWyDfh3MpGn1UcvsiM5uFupCm0l4n04nZg7HTGIqt6b eGzKDYc3mS0Prlk9pHMKXW740lIIsfoVTleQ927ws97VLFHPWqTeWK029KIuwasKCn 62hJL4FZNczGPIzOFNRqrG0On1Y2nHTbbaYSV3xM28kLMivQZ6YMkxulCPcGboE8vs hBjhRyF43eQvQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0198F693B1; Fri, 16 Jan 2026 17:58:30 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 17:56:56 -0700 Message-ID: <20260117005702.1684841-19-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117005702.1684841-1-sjg@u-boot.org> References: <20260117005702.1684841-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NFDHZQMZTHSL4PBPWEAPACQAOREEN77B X-Message-ID-Hash: NFDHZQMZTHSL4PBPWEAPACQAOREEN77B X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 18/18] video: Add test for entry save/restore List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add dm_test_video_entry_save() and dm_test_video_entry_save_tt() to directly test vidconsole_entry_save() and vidconsole_entry_restore() for both bitmap and truetype fonts. The tests verify that cursor position is correctly saved and restored. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/dm/video.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/dm/video.c b/test/dm/video.c index d3978f4b00c..97778a70559 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1516,3 +1516,70 @@ static int dm_test_video_context_alloc(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_context_alloc, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* Test vidconsole entry save/restore */ +static int check_entry_save(struct unit_test_state *uts, struct udevice *con) +{ + struct vidconsole_priv *priv; + struct vidconsole_ctx *ctx; + int xcur_frac, ycur; + struct abuf buf; + + priv = dev_get_uclass_priv(con); + ctx = priv->ctx; + + /* Move cursor to a known position */ + vidconsole_position_cursor(con, 5, 3); + xcur_frac = ctx->xcur_frac; + ycur = ctx->ycur; + + /* Save the state */ + abuf_init(&buf); + ut_assertok(vidconsole_entry_save(con, &buf)); + + /* Move cursor to a different position */ + vidconsole_position_cursor(con, 10, 7); + ut_assert(ctx->xcur_frac != xcur_frac || ctx->ycur != ycur); + + /* Restore the state */ + ut_assertok(vidconsole_entry_restore(con, &buf)); + + /* Verify cursor is back at saved position */ + ut_asserteq(xcur_frac, ctx->xcur_frac); + ut_asserteq(ycur, ctx->ycur); + + abuf_uninit(&buf); + + return 0; +} + +/* Test entry save/restore with bitmap font */ +static int dm_test_video_entry_save(struct unit_test_state *uts) +{ + struct udevice *dev, *con; + + ut_assertok(select_vidconsole(uts, "vidconsole0")); + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, "8x16", 0)); + + ut_assertok(check_entry_save(uts, con)); + + return 0; +} +DM_TEST(dm_test_video_entry_save, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* Test entry save/restore with truetype font */ +static int dm_test_video_entry_save_tt(struct unit_test_state *uts) +{ + struct udevice *dev, *con; + + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, NULL, 30)); + + ut_assertok(check_entry_save(uts, con)); + + return 0; +} +DM_TEST(dm_test_video_entry_save_tt, UTF_SCAN_PDATA | UTF_SCAN_FDT);