From patchwork Fri Apr 14 08:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1768860 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=wD32PlA0; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PyV9F5ptsz1yZk for ; Fri, 14 Apr 2023 18:34:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93B1985EE2; Fri, 14 Apr 2023 10:34:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com 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=canonical.com header.i=@canonical.com header.b="wD32PlA0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 857AE85EA5; Fri, 14 Apr 2023 10:34:02 +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,DKIMWL_WL_HIGH, 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 smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4120685E73 for ; Fri, 14 Apr 2023 10:33:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=heinrich.schuchardt@canonical.com Received: from workstation5.fritz.box (ip-088-152-145-137.um26.pools.vodafone-ip.de [88.152.145.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 19C5A3FF91; Fri, 14 Apr 2023 08:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1681461238; bh=UKQF+/oFgPYOrS11sGy+FwzuFO5/IkQ+UiWN32LR6Qg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=wD32PlA0UyxnJB7cvYhQo97irr63ni47TfRiwLYSlF1lAyasFPCfyS9dug6WlTZct QiPue7KR0XR3RiEtytLGJKktinlGuOAGx4+JqN43DRbg+6NeiEbfiUuHsi6tiKMJHV /EY6sythDub5VDsZ8ym520NoSziol+IxXCD2spFEsNz10C34kyAh+XzwtANUk+GuFL 2d5+PwlHcEAQJhSmRrHNjpO1ZZmVEy53QazmtqQbTnwgZdgaZU8qVJpgH2fIqeFU8s wXhVztmHiOhvTAAFr6KK4EeYCLG14NNSxOqNEGS+zpf93tAQ1jr43coz0yzgAa9ExP j6TKmXUJQj3fA== From: Heinrich Schuchardt To: Ilias Apalodimas Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 1/1] test: fix pylint warning for capsule tests Date: Fri, 14 Apr 2023 10:33:41 +0200 Message-Id: <20230414083341.288058-1-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 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 Fix pylint warnings like: * Class inherits from object * Missing module description * Missing class description * First line of comment blank * Superfluous imports Signed-off-by: Heinrich Schuchardt --- test/py/tests/test_efi_capsule/conftest.py | 27 ++++-------- .../test_capsule_firmware_fit.py | 35 ++++++++-------- .../test_capsule_firmware_signed_fit.py | 41 ++++++++++--------- .../test_capsule_firmware_signed_raw.py | 38 ++++++++--------- 4 files changed, 65 insertions(+), 76 deletions(-) diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 4879f2b5c2..0e5137de60 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -2,30 +2,21 @@ # Copyright (c) 2020, Linaro Limited # Author: AKASHI Takahiro -import os -import os.path -import re -from subprocess import call, check_call, check_output, CalledProcessError -import pytest -from capsule_defs import * +"""Fixture for UEFI capsule test +""" -# -# Fixture for UEFI capsule test -# +from subprocess import call, check_call, CalledProcessError +import pytest +from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH @pytest.fixture(scope='session') def efi_capsule_data(request, u_boot_config): - """Set up a file system to be used in UEFI capsule and - authentication test. - - Args: - request: Pytest request object. - u_boot_config: U-boot configuration. + """Set up a file system to be used in UEFI capsule and authentication test + and return a ath to disk image to be used for testing - Return: - A path to disk image to be used for testing + request -- Pytest request object. + u_boot_config -- U-boot configuration. """ - global CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR mnt_point = u_boot_config.persistent_data_dir + '/test_efi_capsule' data_dir = mnt_point + CAPSULE_DATA_DIR diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py index d28b53a1a1..9ee152818d 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py @@ -1,16 +1,13 @@ # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2020, Linaro Limited # Author: AKASHI Takahiro -# -# U-Boot UEFI: Firmware Update Test -""" +"""U-Boot UEFI: Firmware Update Test This test verifies capsule-on-disk firmware update for FIT images """ -from subprocess import check_call, check_output, CalledProcessError import pytest -from capsule_defs import * +from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR @pytest.mark.boardspec('sandbox_flattree') @@ -24,15 +21,18 @@ from capsule_defs import * @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow -class TestEfiCapsuleFirmwareFit(object): +class TestEfiCapsuleFirmwareFit(): + """Test capsule-on-disk firmware update for FIT images + """ + def test_efi_capsule_fw1( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 1 - Update U-Boot and U-Boot environment on SPI Flash - but with an incorrect GUID value in the capsule - No update should happen - 0x100000-0x150000: U-Boot binary (but dummy) - 0x150000-0x200000: U-Boot environment (but dummy) + """Test Case 1 + Update U-Boot and U-Boot environment on SPI Flash + but with an incorrect GUID value in the capsule + No update should happen + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) """ # other tests might have run and the # system might not be in a clean state. @@ -74,8 +74,6 @@ class TestEfiCapsuleFirmwareFit(object): capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') - capsule_auth = u_boot_config.buildconfig.get( - 'config_efi_capsule_authenticate') # reboot u_boot_console.restart_uboot(expect_reset = capsule_early) @@ -107,11 +105,12 @@ class TestEfiCapsuleFirmwareFit(object): def test_efi_capsule_fw2( self, u_boot_config, u_boot_console, efi_capsule_data): + """Test Case 2 + Update U-Boot and U-Boot environment on SPI Flash + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) """ - Test Case 2 - Update U-Boot and U-Boot environment on SPI Flash - 0x100000-0x150000: U-Boot binary (but dummy) - 0x150000-0x200000: U-Boot environment (but dummy) - """ + disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 2-a, before reboot'): output = u_boot_console.run_command_list([ diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py index 8c2d616fd0..ba8429e83c 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py @@ -3,10 +3,8 @@ # Copyright (c) 2022, Arm Limited # Author: AKASHI Takahiro , # adapted to FIT images by Vincent Stehlé -# -# U-Boot UEFI: Firmware Update (Signed capsule with FIT images) Test -""" +"""U-Boot UEFI: Firmware Update (Signed capsule with FIT images) Test This test verifies capsule-on-disk firmware update with signed capsule files containing FIT images """ @@ -25,15 +23,18 @@ from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow -class TestEfiCapsuleFirmwareSignedFit(object): +class TestEfiCapsuleFirmwareSignedFit(): + """Capsule-on-disk firmware update test + """ + def test_efi_capsule_auth1( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 1 - Update U-Boot on SPI Flash, FIT image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 1 + Update U-Boot on SPI Flash, FIT image format + x150000: U-Boot binary (but dummy) - If the capsule is properly signed, the authentication - should pass and the firmware be updated. + If the capsule is properly signed, the authentication + should pass and the firmware be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 1-a, before reboot'): @@ -103,13 +104,13 @@ class TestEfiCapsuleFirmwareSignedFit(object): def test_efi_capsule_auth2( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 2 - Update U-Boot on SPI Flash, FIT image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 2 + Update U-Boot on SPI Flash, FIT image format + 0x100000-0x150000: U-Boot binary (but dummy) - If the capsule is signed but with an invalid key, - the authentication should fail and the firmware - not be updated. + If the capsule is signed but with an invalid key, + the authentication should fail and the firmware + not be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 2-a, before reboot'): @@ -182,12 +183,12 @@ class TestEfiCapsuleFirmwareSignedFit(object): def test_efi_capsule_auth3( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 3 - Update U-Boot on SPI Flash, FIT image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 3 + Update U-Boot on SPI Flash, FIT image format + 0x100000-0x150000: U-Boot binary (but dummy) - If the capsule is not signed, the authentication - should fail and the firmware not be updated. + If the capsule is not signed, the authentication + should fail and the firmware not be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 3-a, before reboot'): diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py index 2bbaa9cc55..710d9925a3 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py @@ -1,10 +1,8 @@ # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2021, Linaro Limited # Author: AKASHI Takahiro -# -# U-Boot UEFI: Firmware Update (Signed capsule with raw images) Test -""" +"""U-Boot UEFI: Firmware Update (Signed capsule with raw images) Test This test verifies capsule-on-disk firmware update with signed capsule files containing raw images """ @@ -23,15 +21,17 @@ from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow -class TestEfiCapsuleFirmwareSignedRaw(object): +class TestEfiCapsuleFirmwareSignedRaw(): + """Firmware Update (Signed capsule with raw images) Test + """ + def test_efi_capsule_auth1( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 1 - Update U-Boot on SPI Flash, raw image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 1 - Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) - If the capsule is properly signed, the authentication - should pass and the firmware be updated. + If the capsule is properly signed, the authentication + should pass and the firmware be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 1-a, before reboot'): @@ -100,13 +100,12 @@ class TestEfiCapsuleFirmwareSignedRaw(object): def test_efi_capsule_auth2( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 2 - Update U-Boot on SPI Flash, raw image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 2 - Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) - If the capsule is signed but with an invalid key, - the authentication should fail and the firmware - not be updated. + If the capsule is signed but with an invalid key, + the authentication should fail and the firmware + not be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 2-a, before reboot'): @@ -179,12 +178,11 @@ class TestEfiCapsuleFirmwareSignedRaw(object): def test_efi_capsule_auth3( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 3 - Update U-Boot on SPI Flash, raw image format - 0x100000-0x150000: U-Boot binary (but dummy) + """Test Case 3 - Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) - If the capsule is not signed, the authentication - should fail and the firmware not be updated. + If the capsule is not signed, the authentication + should fail and the firmware not be updated. """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 3-a, before reboot'):