From patchwork Fri Jan 30 03:58:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1788 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org Authentication-Results: mail.u-boot.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=cHl2Dp5Q; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9E8EE697CB for ; Thu, 29 Jan 2026 20:59:42 -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 FpQCLJ_0a2av for ; Thu, 29 Jan 2026 20:59:42 -0700 (MST) Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A657D697CE for ; Thu, 29 Jan 2026 20:59:40 -0700 (MST) Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DFA0A69738 for ; Thu, 29 Jan 2026 20:59: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 oYkq6GSYmOYz for ; Thu, 29 Jan 2026 20:59:37 -0700 (MST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.173; helo=mail-oi1-f173.google.com; envelope-from=sjg@chromium.org; receiver=u-boot.org Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by mail.u-boot.org (Postfix) with ESMTPS id 3A807697CB for ; Thu, 29 Jan 2026 20:59:34 -0700 (MST) Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-45c70afbeebso1143678b6e.0 for ; Thu, 29 Jan 2026 19:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1769745573; x=1770350373; darn=u-boot.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BsToSrH9sdKqP0sx8AXQu8h5C0IEUSBbdcbHyXxopoE=; b=cHl2Dp5Q+vz0PZPvdSrezBUtW2X5pNFXRRpAaKE75tkQt79O6sI+j5rwzPyC5rPIkO BDR+VRdscGvecG1edC2APpO8zZkJxZTPRtHG/9oupP/a7U8kl0m9frdzS/Gz2ehQ9rFN oFzp8d3eyPsFkwsu/O86vyIkXrAhFAVQTLu6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769745573; x=1770350373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BsToSrH9sdKqP0sx8AXQu8h5C0IEUSBbdcbHyXxopoE=; b=MJs+qb4R3jJduc9tb10yzeGRtbeBcLT7iz0lCgtRq3QqFTnV/EYCA/Yht529g6bmnA 5hdjxc2aeiu4Al8EQ6y0dE8GAggdmx3awEzb1/ENAi2Vjs9QtLcE1tetJwl7hz3Ux/oS a1OEtADvYfzPcbGelO1/jHHolyYaYWOIFvO3fGoeM72BrqvGu+mI9CD4YJIQQiavo7sz KdYbVo2jOO6BdofDk4R81To0R5iJXc30kzVZzGiCzORP4LD5oVdUbj4EhEz6Ba8x436N v8Oam5WXhsycz3EC3jd7hgk357cb0qM5MCIZUca3X9+0ihSFMqRJlyj0NPPie5QtqmHy 78WA== X-Gm-Message-State: AOJu0YxouJl65kfTmYavULyosVYUwO6gB10AYHjokZQmvXqNWo/FicvI aduP7i/uX3dErUyDs0+EOn+SznCO51NQonj7IvUIB8f79An8WEBqE47YrOuTzTZ3j8jl17xz3hp BAmb71A== X-Gm-Gg: AZuq6aI1+JgXgK6TCuHKmAU/xdRaElcnsIqYRK/Dp1Hmsv/p47TXUM7BOXQMHlon9Nj XwaavJcluHEyIO+sCJ0U8HRelLepgxK4zdx4MWJxKlYaBDqZeTLN7jTYFsaZxUe7Ur+yevudMrY 4fQa4hqT+eaH7Jw6bPeDyzmKTHzLOXkkpv3FvMe3XjP8fkhuXqu6PIK8QhDK6qBUIJnPpVc/zQU si8P2yz5J1IoUHaBx38lP/6GO19G6UyvPDEJRwErUdvsapOs3yjmWc8ffwR+0hkafBibU4AE9bo fl/PJW/StjTo7gqPVI+2pGTlzGi4FJkqLVaNy/okVyYkB6aSTI7SRYvVOitCnDH9GRAyqaPow4W 4exnxndH0ZZ9xxErOp7DOA64Hn51CyzUg86tGcNcn/1yGi1/RwxGZQo1WABjD9iifo1CjfXQ+65 k6wsQ7Huo5T9h0WOeV X-Received: by 2002:a05:6820:f0a:b0:663:89a:812a with SMTP id 006d021491bc7-6630f035b90mr895737eaf.33.1769745572948; Thu, 29 Jan 2026 19:59:32 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-662f9a4e491sm4128687eaf.16.2026.01.29.19.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 19:59:31 -0800 (PST) From: Simon Glass X-Google-Original-From: Simon Glass To: U-Boot Concept Date: Thu, 29 Jan 2026 20:58:36 -0700 Message-ID: <20260130035849.3580212-14-simon.glass@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260130035849.3580212-1-simon.glass@canonical.com> References: <20260130035849.3580212-1-simon.glass@canonical.com> MIME-Version: 1.0 Message-ID-Hash: 4R4FRMEF6HCS3ON2VGK7KIBHCGRU7N3K X-Message-ID-Hash: 4R4FRMEF6HCS3ON2VGK7KIBHCGRU7N3K X-MailFrom: sjg@chromium.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 13/19] test: Add editenv test for init/poll/uninit functions List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add a test for the expo_editenv_init(), expo_editenv_poll() and expo_editenv_uninit() functions which allow more flexible use of the environment editor. The test uses a helper function editenv_send() to send keys directly to the expo and verify the result. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/boot/editenv.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/boot/editenv.c b/test/boot/editenv.c index 02bc025e216..62a33f1ba0f 100644 --- a/test/boot/editenv.c +++ b/test/boot/editenv.c @@ -9,11 +9,64 @@ #include #include #include +#include #include +#include #include #include #include "bootstd_common.h" +static const char initial[] = + "This is a long string that will wrap to multiple lines " + "when displayed in the textedit widget. It needs to be " + "long enough to span several lines so that the up and down " + "arrow keys can be tested properly.\n" + "The arrow keys should " + "move the cursor between lines in the multiline editor."; + +/** + * editenv_send() - Send a key to the editenv expo + * + * Arranges and renders the scene, sends the key, then checks for any + * resulting action. + * + * @info: Editenv info + * @key: Key to send (ASCII or BKEY_...) + * Return: 0 if OK, 1 if editing is complete, -ECANCELED if user quit, + * other -ve on error + */ +static int editenv_send(struct editenv_info *info, int key) +{ + struct expo_action act; + int ret; + + ret = expo_send_key(info->exp, key); + if (ret) + return ret; + + ret = scene_arrange(info->scn); + if (ret) + return ret; + + ret = expo_render(info->exp); + if (ret) + return ret; + + ret = expo_action_get(info->exp, &act); + if (ret == -EAGAIN) + return 0; + if (ret) + return ret; + + if (act.type == EXPOACT_QUIT) + return -ECANCELED; + + if (act.type == EXPOACT_CLOSE) + return 1; + + return 0; +} + /* Check expo_editenv() basic functionality */ static int editenv_test_base(struct unit_test_state *uts) { @@ -92,3 +145,34 @@ static int editenv_test_video(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(editenv_test_video, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); + +/* Check the init/poll/uninit functions work correctly */ +static int editenv_test_funcs(struct unit_test_state *uts) +{ + struct editenv_info info; + struct udevice *dev, *con; + + ut_assertok(uclass_first_device_err(UCLASS_VIDEO, &dev)); + ut_assertok(uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &con)); + + /* Set font size to 30 */ + ut_assertok(vidconsole_select_font(con, NULL, NULL, 30)); + + ut_assertok(expo_editenv_init("testvar", initial, &info)); + ut_asserteq(16611, ut_check_video(uts, "init")); + + /* Type a character and press Enter to accept */ + ut_assertok(editenv_send(&info, '*')); + ut_asserteq(16689, ut_check_video(uts, "insert")); + + ut_asserteq(1, editenv_send(&info, BKEY_SELECT)); + + /* The '*' should be appended to the initial text */ + ut_assert(strstr(expo_editenv_result(&info), "editor.*")); + ut_asserteq(16689, ut_check_video(uts, "save")); + + expo_editenv_uninit(&info); + + return 0; +} +BOOTSTD_TEST(editenv_test_funcs, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);