From patchwork Tue Nov 16 04:32:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 519171 Delivered-To: patch@linaro.org Received: by 2002:ac0:c605:0:0:0:0:0 with SMTP id p5csp6619701imj; Mon, 15 Nov 2021 20:35:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnK2h/J9L0h5rk3GRIT4JaHYefLiwwsOWfJaOgI9yPPRJBd3U7hU+AgBLZzSL/IdaqAHA9 X-Received: by 2002:a05:6402:354f:: with SMTP id f15mr6250925edd.390.1637037313940; Mon, 15 Nov 2021 20:35:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637037313; cv=none; d=google.com; s=arc-20160816; b=aQuwZ01yFR0V8FxYQFZ4bYbva30D3DM1Y9jq/4aeiookoJ1V2TpJXDXvbDck8x/809 IFz9CgxuQNZcxsPFM1V3Ih/BF2/ehXMh5yNXBMe+3xJSxK3VEzHFebd44BFN3YroXWaA gNS4QJYxNXCJdO3CfwZPXaXYaDjCLHS6t1/SGROlOjJdCSui3FlVAuY5vrgdKbV7emGm uz7UOEXrA4+czdd8n42qHWo2as+T7cHVtwsBNFRsY93Xhd85H1i01An0C+CZJpaF8yJ2 4ossMDEibVmXdaNrFb+UskBdtuo81wA5cnBNbYOO275anHYOxRkGugXXA4pDz0GYojhc 9IKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=37b4CbGVq2vXfUQd07BoRyvPsjDtxkfVdV+ImREOVoM=; b=0aVeonVylNzzXSgQy0ge1PLjhGik3UMy61U++VMhnL0oe5ThqBi+sT5dTf4FSydol9 WkEUw+qx9koi8LizVRxahFSDLeamAJE7yWX2cZrAyiIqhpe5ZVMwck6zYfcD3sNnl3rt O7Om8ptsfL0CI+dxx3v7+8AVQmOCyy0yKmqaLAr7Lh8plGQq6dPkt4FbAdVLj1khtG5S qQ+aZTf598POJneilSyL+onKqLbpa2IzsUVMtwupeFv68ECgeu8Tk2/Dcd+09FH/jq7K xSXD+AlU9EWOHMsvWcklC4VmwkgxNd5vWDatKfCsl0KDItjQSZesUqwJ4Ki14Z7Hkh1d Tj9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mhb17GCf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id y8si36417670edw.205.2021.11.15.20.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 20:35:13 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mhb17GCf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D478E83816; Tue, 16 Nov 2021 05:34:55 +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="mhb17GCf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 76255837E2; Tue, 16 Nov 2021 05:33:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (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 BF227837F9 for ; Tue, 16 Nov 2021 05:33:44 +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-pj1-x1033.google.com with SMTP id x7so14634113pjn.0 for ; Mon, 15 Nov 2021 20:33:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=37b4CbGVq2vXfUQd07BoRyvPsjDtxkfVdV+ImREOVoM=; b=mhb17GCfySjrQ9qoYZ28PU6JoQTqIu3EtrdRnkqp1uxuy6nUCaf5syF1nWQ0MybxfA N7hSF796c9cQ1LKJ4FqbTyDEfTdTtQW3Og8jd2UFv/aOpc16xs/AFx0NOA8IigfMjdeO VdIxJPA6/I1W0yVYEA6WRWWIDOVNISrljXtgNWcAt/PckCy9czC3CmvCmsvxumlDwHrN rndswK1FiKn7IVdVDb0YVDWZJXOUSw4twTZ7o8g9HYv+/9NjIvUGlFe+9JSbu54uDqqE UHQ+hEUWmIytHIXMFN9nY9R7u44sYQa6hTiffZBEnY38Kvtzv0QWMP9UnKd5elLnvo5W i2KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=37b4CbGVq2vXfUQd07BoRyvPsjDtxkfVdV+ImREOVoM=; b=mf4NaJ+TJd1PQTZ4LfL9nSSQt5+I2EBjd7hQZkswzkUveX/kM6NYG4TcoFWenu/2kQ /zYvUBBkTHW8WuEDCr78qlN5zq6vrzdjsOMttw/VSYMYkSR6irF+tEB6zXhk+bEHZN9O jvw0H1wJ3uRzNZ7fXMZnEB4AHTTK4f3B8+8SJw9JW3s6tja6d+fVcn165yfymZD4wAgg Ic/T03ZluSkCzKTAIjzgfD4O7MJO43D3dUc2N+7kvYfat6rABrcSjyKYX7mjOsatWh6M kgqS7+GDpkPLcol0XbFVAWI2vS762/4zt/k0wgmINo3/pYOHtAfzMOvtYb4XsHkVSKL0 88Ow== X-Gm-Message-State: AOAM532+3iKkPpwm0U3hD8jUhCcTMt69h4B5zEey7MM1mnYRl+gTbRbS EtZWRiu+5v1fpT2MnOyHFt7QSA== X-Received: by 2002:a17:903:1109:b0:143:85f3:af29 with SMTP id n9-20020a170903110900b0014385f3af29mr41818190plh.47.1637037223125; Mon, 15 Nov 2021 20:33:43 -0800 (PST) Received: from localhost.localdomain ([2400:4050:c3e1:100:d07c:c772:1ab9:a9e0]) by smtp.gmail.com with ESMTPSA id lt5sm782914pjb.43.2021.11.15.20.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 20:33:42 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, masami.hiramatsu@linaro.org, mark.kettenis@xs4all.nl, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v7 09/12] test/py: efi_capsule: add a test for "--guid" option Date: Tue, 16 Nov 2021 13:32:35 +0900 Message-Id: <20211116043238.67226-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211116043238.67226-1-takahiro.akashi@linaro.org> References: <20211116043238.67226-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.35 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.2 at phobos.denx.de X-Virus-Status: Clean This test scenario tests a new feature of mkeficapsule, "--guid" option, which allows us to specify FMP driver's guid explicitly at the command line. Signed-off-by: AKASHI Takahiro --- test/py/tests/test_efi_capsule/conftest.py | 3 + .../test_efi_capsule/test_capsule_firmware.py | 67 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index a5a25c53dcb4..9076087a12b7 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -86,6 +86,9 @@ def efi_capsule_data(request, u_boot_config): check_call('cd %s; %s/tools/mkeficapsule --index 1 --raw u-boot.bin.new Test02' % (data_dir, u_boot_config.build_dir), shell=True) + check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid E2BB9C06-70E9-4B14-97A3-5A7913176E3F u-boot.bin.new Test03' % + (data_dir, u_boot_config.build_dir), + shell=True) if capsule_auth_enabled: # firmware signed with proper key check_call('cd %s; ' diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware.py b/test/py/tests/test_efi_capsule/test_capsule_firmware.py index 9eeaae27d626..9cc973560fa1 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware.py @@ -247,3 +247,70 @@ class TestEfiCapsuleFirmwareFit(object): 'sf read 4000000 100000 10', 'md.b 4000000 10']) assert 'u-boot:New' in ''.join(output) + + def test_efi_capsule_fw4( + self, u_boot_config, u_boot_console, efi_capsule_data): + """ + Test Case 4 - Test "--guid" option of mkeficapsule + The test scenario is the same as Case 3. + """ + disk_img = efi_capsule_data + with u_boot_console.log.section('Test Case 4-a, before reboot'): + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'efidebug boot add -b 1 TEST host 0:1 /helloworld.efi -s ""', + 'efidebug boot order 1', + 'env set -e -nv -bs -rt OsIndications =0x0000000000000004', + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'env save']) + + # initialize content + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'fatload host 0:1 4000000 %s/u-boot.bin.old' % CAPSULE_DATA_DIR, + 'sf write 4000000 100000 10', + 'sf read 5000000 100000 10', + 'md.b 5000000 10']) + assert 'Old' in ''.join(output) + + # place a capsule file + output = u_boot_console.run_command_list([ + 'fatload host 0:1 4000000 %s/Test03' % CAPSULE_DATA_DIR, + 'fatwrite host 0:1 4000000 %s/Test03 $filesize' % CAPSULE_INSTALL_DIR, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test03' in ''.join(output) + + # reboot + u_boot_console.restart_uboot() + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + with u_boot_console.log.section('Test Case 4-b, after reboot'): + if not capsule_early: + # make sure that dfu_alt_info exists even persistent variables + # are not available. + output = u_boot_console.run_command_list([ + 'env set dfu_alt_info "sf 0:0=u-boot-bin raw 0x100000 0x50000;u-boot-env raw 0x150000 0x200000"', + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test03' in ''.join(output) + + # need to run uefi command to initiate capsule handling + output = u_boot_console.run_command( + 'env print -e Capsule0000') + + output = u_boot_console.run_command_list(['efidebug capsule esrt']) + + # ensure that EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID is in the ESRT. + assert 'E2BB9C06-70E9-4B14-97A3-5A7913176E3F' in ''.join(output) + + output = u_boot_console.run_command_list([ + 'host bind 0 %s' % disk_img, + 'fatls host 0:1 %s' % CAPSULE_INSTALL_DIR]) + assert 'Test03' not in ''.join(output) + + output = u_boot_console.run_command_list([ + 'sf probe 0:0', + 'sf read 4000000 100000 10', + 'md.b 4000000 10']) + assert 'u-boot:New' in ''.join(output)