From patchwork Thu Oct 28 06:23:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 516362 Delivered-To: patch@linaro.org Received: by 2002:ac0:c404:0:0:0:0:0 with SMTP id t4csp1371400imj; Wed, 27 Oct 2021 23:26:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcMRmWUpa5pCOC84C1RVhR5hHcthxa5qnOwIiH1TMPEq1Far2hyuv4OW5MwYklzdRkCVVy X-Received: by 2002:a05:6402:4303:: with SMTP id m3mr3538155edc.328.1635402389213; Wed, 27 Oct 2021 23:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635402389; cv=none; d=google.com; s=arc-20160816; b=G4UuijjD3acZ3Up9+T6NsNDNJ2mJcQZomgih/F0kpMrMpPLt7Qk19RBp8RsLsph4wd RJL3ZBJB+hdQDyM7eN3HHy+ibhxMIwBoowePCbRWkWDx3DXPd+G/PNsJmU8qexhbwSKa uPTouwW/4aQbsGAO4WPz8m4OF4Q/+7orkM9wZbmXWHsoXXzDjVBcW0HjXq6LZ+tQDeN0 S7VRKdn1L+8z8C6gNrBxTgQ9H+WTaAdWlESdjalYVBiXF86B24pZZfAOKSEV3hraUYGY odARmgSBodJs6xXXFfREOIy5PoQsd/2F7prIK6fyItFQhSjCi6pg1EYBEwejaLOGZZb6 0o2w== 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=i6GO9GbOEVkVGCqDCcFVm5yBGFySYGoKpp+moWwFpJY=; b=F3urrnP7ify1R/wcISvO9RLWWvagioN4m3L3AfdjlWho2TYamMVkAA+MbzemoXeW1t TyB3Wssmf10tfEHHgc02sg/E/ITDXCGROYS18sy9dzidVN/F2q6HztpzqG7s+NHo2tEG m4GpjlRD26UqjRbamTsw+zmBvaIvFaBtuwNpYABT6hQA2UwQ5Lc25C8gaK0Cd6D+g3Tw EfvITkm8V1HQNhzTZYCsd7RmFv/JKMHNRZJvPOwbwa8iy0mRAEujD3NLGZ7F2K8LOB/7 Ea1F1JamNCvFFxnmOC727mrzPceOzMeuzaQHLxB5aQfJpSzk/IMIlU+h3YNdAkRPzmYs mHwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fy7iCJUg; 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 sc24si4098958ejc.355.2021.10.27.23.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 23:26:29 -0700 (PDT) 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=Fy7iCJUg; 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 1AF318357F; Thu, 28 Oct 2021 08:26:02 +0200 (CEST) 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="Fy7iCJUg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43F6B831B4; Thu, 28 Oct 2021 08:25:35 +0200 (CEST) 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-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (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 B483E82F33 for ; Thu, 28 Oct 2021 08:25:19 +0200 (CEST) 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-pl1-x62f.google.com with SMTP id i5so3714310pla.5 for ; Wed, 27 Oct 2021 23:25:19 -0700 (PDT) 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=i6GO9GbOEVkVGCqDCcFVm5yBGFySYGoKpp+moWwFpJY=; b=Fy7iCJUgRR71tHWauVtfL3KbdO41KS9l8PR8Hui1hU8R7g9Fu0EwB7u1FdeU0e0vG9 mCRK/7ImkvrDda6uiM+q+pIoenrPghBVbTqir2IyVKLWkTJUybdNjAFr/2nDqd1Rdrwy TJQh94IhnfJM0dZeGs1smS9TQfZ6YwCNg32zIsa43Jqp6A/pW0D4i+EiHXcHHf9+NbHs 8Ix6cjyWMxhrCE08+44vr1EvtmvoVbCgANOCnpUWNhm4cxnOt/0CQUtyRfHFG5lXmDgO 6/qwyCTNwi7TRxYtWayuUhqS+ALAgsEQlYoA3WJsNpK/q8wBfvdBTkTOMCVTTrlJzdEG zsCg== 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=i6GO9GbOEVkVGCqDCcFVm5yBGFySYGoKpp+moWwFpJY=; b=YFhLl5q1aqynaCvhmpV2UAFsOVuOp875XFZvU7DGvhe0WjE/sZUApwf+KjtRkn5zF8 KENWpMhS9dpie3YctVyVlnwobtqwiyObPp8hixXg1hmobQjFacCpJVVUNc/kBf1SQk4R 67EGv8M4P+9optwrlK7GkPI1QNQA91tdmR2DwySZ9+BpDZV6Gn60MQntcEEykg2B1yRZ XZcwn+174b+w8DrgbLSeFsjms/O92SADz8mGVoupRNA2+GW1cU4UJks1ZvXsACdQsHtu capQlBpRG0nR5q/8AvYWbT9DvnspvpgzhIdj7MhwZ3n9goefDLQuU/NBFvMmuULOYw74 9TFQ== X-Gm-Message-State: AOAM531MtqvqAjuz+r3tPbIpDvn3Qh7uj574HoczTmjzfFrog95HSfIB YxNiFedDGcEETzd29PM31biQzA== X-Received: by 2002:a17:90a:1a4c:: with SMTP id 12mr2440436pjl.175.1635402318044; Wed, 27 Oct 2021 23:25:18 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:394a:97ee:bbbb:462e]) by smtp.gmail.com with ESMTPSA id p16sm1582018pgd.78.2021.10.27.23.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 23:25:17 -0700 (PDT) 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, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v5 08/11] test/py: efi_capsule: add a test for "--guid" option Date: Thu, 28 Oct 2021 15:23:53 +0900 Message-Id: <20211028062356.98224-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211028062356.98224-1-takahiro.akashi@linaro.org> References: <20211028062356.98224-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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(+) -- 2.33.0 diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 08bcd74dd991..b31dea5c1df6 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -76,6 +76,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; %s/tools/mkeficapsule --index 1 --monotonic-count 1 --private-key SIGNER.key --certificate SIGNER.crt --raw u-boot.bin.new Test11' % 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)