From patchwork Mon Sep 14 10:50:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1363512 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=aAcSvAp2; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bqjq75JJ3z9sTm for ; Mon, 14 Sep 2020 20:52:03 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E85BD822D2; Mon, 14 Sep 2020 12:51:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="aAcSvAp2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A98E81C31; Mon, 14 Sep 2020 12:51:41 +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,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 C6FB181BD2 for ; Mon, 14 Sep 2020 12:51:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600080695; bh=u2S3rj4slA47vsYNAyL9l/xngXSd7fFxbpc+gpoTrcQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=aAcSvAp2kGUJ+5VL99Yg43Thu7nW8mnYSNcYBfpOCeoVTiqv28CG1iSBsuPUYR2/1 l1VOq5rpfO1dOhRvkmDsoVvBJxBeinxo67XGHF0+123nRopBGWdTQySq8rPZyjr/7Z FXSkHlmLYKecJLw5mrGVMtR5XItQRnJOWbHMgdWA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1M9FjR-1kBT5E0nkl-006S6R; Mon, 14 Sep 2020 12:51:35 +0200 From: Heinrich Schuchardt To: Tom Rini Cc: Philippe Reynes , Simon Glass , Patrick Delaunay , Walter Lozano , Wolfgang Wallner , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 1/3] test: sharpen button label unit test Date: Mon, 14 Sep 2020 12:50:54 +0200 Message-Id: <20200914105056.174287-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914105056.174287-1-xypron.glpk@gmx.de> References: <20200914105056.174287-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:tDbl6OJM1eDbJhFRX5QxHYvv/aF3vlfzEV/0GtDXZdP4Ad6KcuX HfwwV/OxZw2KbxOlB6gSnIXMA0rUzYZEY02ma74dK3IFsn8EabT0EE6go13tdx8WCXTfNv1 JZpICEmD1KE6P7AW5wWrzhuTk4Xlmh8hSgs13GbgFdQnGix8RELY+xtoTtsCiQ5N8Jcd0AU EvOaI/yYY+B+TBDnYEQIg== X-UI-Out-Filterresults: notjunk:1;V03:K0:hJFgiFNmIec=:+z4kbtdHgP6c+LRGddRwlT Ww50rbchqDeOqR3p/nCgOIgxoySbwbfESTjh678KErghS4qS3gsbuu9w9BPkxJ3cQQ9m6lh+/ 8GkbShuGagsv6KXFP+CyBEI71VB93g0NU63s05+3Zf3tlLb6gYJmVTALVOt1jAUlzUGXPai24 MrCuyLD2jRQvEnIyTe4Ylb7hCL2rvkP2o77JR1f0dLmAXY5Qe57iohDVXNcRzmbEvRkE22dXg sA6NPwL1OYYi7CC2eow/KZeNOgzQafcD30SmxFee6ePPQPnM2EftxYewnCMmSO3gX92Z7E43K D2/um2jyy440/1ty4+547tMGidR+C0pngimHSqCLbI+RyklcvlZF03TFFPSEcI5qTdkfuvGAV KsFL0OjdgJKBJ5g12CFIy3Hv7Spu3S6Wh34nhnvqtxaghSfP2N4i3FGrimy9t6uttouEqYfzB s/IiBe42uQsDKTx6tG6MlyPpyFJYI+EgVN73wPbJ8HWF1D2Yr89RvvGlSRf7ssQ7fHNRc6Pif 3vdYvXxAU9K4t6QMAYdG6KpjMv+Ql8aloZJCsspTm7FSCH4TTGBOHtYOZZ8LBB0fadhACm6aH hpOmMfhhwzRilnmSWPKyvuhhHphUbPqgyKek3P/lM9m0sf0En1pJvk0k4Vq7yVboUDn5QXrBI bSJj/g7rAhJ3+ODy5h8od/ocydf5XabYFeobB1LIXXEk57KDN4znSEEJ0478UCMCkjDzsM6xR PDSRYSlh2d6fhEvnTJhaqPe4ri94rfixD2EExHdwF6FX3QipPa+9s1zXmV92yYIkNYb0r7PBW XLgOVqwMwVFesc94sZP0vfpw/MCL/8TxJ5W1juYa/F4TMESP+iw9bc3H8IT4tF7es6qP8+sQ9 eVq9XwlaI+qUWvLLltAj2IPsq/ycg7yLk4DN5s9zQaSSWU/DWyVfN0fJwIFcgLbbpNYIYxdn6 BGttDaV5m9kvQ7iqZLkU2UPFayiiheEb2MiEObQyXgjRG4NavWUp0LOKbsAT+z7qHgrzOaB6x vzDlcLdKbRvAm9PwqsRstAoNao9xIf73vq1iSV8fPOOYgwLlOrLvlSpnBP2dLaofk+G04iFoJ N/+Bpgv2oeVhjNdLzeyDZusswzGycRxzSRrhbIafX6iiZ+Pb1l63h/1ADA1ht/iEyYFfOijxe sLxlR+GIAXTfUsoeWZJjwWc4a7lBsVaRcotAzGK+2p55RyPg8Yj4N2NaDSOUOMErdnW8PIqHN GyKFPTi6EUr6YzmRTVINZCZRP61Jb5gaoHv+APg== 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.3 at phobos.denx.de X-Virus-Status: Clean Using different strings for the device tree node labels and the label property of buttons sharpens the button label unit test. Signed-off-by: Heinrich Schuchardt Reviewed-by: Philippe Reynes --- v2: new patch --- arch/sandbox/dts/sandbox.dtsi | 8 ++++---- arch/sandbox/dts/test.dts | 8 ++++---- test/dm/button.c | 6 +++--- test/py/tests/test_button.py | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) -- 2.28.0 diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index c76ecc013c..0faad3f319 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -18,14 +18,14 @@ buttons { compatible = "gpio-keys"; - summer { + btn1 { gpios = <&gpio_a 3 0>; - label = "summer"; + label = "button1"; }; - christmas { + btn2 { gpios = <&gpio_a 4 0>; - label = "christmas"; + label = "button2"; }; }; diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 9f45c48e4e..395d5f5e56 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -54,14 +54,14 @@ buttons { compatible = "gpio-keys"; - summer { + btn1 { gpios = <&gpio_a 3 0>; - label = "summer"; + label = "button1"; }; - christmas { + btn2 { gpios = <&gpio_a 4 0>; - label = "christmas"; + label = "button2"; }; }; diff --git a/test/dm/button.c b/test/dm/button.c index 9117801736..ecaa47cf5f 100644 --- a/test/dm/button.c +++ b/test/dm/button.c @@ -57,17 +57,17 @@ static int dm_test_button_label(struct unit_test_state *uts) { struct udevice *dev, *cmp; - ut_assertok(button_get_by_label("summer", &dev)); + ut_assertok(button_get_by_label("button1", &dev)); ut_asserteq(1, device_active(dev)); ut_assertok(uclass_get_device(UCLASS_BUTTON, 1, &cmp)); ut_asserteq_ptr(dev, cmp); - ut_assertok(button_get_by_label("christmas", &dev)); + ut_assertok(button_get_by_label("button2", &dev)); ut_asserteq(1, device_active(dev)); ut_assertok(uclass_get_device(UCLASS_BUTTON, 2, &cmp)); ut_asserteq_ptr(dev, cmp); - ut_asserteq(-ENODEV, button_get_by_label("spring", &dev)); + ut_asserteq(-ENODEV, button_get_by_label("nobutton", &dev)); return 0; } diff --git a/test/py/tests/test_button.py b/test/py/tests/test_button.py index 98067a98f2..eadd9dd613 100644 --- a/test/py/tests/test_button.py +++ b/test/py/tests/test_button.py @@ -11,7 +11,7 @@ def test_button_exit_statuses(u_boot_console): expected_response = 'rc:0' response = u_boot_console.run_command('button list; echo rc:$?') assert(expected_response in response) - response = u_boot_console.run_command('button summer; echo rc:$?') + response = u_boot_console.run_command('button button1; echo rc:$?') assert(expected_response in response) expected_response = 'rc:1' From patchwork Mon Sep 14 10:50:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1363513 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=ibTDaxbH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4BqjqH0gdBz9sTS for ; Mon, 14 Sep 2020 20:52:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D0A59822FD; Mon, 14 Sep 2020 12:51:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="ibTDaxbH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6028381BEB; Mon, 14 Sep 2020 12:51:43 +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,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (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 528F981BEB for ; Mon, 14 Sep 2020 12:51:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600080695; bh=ZCwCjlcl5hJucOnmSViPr3crKkP+4YvqyVaTuNF6Mh8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ibTDaxbHkLZhmiQoDO062bNQ3U3kIZWIntIR57Wn9LiyngFz+p0qDUzgcokx25gpj kc3b8HIuGV2BA+KLP6oTvllmSMOGPKqg2Y6+IKpHxZFejl/4JoZnMY3djR5itUnkQG bu43y/ysdrdDl/++8LYIvembHn02rJ9H5msJvJhw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MJE2D-1jx4RA2pVD-00KfZL; Mon, 14 Sep 2020 12:51:35 +0200 From: Heinrich Schuchardt To: Tom Rini Cc: Philippe Reynes , Simon Glass , Patrick Delaunay , Walter Lozano , Wolfgang Wallner , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 2/3] drivers: gpio: keep output value for input on sandbox Date: Mon, 14 Sep 2020 12:50:55 +0200 Message-Id: <20200914105056.174287-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914105056.174287-1-xypron.glpk@gmx.de> References: <20200914105056.174287-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:WhOYg9VksOknSrE8/v1K6j+1MDKmGvgb7oBf9fZew9KiDD+o6VG Fa2oyvw9AHVW2OETquAOCLjH6j8pgpDyMeo8XuHuLMWJ7muav0uWrttXCwqm1KG8C2D4auc La4QZ/WVMrtlu/2MUU7IUyAU9esF8PJ7rHGzXbWEr1wWG92olOcOYB39DXXraQB/WSXwcKO JyNw+0J4YlmgJwA02pjiA== X-UI-Out-Filterresults: notjunk:1;V03:K0:v2ghCB7p3PQ=:Qymn3ro1YVUlYWo35A7m2B OgBSGuhdKgACPnQrHK0SCz5L46/MJ5BS++y40SNyEgVV4r4v334ZDFOg3zQG/FTnbDf/BDdGZ AQsj7Jk62616lui62RsP4IqQzKq2ZXOePZoIaEpEPiIuMunGvj8Oj0Hl9jP1PpevPRLnEbuhP EE4IUbOntO9O+L156Cm7zg7thpL5ZOHyOLfV8xY/6tcPXF/MOB/X7zI6Ry2++6HL7r6AyOk+U 5QUO35znqNDLPjdgMMC+IKWdxS2ZFkumQiNzFdLAeY3K2tn2PcYiwam4k7zg5XaOb56+8qAtH XRLih+A7+zEgjaS7vQ5PLuHa7WQ7jrIKKLVGUrX/0dERDLu0Sl7mDHoLVCOWAecsYX+WAgxgJ FjSP56ja3lDlz0uNu6seiqpUf/n8VyfTdbpaXVv/PFcO35QNqqUgbaLZMbDFbIxCgNA3+7DkT YQ03QelCTzOljKTikNHjK2ii/Zux+WHehGBydScQppa39W7NAgh5THkKZqgpn8nYufll18ZpJ xJyDMjbyS7jSFTj4QYFi2G4zGdeOT2P/qoShwdaegYxKRMRr6wd/hHZK4Y90tV6bDV3uTDn4m aC50LQ2EU+ygnImbfcqCcM1VSWZjwWjPYs0zshZIbaElPlFIqOwybYi2B8pvIeOFfvkBSH63j bofDW1xhF9vDSN43tHbh0xtzcEU6urnEw5Gzg+eV7uYBG2/+wdn2uNZ+H3zoS8ZkRzAzTd1Qh yWqyZHHoRnUeMPG8s/2jPUbDE7VWzvqSMFlz7lZ81UrNQF3CYamkUfwsHWhWINbNhQ9Lv5dm/ Hy5U0ITBuZiEZX8wSWYS1ek2mdxyhL4Ed1tjOI3QVFOzwMZ08i/ge3rED39g510WIfdTJKuso w8RHvGYDYsQv5/JCHONqAB9qPA3j+oTvnX7AwgH0tshInoqWsmj147O1PpqjcddPZqdmlzfKn yD+cjYYFSjR3rVImyCzhp5P37lJmk9E0O4aYUel4gF2Q8pxMSR5Kw2/i8qjVKGQ5QsBqgyYKp yErapNf+uzVmtixcsx13d6qqgO5hcr7Wzpcx/tfLgsjH8DH/61wkfPf+en/tPR8FuhEF9oBEo UN6yBTYc6UKmM/0efZmo/tpCtCfdzR/W39+mURSygHUDkTYZRBRTnZs0MCzBPrVaPGdqIHOA7 h2a4dB8kE54TCfjyZHAUn5dMJuvH/L/5ndJopuAfCVjSF8DsXjJf1POPGzzou/VXCY58L9i1f 598Ye0dIgU6MhjsKy3hHgLWhS7HBluJNPOzZi9A== 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.3 at phobos.denx.de X-Virus-Status: Clean For testing purposes keep the output value when switching to input. This allows us to manipulate the input value via the gpio command. Signed-off-by: Heinrich Schuchardt Reviewed-by: Philippe Reynes --- v2: new patch --- drivers/gpio/sandbox.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.28.0 diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c index c2f80472b8..eb2600de31 100644 --- a/drivers/gpio/sandbox.c +++ b/drivers/gpio/sandbox.c @@ -185,7 +185,15 @@ static int sb_gpio_set_dir_flags(struct udevice *dev, unsigned int offset, dir_flags = get_gpio_dir_flags(dev, offset); - *dir_flags = flags; + /* + * For testing purposes keep the output value when switching to input. + * This allows us to manipulate the input value via the gpio command. + */ + if (flags & GPIOD_IS_IN) + *dir_flags = (flags & ~GPIOD_IS_OUT_ACTIVE) | + (*dir_flags & GPIOD_IS_OUT_ACTIVE); + else + *dir_flags = flags; return 0; } From patchwork Mon Sep 14 10:50:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1363514 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=ZfoHh6/c; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4BqjqT0X12z9sTS for ; Mon, 14 Sep 2020 20:52:21 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E6D078231E; Mon, 14 Sep 2020 12:51:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="ZfoHh6/c"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7BA0C822FD; Mon, 14 Sep 2020 12:51:44 +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,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (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 04E3481BDF for ; Mon, 14 Sep 2020 12:51:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1600080696; bh=mCvfDsCgvu/g2E2kkgJFQoMoqCeTpP8sVT//pLriVFA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ZfoHh6/cA1iZvGOXm+nFeTXpULGng0l+O8OcyyaGfmPz++RF9OlQafiUgzb5kiIw+ b/lkjTiUMND8vubB3n0FL0RMGM/BKB2G1GXfhMOS8Q2Xk3Ujnh0c4k45DusFZlsXXx mpLdoAuuEWhi5nojbgTPhtGjJIznqrdgwEouGj2M= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([178.202.41.107]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MoO6M-1ktLwO0dbc-00opPM; Mon, 14 Sep 2020 12:51:36 +0200 From: Heinrich Schuchardt To: Tom Rini Cc: Philippe Reynes , Simon Glass , Patrick Delaunay , Walter Lozano , Wolfgang Wallner , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH v2 3/3] cmd/button: return button status Date: Mon, 14 Sep 2020 12:50:56 +0200 Message-Id: <20200914105056.174287-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200914105056.174287-1-xypron.glpk@gmx.de> References: <20200914105056.174287-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UJfxXO98b0fHvrvB7sci6jlZwhH04+WpULEdM7kR2PGwSowSmXb XgyvHAjMlqsEt8sF1ln8fuWHrMp4GOSMi01p9YPMo9cVltSXOto1BHkBCkUIImInYb/l/ki j6IemRf9JcJmou6nmNZwgPzeVGOXRhqmQuymIRErJHd/LFin4MlXK8sx2WtHNLz2OsGDBVT SEHPLymz8/uohE383/ilQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:TflkN6N6s60=:B9116GQttzi/rOu6XouGLc NVv1TbBu9yZ5AXXVWil4O882sgkKjfHHOQli3r+K38MG/00x0P2oJ1OKTZY1VDfK3YXIcWOy0 kiK87HiI7XSB2yeKF/NdLWsLYQev4KWm+uzsd0I0hAlVKCCVwiE2PSdxs/Cz/kKDXewYI31MH 3C/Nl7C5aPueS1B1Ws+NRX9wvdo3g690m1DMMCOnCq/FI1g+I2nUyuPOHlvKVTAC7B+KM/qgT EfUlA5dMnu/iUxlK+kw79QkaXz9ojmtzJOsfaWqM+rQkpCh6xpcmZdAPhEV07/g54EasXNPhJ 6NmhznrRVcWdXImTai1D8t99OTXF9piqOGXVOxlGEKXXKQN39J0cAoT1MCjTXwLZOI2Vz1Iu8 5jbISIdVT60f/DO5P8NAg/N4agscWfhPl+vpYniA5FnLHOXyfos8cM9hluSoB8r60fFQFMY9H pMGOIK2Ib6Ho9B/aFjupbHyD9XFiOozJW5g4tKxVKgWg+TDumMCK4kAvixGU6k732STicjcVn TYdZRAq/EKGOrFRhrwHJ9PJK6PSHtduL+5dKD0Vem+ST7AZRjzFdB37uW+aN1K40b7cGNF+ad sbhr3vFVuWgXZdFZiFUbKnRvk3QOJm9ovbZuj55L/00rbu5tQd/91KY95NaqohWcbtKfcIcq9 6SxEhHBsKgWgRENvZhtguCbe/CQw91NTa1y20rEkkhRsNOC70ntWzb79RtxWvORaf9DPGBAMT LlDuBYv+83TLkWSNwVSdEPfk+5B2VKJsJ17sZpKakkwcILT9kGjp4Joxtb5vQ3Vxiaoue+Uyx spTCZBchww0GP6Oag7Jat3SJVqx1qrJYsM8MrNUqMELotdt4U7sD0xTZpCcM38EI2dfcfYsK+ 0p8KTZzuQH+WGQ1dDpKwJSWfxhm2ca4DJkwzTeyoWN7U5dECJfckI9jsNY77NF2OYCjUvzoRW vOMIaA743h1BmKNvZoZVgkacn9QVWqC3wuxUf/s+GZ+DCV3wzLMiuSptqH5Opci7W8nhOTDZ8 G1wOuW+xQ3amubuwElsGQrVsGpb3zLGsyBhiXsNhNxgYqZiOFnmMStnxEgA6XVThG9QojANH5 Xuk77eXHbNQIbCRITrMcBXY4HeiztgwYLhOICX+JvfRnEqfK91jBAS86dS8djwMjK5r+1fxvX tJ1ILM7CdgjZz+loZ6Qj6Amoe6/Lmgrxj32ZHG+R/WbjmaTMMp//pJLGmvNqNCqaTMp4lr213 XTwSwDEM1+lwfqlreJvVDrIowwccSAETn5TVhpg== 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.3 at phobos.denx.de X-Virus-Status: Clean To make the button command useful in a shell script it should return the status of the button: * 0 (true) - pressed, on * 1 (false) - not pressed, off The button command takes only one argument. Correct maxargs. Adjust the Python unit test. Signed-off-by: Heinrich Schuchardt Reviewed-by: Philippe Reynes --- v2: adjust Python unit test --- cmd/button.c | 4 ++-- test/py/tests/test_button.py | 34 ++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 10 deletions(-) -- 2.28.0 diff --git a/cmd/button.c b/cmd/button.c index 84ad1653c7..64c5a8fa04 100644 --- a/cmd/button.c +++ b/cmd/button.c @@ -75,11 +75,11 @@ int do_button(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) ret = show_button_state(dev); - return 0; + return !ret; } U_BOOT_CMD( - button, 4, 1, do_button, + button, 2, 1, do_button, "manage buttons", " \tGet button state\n" "button list\t\tShow a list of buttons" diff --git a/test/py/tests/test_button.py b/test/py/tests/test_button.py index eadd9dd613..3b7f148c8f 100644 --- a/test/py/tests/test_button.py +++ b/test/py/tests/test_button.py @@ -4,16 +4,34 @@ import pytest @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_button') -def test_button_exit_statuses(u_boot_console): - """Test that non-input button commands correctly return the command - success/failure status.""" +def test_button_list(u_boot_console): + """Test listing buttons""" - expected_response = 'rc:0' response = u_boot_console.run_command('button list; echo rc:$?') - assert(expected_response in response) + assert('button1' in response) + assert('button2' in response) + assert('rc:0' in response) + +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_button') +@pytest.mark.buildconfigspec('cmd_gpio') +def test_button_return_code(u_boot_console): + """Test correct reporting of the button status + + The sandbox gpio driver reports the last output value as input value. + We can use this in our test to emulate different input statuses. + """ + + u_boot_console.run_command('gpio set a3; gpio input a3'); + response = u_boot_console.run_command('button button1; echo rc:$?') + assert('on' in response) + assert('rc:0' in response) + + u_boot_console.run_command('gpio clear a3; gpio input a3'); response = u_boot_console.run_command('button button1; echo rc:$?') - assert(expected_response in response) + assert('off' in response) + assert('rc:1' in response) - expected_response = 'rc:1' response = u_boot_console.run_command('button nonexistent-button; echo rc:$?') - assert(expected_response in response) + assert('not found' in response) + assert('rc:1' in response)