From mboxrd@z Thu Jan 1 00:00:00 1970 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 958A5CDE03D for ; Thu, 26 Sep 2024 22:03:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3354988E8B; Fri, 27 Sep 2024 00:03:16 +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="HfizVZ3R"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DCD0788E96; Fri, 27 Sep 2024 00:03:14 +0200 (CEST) Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) (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 BC6CC88E5F for ; Fri, 27 Sep 2024 00:03:12 +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-qt1-x829.google.com with SMTP id d75a77b69052e-45aeef3ce92so8446921cf.2 for ; Thu, 26 Sep 2024 15:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727388191; x=1727992991; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=y6rJQMOhsSwQGbiM5xIK5Rhad8fP1T84y2nnqZJna0o=; b=HfizVZ3R/SeCo4uNK/lhmYAWB+EU85OcTI5ee5o1JtDX6IHEHxSlneiQ27olL8y0w0 bhWEXgBwKUf1He4ybRGhU42tMF0L4r6+7U2BD5NACF7kWPuFuGNKjIDWze8Irp86h1LA 2RCPRC52Jt/nNN+WRCnwUBOLollJu3/aMFA6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727388191; x=1727992991; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y6rJQMOhsSwQGbiM5xIK5Rhad8fP1T84y2nnqZJna0o=; b=F2YFsNUzOkRquZAcHbNZQT+SX1LvYmZGwJSktBZnOEhvHbsGkdKeRAX0gV+fYrGbgW HkhNwrb3I/pIKJ2BLevwzd8Op/oUssymBaS51IWTzGR63D/s6DuY51kPQZy1dDElzIaD /9FmeboV/MTbDThK9uKV2G5sa+sPGiON4OGn0d+0/WMBnT9mFGFhRBzRvpHWby5pTRV9 9MaNtgGuoVTjYopObpFEJDThqMd79SSr++Wx4Rk8NGAu/qeExaBvTjEVt8j92sijd+LA 3mClyEM6MxUPustxRAX14TuGGjs13pVFxF2rpDTg3jOFZ0ADxHKuoRMRPZCsZhFK78l5 7HtQ== X-Gm-Message-State: AOJu0Yz9VVxCRtoyxBDGukrk6zcS7dBeejJ7LdnxzoVxWHhVf+ruCfuU ezEjCMGBADzpzsJkI2iNPfLZXh6uLP5i4OrIM3s79QE1UkrMXtpboSOck9DyRLM2l99Nxx0t9Ki ooODzbm8= X-Google-Smtp-Source: AGHT+IFT62WViDi6PjHkSmjbwNoSyR7iiJuJHI2r7BntBgasvf1sKGPUVR/NRbb1eM5Mobr+cq6Q5w== X-Received: by 2002:a05:622a:11d2:b0:458:2bee:8d56 with SMTP id d75a77b69052e-45c9f302443mr12709941cf.44.1727388191147; Thu, 26 Sep 2024 15:03:11 -0700 (PDT) Received: from chromium.org ([205.220.129.31]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45c9f2e02c8sm2540211cf.44.2024.09.26.15.02.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 15:03:09 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass Subject: [PATCH v6 08/12] efi_loader: Disable ANSI output for tests Date: Fri, 27 Sep 2024 00:02:19 +0200 Message-ID: <20240926220226.1265965-9-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 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.43.0