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 89A88C433EF for ; Wed, 23 Mar 2022 06:33:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9094283B15; Wed, 23 Mar 2022 07:33:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Fr1t9OH1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2824983B2C; Wed, 23 Mar 2022 07:33:07 +0100 (CET) Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 43FBB83B10 for ; Wed, 23 Mar 2022 07:33:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x530.google.com with SMTP id bc27so383364pgb.4 for ; Tue, 22 Mar 2022 23:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=+sirqYhj8ufB39mVs7yUjdy7kuNRcv7x79Hoz/VjCJ0=; b=Fr1t9OH1LIrSmRUWKvQBuWIukAFPnBWQpLn45grikkSGWB4GKlayxkOkIapLbTh1SQ Ga+BdRHda7MeEcMnwf7HDG7keqXDi6m7OxpBQT6TwR5NUaRjB8Fz396uPgnAWpbTGRxC lIWBvp+oy1XohjPFh+Qq23MHH0OPvSDTwUmtVrgAj4hYxwBLYI/ZReELTwyUbSW4PCLu /pRSJc8xxeWoBq9TR5DLdYwroVwTsRrJp8pGuTkNj+kADYdcpygrDzYJjDvkFDIN/g2g 3qCdeVODWoJ5gU6NzdD6fqb34TK+/xmuDNMrm23TGi8MR1PGC29OxUCz1kqUnt5zEwFL 94uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=+sirqYhj8ufB39mVs7yUjdy7kuNRcv7x79Hoz/VjCJ0=; b=mvzfb3+sITqSSB0N1Srj54Z531y35M6Nb+XMgtCIA4JHCKPwzCZiONm2Y+Y5M/PeWJ qhi4hN3EL35kV1g3ehwixX8hwsvb+3n4DNQLK7NlGOQ9T9cv5XAJgizhTfil7VFp2IHA yN6SyWv0ZsUnw0hdSFgXswTZ5WWoFYeYGyVDnfsDHydGoTEBOnt1Ot1CsLMXhFkuSlP+ bx55lMROF6B5RRcem0PRoewWISU6XHREm5uA5OFVgPSCjdDPRDm8P7CP0oI22JfBh7ty Wsgv8pomV0pP0BAm0ztx4HUUJMb8A0yAHI27Y5sqXxe74zWzhH25OsOo4xjrnGlriO4/ n8fQ== X-Gm-Message-State: AOAM531BiBWVnnT84pnXWwTGwntCZ16dzRGvvGGXrfiSL/QMcgRJtKzE eEyP2linyAY5mklaOofH3UGrww== X-Google-Smtp-Source: ABdhPJzxI2kLE5TBKhmX3359ZrTtmZCEAZYcmVK81UpaJ5AyemNBjm3T3cylmGtUAkFypg0OJ05P5Q== X-Received: by 2002:a63:e74d:0:b0:37c:728a:e06f with SMTP id j13-20020a63e74d000000b0037c728ae06fmr2891860pgk.458.1648017180535; Tue, 22 Mar 2022 23:33:00 -0700 (PDT) Received: from laputa ([2400:4050:c3e1:100:2199:5d47:ea3f:788f]) by smtp.gmail.com with ESMTPSA id p10-20020a056a0026ca00b004fa06fa407asm25859512pfw.91.2022.03.22.23.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 23:33:00 -0700 (PDT) Date: Wed, 23 Mar 2022 15:32:56 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Ilias Apalodimas Subject: Re: [PATCH v3 3/3] test: test UEFI boot manager Message-ID: <20220323063256.GA49108@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , u-boot@lists.denx.de, Ilias Apalodimas References: <20220322205807.7584-1-heinrich.schuchardt@canonical.com> <20220322205807.7584-4-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220322205807.7584-4-heinrich.schuchardt@canonical.com> 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.5 at phobos.denx.de X-Virus-Status: Clean On Tue, Mar 22, 2022 at 09:58:07PM +0100, Heinrich Schuchardt wrote: > Provide a unit test for > > * efidebug boot add and other boot sub-commands as well? See below. > * efidebug bootmgr -> bootefi bootmgr > * initrd via EFI_LOAD_FILE2_PROTOCOL > > Signed-off-by: Heinrich Schuchardt > --- > v3: > pass u"nocolor" as optional data to initrddump.efi > v2: > new patch > --- > test/py/tests/test_efi_bootmgr/conftest.py | 42 +++++++++++++++++++ > .../test_efi_bootmgr/test_efi_bootmgr.py | 31 ++++++++++++++ > 2 files changed, 73 insertions(+) > create mode 100644 test/py/tests/test_efi_bootmgr/conftest.py > create mode 100644 test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py > > diff --git a/test/py/tests/test_efi_bootmgr/conftest.py b/test/py/tests/test_efi_bootmgr/conftest.py > new file mode 100644 > index 0000000000..69008fddce > --- /dev/null > +++ b/test/py/tests/test_efi_bootmgr/conftest.py > @@ -0,0 +1,42 @@ > +# SPDX-License-Identifier: GPL-2.0+ > + > +"""Fixture for UEFI bootmanager test > +""" > + > +import os > +import pytest > +import shutil > +from subprocess import call, check_call > + > +@pytest.fixture(scope='session') > +def efi_bootmgr_data(u_boot_config): > + """Set up a file system to be used in UEFI bootmanager > + tests > + > + Args: > + u_boot_config: U-boot configuration. > + > + Return: > + A path to disk image to be used for testing > + """ > + mnt_point = u_boot_config.persistent_data_dir + '/test_efi_bootmgr' > + image_path = u_boot_config.persistent_data_dir + '/efi_bootmgr.img' > + > + shutil.rmtree(mnt_point, ignore_errors=True) > + os.mkdir(mnt_point, mode = 0o755) > + > + with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file: > + file.write("initrd 1") > + > + with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file: > + file.write("initrd 2") > + > + shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi', > + mnt_point + '/initrddump.efi') > + > + check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat {} {}' > + .format(mnt_point, image_path), shell=True) > + > + print(image_path) > + > + yield image_path > diff --git a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py > new file mode 100644 > index 0000000000..feba306580 > --- /dev/null > +++ b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py > @@ -0,0 +1,31 @@ > +# SPDX-License-Identifier: GPL-2.0+ > + > +import pytest > + > +@pytest.mark.boardspec('sandbox') > +@pytest.mark.buildconfigspec('efi_loader') Obviously, this test depends on 'cmd_efidebug' and 'cmd_bootefi'. > +def test_efi_bootmgr(u_boot_console, efi_bootmgr_data): > + u_boot_console.run_command(cmd = 'host bind 0 {}'.format(efi_bootmgr_data)) > + > + u_boot_console.run_command(cmd = 'efidebug boot add ' \ > + '-b 0001 label-1 host 0:1 initrddump.efi ' \ > + '-i host 0:1 initrd-1.img -s nocolor') > + u_boot_console.run_command(cmd = 'efidebug boot dump') Why do you call "boot dump" here? If you intend to test this sub-command, you should check the output. Or do you think it's enough to simply exercise the code for testing? > + u_boot_console.run_command(cmd = 'efidebug boot order 0001') > + u_boot_console.run_command(cmd = 'bootefi bootmgr') > + response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False) > + assert 'crc32: 0x181464af' in response > + u_boot_console.run_command(cmd = 'exit', wait_for_echo=False) > + > + u_boot_console.run_command(cmd = 'efidebug boot add ' \ > + '-B 0002 label-2 host 0:1 initrddump.efi ' \ > + '-I host 0:1 initrd-2.img -s nocolor') > + u_boot_console.run_command(cmd = 'efidebug boot dump') > + u_boot_console.run_command(cmd = 'efidebug boot order 0002') > + u_boot_console.run_command(cmd = 'bootefi bootmgr') > + response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False) > + assert 'crc32: 0x811d3515' in response > + u_boot_console.run_command(cmd = 'exit', wait_for_echo=False) If you like, please add a test for "boot next" (or BootNext variable) as well. Thanks, -Takahiro Akashi > + > + u_boot_console.run_command(cmd = 'efidebug boot rm 0001') > + u_boot_console.run_command(cmd = 'efidebug boot rm 0002') > -- > 2.34.1 >