From patchwork Tue Nov 2 00:55:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 516605 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp3916872iml; Mon, 1 Nov 2021 17:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzRPTpNCNRxCOorxyN6C6VWxV04Z1GpyqEZJ7cHA9blfdleX7UkdWnBakOyZWQbL9IQEhA X-Received: by 2002:a05:6402:1102:: with SMTP id u2mr24028340edv.124.1635814646853; Mon, 01 Nov 2021 17:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635814646; cv=none; d=google.com; s=arc-20160816; b=iR8OU6kVq/vsO7o2ZfXLPLB6mQuxxGzqiJqwX/RbsV25kKgGhUi2f4X1IIlzsmxLIL 3Ba3j50Yc7bFlKfhovFPdrBqynRbj9v9bLKwl9qq66A+RRCVXv7FfOhUDvrsA50VTaZc oaPDNG3VwbxCbPw+JL/b9oNcLa9c6vP46wyCXbdVLlDsEx0hTH8swaCA6xEnlVaTbpU3 JiYODTMesf9XtxXkPrKkn8RSFMsdo18kJgJBVPTd6N7IWojYIzfN4IC8YCFLwq/AUlo8 BdPjrWFsp/2x6haArz7IEmP7uSPcstq+ZIa9u4O9+OSTaOItiwt2fUGZoBilYwwvFO+f KNkQ== 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=TdVQHXupoSSjvFnnthHgCO5XXzjA1KnrFCMANt33JXRjBNPqtb+SM+RqDQTD2H7LUW HyIcAiO7wyjGDu2lWXqraVytlFgxYHPKHqjDokjg4+ZaBBIxQdIBk/wKmIVq6IdaveuI DR9HRMvV1YkuNVdkOB1up11KqtiHPI+bG0jVIiwPL80x7LCo5R/FJrt2A+BVpQe9jVGf GPVtiTLNBNleZuY+2kGM36AZUbiFSEwzUxmdT3DF0G9XOgf6u39QDPJVy5pZWBVMqv0X wHsUjdVpzLjt3aOKvxhadj+Vf6jH8X5+Jp60mnKnFTlgihyXukq5AevoOusGomuw5W0I JLOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yQfVER6G; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id fy1si31513116ejc.23.2021.11.01.17.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 17:57:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yQfVER6G; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 927A6835DB; Tue, 2 Nov 2021 01:57: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="yQfVER6G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5DDAD83383; Tue, 2 Nov 2021 01:56:37 +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-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 5563A83606 for ; Tue, 2 Nov 2021 01:56:14 +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-pf1-x433.google.com with SMTP id s5so6412356pfg.2 for ; Mon, 01 Nov 2021 17:56:14 -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=37b4CbGVq2vXfUQd07BoRyvPsjDtxkfVdV+ImREOVoM=; b=yQfVER6GSIJyUxO66UVaIz9fAMhskCgw/3XkiQP49GsAgl4N0vAs/AbL9kcCcPG7Xz ZW8s3IXCJOFEngswgXcFItDPcsFWhDoJBwXpxFbDktq9X18Jh3sktbtcZs3pFLXR/PPq 3HhdygTUK6owSL9FChEm2KL/M3bwhkod2exicWtj7OiM1ebRwtN1E9k3AzJtv+eHMQ0b Uo6KTjsSyBzKOxL5DEtCR38dpXIa+bJgpjH1rUrNe+yUMCrln+bPc0ULD/LH1v8MZUin lEZJt52G+rkPub7T5KKUfjO4EOwiGWCFo3HiJxmZxmhZd2cWjj3dYtzsJUkbvfT22njW vw4Q== 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=OujP6h9DDNh+eMoPC+WsxmMlVguZBy8CKynihZT/e2cGNYmMFI1VbD/Yb7hE7g+vVw wf/zajkgR+D2ypXUYDuuf2u92Iqoa4gSJ5e97rFG+YNAF6gEOaRiBaGsP3NdxTzuSWuG u8IgfWmzghFV64UDVLO3MI1AuAcEhddTD9Ks/2Wi/O3CS3pvJber8RwhFz40hyFMHajN GuvpZVjVrMV19Rew+xl9ujcHuFZP3pCSEpIYCNfxJGWXRsJJ47JiClf5TFVzluR8FhJH U+E107ztnj7WqX5p4fc6INNSCEWr/FWBfK020OTeWVx2UbOHYkbWEoA+OwVyS98d2mOI q2aA== X-Gm-Message-State: AOAM530hhG1kFprO2n6psE33Sc1FnjoaRBNukrvcBGWEdlwnZYrB8LHr 20M3chQgaYy5MpY/06PnQGdYqg== X-Received: by 2002:a05:6a00:c94:b0:480:fcc2:bb2c with SMTP id a20-20020a056a000c9400b00480fcc2bb2cmr14101834pfv.30.1635814572599; Mon, 01 Nov 2021 17:56:12 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c3e1:100:a475:65cc:d4b7:aaf5]) by smtp.gmail.com with ESMTPSA id n29sm12305596pfv.29.2021.11.01.17.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 17:56:12 -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 v6 09/12] test/py: efi_capsule: add a test for "--guid" option Date: Tue, 2 Nov 2021 09:55:09 +0900 Message-Id: <20211102005512.96019-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211102005512.96019-1-takahiro.akashi@linaro.org> References: <20211102005512.96019-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 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)