From patchwork Tue Apr 20 08:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 1468235 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FPcGg0GhFz9tlf for ; Tue, 20 Apr 2021 18:26:34 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4221382B05; Tue, 20 Apr 2021 10:26:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 59CF882B01; Tue, 20 Apr 2021 10:25:56 +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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C23D82AF2 for ; Tue, 20 Apr 2021 10:25:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kory.maincent@bootlin.com Received: from localhost.localdomain (pop.92-184-110-32.mobile.abo.orange.fr [92.184.110.32]) (Authenticated sender: kory.maincent@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id C864824000C; Tue, 20 Apr 2021 08:25:47 +0000 (UTC) From: Kory Maincent To: u-boot@lists.denx.de Cc: thomas.petazzoni@bootlin.com, jkridner@beagleboard.org, drew@beagleboard.org, robertcnelson@gmail.com, maxime@cerno.tech, trini@konsulko.com, andre.przywara@arm.com Subject: [PATCH v4 03/10] pytest: add sandbox test for "extension" command Date: Tue, 20 Apr 2021 10:25:34 +0200 Message-Id: <20210420082541.28757-4-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210420082541.28757-1-kory.maincent@bootlin.com> References: <20210420082541.28757-1-kory.maincent@bootlin.com> 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.102.4 at phobos.denx.de X-Virus-Status: Clean This commit extends the sandbox to implement a dummy extension_board_scan() function and enables the extension command in the sandbox configuration. It then adds a test that checks the proper functionality of the extension command by applying two Device Tree overlays to the sandbox Device Tree. Signed-off-by: Kory Maincent --- arch/Kconfig | 2 ++ arch/sandbox/dts/Makefile | 1 + arch/sandbox/dts/overlay0.dts | 9 ++++++ arch/sandbox/dts/overlay1.dts | 9 ++++++ board/sandbox/sandbox.c | 23 +++++++++++++++ test/py/tests/test_extension.py | 52 +++++++++++++++++++++++++++++++++ 6 files changed, 96 insertions(+) create mode 100644 arch/sandbox/dts/overlay0.dts create mode 100644 arch/sandbox/dts/overlay1.dts create mode 100644 test/py/tests/test_extension.py diff --git a/arch/Kconfig b/arch/Kconfig index 3aa99e08fc..fbe969cce0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -109,6 +109,7 @@ config SANDBOX select SPI select SUPPORT_OF_CONTROL select SYSRESET_CMD_POWEROFF + select SUPPORT_EXTENSION_SCAN imply BITREVERSE select BLOBLIST imply CMD_DM @@ -146,6 +147,7 @@ config SANDBOX imply ACPI_PMC_SANDBOX imply CMD_PMC imply CMD_CLONE + imply CMD_EXTENSION config SH bool "SuperH architecture" diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile index d231dc2877..3e5dc67d53 100644 --- a/arch/sandbox/dts/Makefile +++ b/arch/sandbox/dts/Makefile @@ -6,6 +6,7 @@ else dtb-$(CONFIG_SANDBOX) += sandbox.dtb endif dtb-$(CONFIG_UT_DM) += test.dtb +dtb-$(CONFIG_CMD_EXTENSION) += overlay0.dtbo overlay1.dtbo targets += $(dtb-y) diff --git a/arch/sandbox/dts/overlay0.dts b/arch/sandbox/dts/overlay0.dts new file mode 100644 index 0000000000..70c6cf77aa --- /dev/null +++ b/arch/sandbox/dts/overlay0.dts @@ -0,0 +1,9 @@ +/dts-v1/; +/plugin/; + +&{/buttons} { + btn3 { + gpios = <&gpio_a 5 0>; + label = "button3"; + }; +}; diff --git a/arch/sandbox/dts/overlay1.dts b/arch/sandbox/dts/overlay1.dts new file mode 100644 index 0000000000..51621b3110 --- /dev/null +++ b/arch/sandbox/dts/overlay1.dts @@ -0,0 +1,9 @@ +/dts-v1/; +/plugin/; + +&{/buttons} { + btn4 { + gpios = <&gpio_a 5 0>; + label = "button4"; + }; +}; diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c index 18a605de02..6ba1a7177d 100644 --- a/board/sandbox/sandbox.c +++ b/board/sandbox/sandbox.c @@ -13,6 +13,9 @@ #include #include #include +#include + +#include /* * Pointer to initial global data area @@ -81,6 +84,26 @@ int ft_board_setup(void *fdt, struct bd_info *bd) return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000); } +#ifdef CONFIG_CMD_EXTENSION +int extension_board_scan(struct list_head *extension_list) +{ + struct extension *extension; + int i; + + for (i = 0; i < 2; i++) { + extension = calloc(1, sizeof(struct extension)); + snprintf(extension->overlay, sizeof(extension->overlay), "overlay%d.dtbo", i); + snprintf(extension->name, sizeof(extension->name), "extension board %d", i); + snprintf(extension->owner, sizeof(extension->owner), "sandbox"); + snprintf(extension->version, sizeof(extension->version), "1.1"); + snprintf(extension->other, sizeof(extension->other), "Fictionnal extension board"); + list_add_tail(&extension->list, extension_list); + } + + return i; +} +#endif + #ifdef CONFIG_BOARD_LATE_INIT int board_late_init(void) { diff --git a/test/py/tests/test_extension.py b/test/py/tests/test_extension.py new file mode 100644 index 0000000000..4712f9bfe3 --- /dev/null +++ b/test/py/tests/test_extension.py @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2020 +# Author: Kory Maincent + +# Test U-Boot's "extension" commands. + +import os +import pytest +import u_boot_utils + +overlay_addr = 0x1000 + +SANDBOX_DTB='arch/sandbox/dts/sandbox.dtb' +OVERLAY_DIR='arch/sandbox/dts/' + +def load_dtb(u_boot_console): + u_boot_console.log.action('Loading devicetree to RAM...') + u_boot_console.run_command('host load hostfs - $fdt_addr_r %s' % (os.path.join(u_boot_console.config.build_dir, SANDBOX_DTB))) + u_boot_console.run_command('fdt addr $fdt_addr_r') + +@pytest.mark.buildconfigspec('cmd_fdt') +def test_extension(u_boot_console): + """Test the 'extension' command.""" + + load_dtb(u_boot_console) + + output = u_boot_console.run_command('extension list') + assert('No extension' in output) + + output = u_boot_console.run_command('extension scan') + assert output == 'Found 2 extension board(s).' + + output = u_boot_console.run_command('extension list') + assert('overlay0.dtbo' in output) + assert('overlay1.dtbo' in output) + + u_boot_console.run_command_list([ + 'setenv extension_overlay_addr %s' % (overlay_addr), + 'setenv extension_overlay_cmd \'host load hostfs - ${extension_overlay_addr} %s${extension_overlay_name}\'' % (os.path.join(u_boot_console.config.build_dir, OVERLAY_DIR))]) + + output = u_boot_console.run_command('extension apply 0') + assert('bytes read' in output) + + output = u_boot_console.run_command('fdt print') + assert('button3' in output) + + output = u_boot_console.run_command('extension apply all') + assert('bytes read' in output) + + output = u_boot_console.run_command('fdt print') + assert('button4' in output) +