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 599ABC3DA7F for ; Thu, 15 Aug 2024 20:26:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E0FD88B0D; Thu, 15 Aug 2024 22:24:54 +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="chcatZep"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 083CA8870B; Thu, 15 Aug 2024 22:24:50 +0200 (CEST) Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) (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 76B4F88AD7 for ; Thu, 15 Aug 2024 22:24:43 +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-x133.google.com with SMTP id e9e14a558f8ab-39d20c4be2eso3499865ab.1 for ; Thu, 15 Aug 2024 13:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723753480; x=1724358280; 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=7SX7BjENMtC+QtSVAGqrUCvprGRaXNEG+CfBwa+RKd8=; b=chcatZepRQ0I/uWrssVbfsHi5NUkuEBuK7XBmfk01FkXZ7w71amREQJKiqAxes6l6l g40sAhAkkFpBkI0+lk78IQQE2yIkNq/mbsPHp5Cnp9XdcPXpRMz7XkjrYsjKTz5Jyg9z g53F8y+4GLPZ2Z54Pqz9ybD5IEX3ztqT/LLAg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723753480; x=1724358280; 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=7SX7BjENMtC+QtSVAGqrUCvprGRaXNEG+CfBwa+RKd8=; b=ll4Ybx6Nckykw+TMkcrmB7A8XCkqP34+Bu5erMVPWf8RDQWmJb/7EzTsDFsIX1Ts9M PThwT5TrX5o3N8jR0j1S1v+AWMpKoeI2/VHq2Xpw2riY3q7Ko8NH+qVZeHmnYyRcUpME Xgulsrh3M9JtK83Vikpue6a3eGqabUvbD10X0MBd7lXuiR7kcpNMe1EXqn6krIMJEYv0 Em54mRM7PwjzDwSiyhBHi8GNDLII+1j+5RtRrc4sJRH6869fIlYnetF/1R7wdejq+ToT HBceUVgoLYAgL2fWIz9WuP1Yv0uoLtJXv+D5X6koctC/M3E3XegqfICIBBq7d2ZS8B2z fp9w== X-Gm-Message-State: AOJu0Ywocw9lt+m9SCy04Yyj/B/x3/t9fBiQaxUtNahVRv56GmneKFoT 3b2GSSuU7ZiJ11Q28NvEWlOYGYbJqN5Svjs+sbjHeKbX/QnFG6+I/ZBshsHzk+wrk9Jv3dgrvMf oxA== X-Google-Smtp-Source: AGHT+IFPfL7Bz+2w/gHUxVNzDAVHM9oDCNsFvb3wNbKTtGGIaiXiiN7mBPUbCAHCoC8mONNbIHLwrw== X-Received: by 2002:a05:6e02:12c7:b0:39b:4ec2:c5be with SMTP id e9e14a558f8ab-39d26d803cdmr12462755ab.27.1723753479689; Thu, 15 Aug 2024 13:24:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 13:24:39 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH v4 14/14] test: efi: boot: Add a test for the efi bootmeth Date: Thu, 15 Aug 2024 14:24:24 -0600 Message-Id: <20240815202424.766778-15-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 Add a simple test of booting with the EFI bootmeth, which runs the app and checks that it can call 'exit boot-services' (to check that all the device-removal code doesn't break anything) and then exit back to U-Boot. This uses a disk image containing the testapp, ready for execution by sandbox when needed. Signed-off-by: Simon Glass --- Changes in v4: - Add efi_loader tag to some patches - Split out non-EFI patches into a different series Changes in v2: - Add many new patches to resolve all the outstanding test issues test/boot/bootflow.c | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 6d85cf20dd5..8822dac8503 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #ifdef CONFIG_SANDBOX #include @@ -31,6 +32,9 @@ extern U_BOOT_DRIVER(bootmeth_android); extern U_BOOT_DRIVER(bootmeth_cros); extern U_BOOT_DRIVER(bootmeth_2script); +/* Use this as the vendor for EFI to tell the app to exit boot services */ +static u16 __efi_runtime_data test_vendor[] = u"U-Boot testing"; + static int inject_response(struct unit_test_state *uts) { /* @@ -1225,3 +1229,57 @@ static int bootflow_android(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_android, UT_TESTF_CONSOLE_REC); + +/* Test EFI bootmeth */ +static int bootflow_efi(struct unit_test_state *uts) +{ + /* disable ethernet since the hunter will run dhcp */ + test_set_eth_enable(false); + + /* make USB scan without delays */ + test_set_skip_delays(true); + + bootstd_reset_usb(); + + /* Avoid outputting ANSI characters which mess with our asserts */ + efi_console_set_ansi(false); + + ut_assertok(bootstd_test_drop_bootdev_order(uts)); + ut_assertok(run_command("bootflow scan", 0)); + ut_assert_skip_to_line( + "Bus usb@1: scanning bus usb@1 for devices... 5 USB Device(s) found"); + + ut_assertok(run_command("bootflow list", 0)); + + ut_assert_nextlinen("Showing all"); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 extlinux"); + ut_assert_nextlinen( + " 1 efi ready usb_mass_ 1 usb_mass_storage.lun0.boo /EFI/BOOT/BOOTSBOX.EFI"); + ut_assert_nextlinen("---"); + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); + ut_assert_console_end(); + + ut_assertok(run_command("bootflow select 1", 0)); + ut_assert_console_end(); + + /* signal to helloworld to exit boot services */ + systab.fw_vendor = test_vendor; + + ut_asserteq(1, run_command("bootflow boot", 0)); + ut_assert_nextline( + "** Booting bootflow 'usb_mass_storage.lun0.bootdev.part_1' with efi"); + ut_assert_skip_to_line("Booting /\\EFI\\BOOT\\BOOTSBOX.EFI"); + + /* TODO: Why the \r ? */ + ut_assert_nextline("U-Boot test app for EFI_LOADER\r"); + ut_assert_nextline("Exiting boot sevices"); + ut_assert_nextline("## Application failed, r = 5"); + ut_assert_nextline("Boot failed (err=-22)"); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_efi, UT_TESTF_CONSOLE_REC); -- 2.34.1