Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CABE7C3DA7F for ; Thu, 15 Aug 2024 20:26:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0ECB788B1C; Thu, 15 Aug 2024 22:24:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="My3dM4/t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EE00A88B0B; Thu, 15 Aug 2024 22:24:47 +0200 (CEST) Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A984888AC5 for ; Thu, 15 Aug 2024 22:24:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-39d210237feso2928425ab.1 for ; Thu, 15 Aug 2024 13:24:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723753476; x=1724358276; darn=lists.denx.de; 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=9fHFqiEb/an93PtFX+BLCkE6/YVYMa2Q9B8rwdB3tC4=; b=My3dM4/ta66DXL2Jbrkwp8ooGbHDIR2ucDbWHwzj9Odvfikudj9TNxYiERYcnD3cSP 5l/42M2/e30hdNGd5WeyBMyjj5gkxoZHYz/ytYkOD3HyvMXkEeA9aSx8bQzQhPzKRrDu vSs40S8vyui4uwolGiF21wQSBo00YxCRVcm6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723753476; x=1724358276; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9fHFqiEb/an93PtFX+BLCkE6/YVYMa2Q9B8rwdB3tC4=; b=wqitlwzsJ1o/UhLxoJQ0XPT47jGwG47r7MF9JI1Y77i2pIxbqWXwfjxnRLz9LbT//m f1msCwidNDaeVmUYn9SYvQKNux8yErhXI4/zFosC0nfP8Hwlw9GtWr84ZVVFuIq+tMVI xKzT2Lvq+FwcNjVK8FM3tk9zayC9ujkBZ8CVQrxq5SBhqvpM2I7KQN8ViyElZAt8r8KT kS6Xi9vt/2aGCIePpU/aV2GtUv4szRr707QpBMjU4G13IZvwJEQlVVbyNA4oB/B13uwM SRXMPvZBBWAthMAFYuRWQoK+NG4r8yrQH+RTNTHF+yP/zBhdgUXiQVddF68p+StlN++w xERQ== X-Gm-Message-State: AOJu0Yx3pahkW2/MdkLgFsicyxwp1gSz0p++Z69F3Y4R7Sd8Jakl+tdc ptXY3xoUnQ/wV9f7GXyhYsZasDDux1FcwuJtYCt/kkqhUyj1fywxbuPiH/AvSGdOvSVY9sRUbTn 3xA== X-Google-Smtp-Source: AGHT+IEtYZxnBVGxnvrioT9hQ9/4qxLITO9yJYHSGYYAxTpIQZmW1ujpPUPl2HuV563LuE7WBQBzmw== X-Received: by 2002:a05:6e02:12e7:b0:381:d74f:b2f4 with SMTP id e9e14a558f8ab-39d26d72bd0mr11428515ab.24.1723753476093; Thu, 15 Aug 2024 13:24:36 -0700 (PDT) Received: from chromium.org (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39d1ead5597sm8144915ab.7.2024.08.15.13.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 13:24:35 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH v4 10/14] efi_loader: Disable ANSI output for tests Date: Thu, 15 Aug 2024 14:24:20 -0600 Message-Id: <20240815202424.766778-11-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240815202424.766778-1-sjg@chromium.org> References: <20240815202424.766778-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We don't want ANSI characters written in tests since it is a pain to check the output with ut_assert_nextline() et al. Provide a way to tests to request that ANSI characters not be sent. Add a proper function comment while we are here, to encourage others. Signed-off-by: Simon Glass --- (no changes since v1) include/efi_loader.h | 21 ++++++++++++++++++++- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index f84852e384f..82b90ee0f1d 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -531,8 +531,27 @@ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index); efi_status_t efi_bootmgr_run(void *fdt); /* search the boot option index in BootOrder */ bool efi_search_bootorder(u16 *bootorder, efi_uintn_t num, u32 target, u32 *index); -/* Set up console modes */ + +/** + * efi_setup_console_size() - update the mode table. + * + * By default the only mode available is 80x25. If the console has at least 50 + * lines, enable mode 80x50. If we can query the console size and it is neither + * 80x25 nor 80x50, set it as an additional mode. + */ void efi_setup_console_size(void); + +/** + * efi_console_set_ansi() - Set whether ANSI characters should be emitted + * + * These characters mess up tests which use ut_assert_nextline(). Call this + * function to tell efi_loader not to emit these characters when starting up the + * terminal + * + * @allow_ansi: Allow emitting ANSI characters + */ +void efi_console_set_ansi(bool allow_ansi); + /* Set up load options from environment variable */ efi_status_t efi_env_set_load_options(efi_handle_t handle, const char *env_var, u16 **load_options); diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index cea50c748aa..569fc9199bc 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -30,6 +30,17 @@ struct cout_mode { __maybe_unused static struct efi_object uart_obj; +/* + * suppress emission of ANSI codes for use by unit tests. Leave it as 0 for the + * default behaviour + */ +static bool no_ansi; + +void efi_console_set_ansi(bool allow_ansi) +{ + no_ansi = !allow_ansi; +} + static struct cout_mode efi_cout_modes[] = { /* EFI Mode 0 is 80x25 and always present */ { @@ -348,13 +359,6 @@ static int __maybe_unused query_vidconsole(int *rows, int *cols) return 0; } -/** - * efi_setup_console_size() - update the mode table. - * - * By default the only mode available is 80x25. If the console has at least 50 - * lines, enable mode 80x50. If we can query the console size and it is neither - * 80x25 nor 80x50, set it as an additional mode. - */ void efi_setup_console_size(void) { int rows = 25, cols = 80; @@ -362,8 +366,12 @@ void efi_setup_console_size(void) if (IS_ENABLED(CONFIG_VIDEO)) ret = query_vidconsole(&rows, &cols); - if (ret) - ret = query_console_serial(&rows, &cols); + if (ret) { + if (no_ansi) + ret = 0; + else + ret = query_console_serial(&rows, &cols); + } if (ret) return; -- 2.34.1