From patchwork Thu Jan 22 04:11:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1766 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=1769055159; bh=Ntv45gqkELXiAcXeQTB/91SPM6ZXjjSl7HSXJMF1wS4=; 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=qmSTlrO5smk5YHFiiL3v8qLoPsBSwHhD1vsZW8is9O4VmBZyac4+AU4yV5arSOoZ9 2pTX/MBGJQYUC1QGedJk1ehwfRVG3dc9ajAa3PZqmxyyeCHyLzZFK/6fQbUVTTvLSN 1Gs4iDqzFVIFh+djHeJGZ/rLkGlcd3Ax++NITX9G8DkRsgHPwUbX46yIi0sih0CGS4 Yyv5UDeszjSkccqm0izr1o/kl4A1h/z8gGitI9c6IVfhRkykc03A3Pi/GYKkoxHkl2 nyKus0xjws2Aihp5z5VjOPY5QAxdeU8o/WHPc8/eZUU6EXohT7r2rmcN3Al15TYILD fvpSAt7cXy4NA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB3BA6962D for ; Wed, 21 Jan 2026 21:12:39 -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 TcPQF25lzqFn for ; Wed, 21 Jan 2026 21:12:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055159; bh=Ntv45gqkELXiAcXeQTB/91SPM6ZXjjSl7HSXJMF1wS4=; 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=qmSTlrO5smk5YHFiiL3v8qLoPsBSwHhD1vsZW8is9O4VmBZyac4+AU4yV5arSOoZ9 2pTX/MBGJQYUC1QGedJk1ehwfRVG3dc9ajAa3PZqmxyyeCHyLzZFK/6fQbUVTTvLSN 1Gs4iDqzFVIFh+djHeJGZ/rLkGlcd3Ax++NITX9G8DkRsgHPwUbX46yIi0sih0CGS4 Yyv5UDeszjSkccqm0izr1o/kl4A1h/z8gGitI9c6IVfhRkykc03A3Pi/GYKkoxHkl2 nyKus0xjws2Aihp5z5VjOPY5QAxdeU8o/WHPc8/eZUU6EXohT7r2rmcN3Al15TYILD fvpSAt7cXy4NA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DA9E86962A for ; Wed, 21 Jan 2026 21:12:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055157; bh=z86Q3G0rVvbo8YnLQfjq/yP+wp8UGx/K1bWLzvrYvIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=epSx7TrJVe0lVTmk4eYDy291I/ZolRVjS8/XKzbURGP9gTJteJI6QF4ACniC0n4/n rn7ct9G6NOssmskR3Gu9PPfroCbFsgtvHte3oNfvN5c3V3XP3k5SDqgv7wZfadHWcL ljgMLKS6lquIFsL+iUxsmeBUC2XHo8MnpU/3pivcIof25L+KEJKeOB3qV/Aaftl8GB wVxTtlYd5vvpAN5dNB84XHltFyS5yudyHNrEAQ4Cm52dYfz4AezrScCJ/CdIcKdbT9 wLMz/NsLemZRQCVOKWtee7xIciEdTF3mCqPvQzfsmtyyIhj4pbU3dtwCQNq7AZTOtM eMex0FTpn71Yw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7397B694CC; Wed, 21 Jan 2026 21:12: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 10026) with ESMTP id PN3n4GqSQCY5; Wed, 21 Jan 2026 21:12:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055153; bh=rpe4JOLlJ3qxQLJzIaf9n2WarE+kvOCUYVAUh96GLtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqfMUCESJdf2F2AWFc2JibINSKa8tzV6a1zq3/hw/QyUPAteTf6c4iA0v/LWql21Y qf1MqgHt/fErDwg3Cs0VWpKUclpDAgzrE+2Tw1xN0Pl0DCQURgRPSlqh7V/SMcTB1c +HWAyXpeZDecpPL935u2OZ43nTLMdkJuwWd/PMNXSTkIPNxJj9u2V4k7DBkkFw/aQX BPkoi3n3p5CQ2VwocE1wqlCqOwXXK1eBse5AH9yAfTc5CrXx+X3OL7n5AxqhIcruv2 IcDQ7lsspLdr+IM2X9pokDjAsTKItxc6ugIpy4zK14H7ltT8uvu0OLu6T0v10gj+rz JKmzfKZvD7pJw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 21E1769616; Wed, 21 Jan 2026 21:12:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 21:11:35 -0700 Message-ID: <20260122041155.174721-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260122041155.174721-1-sjg@u-boot.org> References: <20260122041155.174721-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: L2AH2PKRMII4CYFJCS5TBY7KGT7ZNNCV X-Message-ID-Hash: L2AH2PKRMII4CYFJCS5TBY7KGT7ZNNCV 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 07/16] test: video: Add tests for independent vidconsole contexts 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 tests to verify that multiple vidconsole contexts operate independently. The tests create two contexts, set different cursor positions in each, write text to each context, and verify that operations on one context do not affect the other. Two tests are added: - dm_test_video_context_indep: Tests with bitmap font - dm_test_video_context_indep_tt: Tests with truetype font Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/dm/video.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/dm/video.c b/test/dm/video.c index fe6407dad35..d3ecb62b43a 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1516,3 +1516,91 @@ 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 that two vidconsole contexts are independent */ +static int dm_test_video_context_indep(struct unit_test_state *uts) +{ + struct vidconsole_ctx *ctx1, *ctx2; + 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, NULL, "8x16", 0)); + + /* Create two contexts */ + ut_assertok(vidconsole_ctx_new(con, (void **)&ctx1)); + ut_assertok(vidconsole_ctx_new(con, (void **)&ctx2)); + + /* Set different cursor positions in each context */ + vidconsole_set_cursor_pos(con, ctx1, 100, 50); + vidconsole_set_cursor_pos(con, ctx2, 200, 100); + + /* Verify positions are independent */ + ut_asserteq(VID_TO_POS(100), ctx1->xcur_frac); + ut_asserteq(50, ctx1->ycur); + ut_asserteq(VID_TO_POS(200), ctx2->xcur_frac); + ut_asserteq(100, ctx2->ycur); + + /* Write to ctx1, verify ctx2 is unchanged */ + vidconsole_put_string(con, ctx1, "Hello"); + ut_asserteq(VID_TO_POS(200), ctx2->xcur_frac); + ut_asserteq(100, ctx2->ycur); + + /* Write to ctx2, verify it moves independently */ + vidconsole_put_string(con, ctx2, "World"); + ut_assert(ctx2->xcur_frac > VID_TO_POS(200)); + ut_asserteq(100, ctx2->ycur); + + /* ctx1 should have moved from the first write */ + ut_assert(ctx1->xcur_frac > VID_TO_POS(100)); + ut_asserteq(50, ctx1->ycur); + + ut_assertok(vidconsole_ctx_dispose(con, ctx1)); + ut_assertok(vidconsole_ctx_dispose(con, ctx2)); + + return 0; +} +DM_TEST(dm_test_video_context_indep, UTF_SCAN_PDATA | UTF_SCAN_FDT); + +/* Test multiple contexts with truetype font */ +static int dm_test_video_context_indep_tt(struct unit_test_state *uts) +{ + struct vidconsole_ctx *ctx1, *ctx2; + struct udevice *dev, *con; + int ctx1_x, ctx2_x; + + ut_assertok(video_get_nologo(uts, &dev)); + ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); + ut_assertok(vidconsole_select_font(con, NULL, NULL, 30)); + + /* Create two contexts */ + ut_assertok(vidconsole_ctx_new(con, (void **)&ctx1)); + ut_assertok(vidconsole_ctx_new(con, (void **)&ctx2)); + + /* Set different cursor positions */ + vidconsole_set_cursor_pos(con, ctx1, 50, 100); + vidconsole_set_cursor_pos(con, ctx2, 300, 200); + + /* Write different text to each */ + vidconsole_put_string(con, ctx1, "First"); + ctx1_x = ctx1->xcur_frac; + + vidconsole_put_string(con, ctx2, "Second context"); + ctx2_x = ctx2->xcur_frac; + + /* Verify they moved independently */ + ut_asserteq(ctx1_x, ctx1->xcur_frac); /* ctx1 unchanged by ctx2 write */ + ut_asserteq(100, ctx1->ycur); + ut_asserteq(ctx2_x, ctx2->xcur_frac); + ut_asserteq(200, ctx2->ycur); + + /* ctx2 should have moved more (longer string) */ + ut_assert(ctx2_x - VID_TO_POS(300) > ctx1_x - VID_TO_POS(50)); + + ut_assertok(vidconsole_ctx_dispose(con, ctx1)); + ut_assertok(vidconsole_ctx_dispose(con, ctx2)); + + return 0; +} +DM_TEST(dm_test_video_context_indep_tt, UTF_SCAN_PDATA | UTF_SCAN_FDT);