From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A397C47082 for ; Mon, 31 May 2021 10:54:07 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC6896124C for ; Mon, 31 May 2021 10:54:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC6896124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC1C582CFE; Mon, 31 May 2021 12:54:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="UAe5e4uN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3464582D71; Mon, 31 May 2021 12:54:01 +0200 (CEST) Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) (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 C5BB481D0B for ; Mon, 31 May 2021 12:53:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=opensource.kab@gmail.com Received: by mail-pg1-x532.google.com with SMTP id l1so841503pgm.1 for ; Mon, 31 May 2021 03:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+DDvjuVFLxLwn50iyZg6vrebqDkDdqM6BeiB7gU0BoY=; b=UAe5e4uNxRRk/29NGNd0MYa5uXkx/5JBrllUKpps8KXw86o7HHm1Oa11qh+VDrW7tm YOLTH0EynkedpLYY94W6RAHJ62jRao9kCPwjq3ktM1M0I8oCui1kDzKKCJdjYID5duRL TCJKHIX9srpA15CKs1mh6WF2ZYnHTbqSkTfdLtFcBnENt/kOmIlBHARLCYoUN/S5m4bP OT6mgS60SdF+pIX6PoofqRtNmnlny52ef1Kad+gXlrzThaWtb9o/FN1JnU7UrSSDZMPm /JorrJCEnT6NZODJQ7lbaw1Aj7xwYD+lH/6DDaYm3MAfMuQxDpI59A785mIQrhHxZ4c4 US1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+DDvjuVFLxLwn50iyZg6vrebqDkDdqM6BeiB7gU0BoY=; b=jcuzRcRBkzKLOdwXKXAacPdEE84ybNUJrU9F/gFxjkFu/LjMx0n3ksWRiPfKxXtTXj 9Q7YbWKQul6LsU/YJxs/l0GtEfwx3ku5uQOgOB5MfDTcTvkpGNli2Pi7Qj4iTxQkWKPq vHc8GkYaSl0GEJaf/L8I6eDYdejUNHy6XrGz6WVTntEil3GAR0XD0/90BPJBP+7eVdyq 6n3u/0Vx4f3ZLuy3FtiuXV0YA/VLU1s/kS2tgbP6XZa9B9SmmEHWAwfGE4r5c4vuE/Ee KZkIKKjgbL8E4b2MKij34N4KSaMAlL6cl5cPNVWCdF8HcjGUMlqbSM7dNacQUAmnSnPi bATQ== X-Gm-Message-State: AOAM530VL6uGeKYnW19EpY5EvcyRlxSkP5w1BywXGmf9JULBq+Zm2Jfi imv0GBOqIhQWvHXFJIg8RelXOtfTyCCH5FXS X-Google-Smtp-Source: ABdhPJx4QFGqZA6L/qHNHMvXYFY4dkZQFRnhNBiqM+neTv714QmtExK1f7WHujbE3HDooPKLFjlZSA== X-Received: by 2002:a63:b30a:: with SMTP id i10mr22176741pgf.306.1622458435919; Mon, 31 May 2021 03:53:55 -0700 (PDT) Received: from localhost.localdomain ([49.204.180.30]) by smtp.gmail.com with ESMTPSA id 14sm5100070pfj.25.2021.05.31.03.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 03:53:55 -0700 (PDT) From: opensource.kab@gmail.com To: u-boot@lists.denx.de Cc: alex.kiernan@gmail.com, Adarsh Babu Kalepalli Subject: [PATCH] =?UTF-8?q?test/py:Update=20python=20tests=20for=20?= =?UTF-8?q?=E2=80=98gpio=E2=80=99=20cmd?= Date: Mon, 31 May 2021 16:23:51 +0530 Message-Id: <20210531105351.15502-1-opensource.kab@gmail.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Adarsh Babu Kalepalli Generic Python Test cases are developed to verfiy 'gpio' command. Signed-off-by: Adarsh Babu Kalepalli --- test/py/tests/test_gpio.py | 175 ++++++++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 1 deletion(-) diff --git a/test/py/tests/test_gpio.py b/test/py/tests/test_gpio.py index 8c64f686b0..109649e2c7 100644 --- a/test/py/tests/test_gpio.py +++ b/test/py/tests/test_gpio.py @@ -1,6 +1,16 @@ -# SPDX-License-Identifier: GPL-2.0+ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2021 Adarsh Babu Kalepalli +# Copyright (c) 2020 Alex Kiernan import pytest +import time +import u_boot_utils + +""" + test_gpio_input is intended to test the fix 4dbc107f4683. + 4dbc107f4683:"cmd: gpio: Correct do_gpio() return value" +""" @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_gpio') @@ -35,3 +45,166 @@ def test_gpio_exit_statuses(u_boot_console): assert(expected_response in response) response = u_boot_console.run_command('gpio input 200; echo rc:$?') assert(expected_response in response) + + +""" +Generic Tests for 'gpio' command on sandbox and real hardware. +The below sequence of tests rely on env__gpio_dev_config for configuration values of gpio pins. + + Configuration data for gpio command. + The set,clear,toggle ,input and status options of 'gpio' command are verified. + For sake of verification,A LED/buzzer could be connected to GPIO pins configured as O/P. + Logic level '1'/'0' can be applied onto GPIO pins configured as I/P + + +env__gpio_dev_config = { + #the number of 'gpio_str_x' strings should equal to + #'gpio_str_count' value + 'gpio_str_count':4 , + 'gpio_str_1': '0', + 'gpio_str_2': '31', + 'gpio_str_3': '63', + 'gpio_str_4': '127', + 'gpio_op_pin': '64', + 'gpio_ip_pin_set':'65', + 'gpio_ip_pin_clear':'66', + 'gpio_clear_value': 'value is 0', + 'gpio_set_value': 'value is 1', +} +""" + + +@pytest.mark.buildconfigspec('cmd_gpio') +def test_gpio_status_all_generic(u_boot_console): + """Test the 'gpio status' command. + + Displays all gpio pins available on the Board. + To verify if the status of pins is displayed or not, + the user can configure (gpio_str_count) and verify existence of certain + pins.The details of these can be configured in 'gpio_str_n'. + of boardenv_* (example above).User can configure any + number of such pins and mention that count in 'gpio_str_count'. + """ + + f = u_boot_console.config.env.get('env__gpio_dev_config',False) + if not f: + pytest.skip("gpio not configured") + + gpio_str_count = f['gpio_str_count'] + + #Display all the GPIO ports + cmd = 'gpio status -a' + response = u_boot_console.run_command(cmd) + + for str_value in range(1,gpio_str_count + 1): + assert f["gpio_str_%d" %(str_value)] in response + + +@pytest.mark.buildconfigspec('cmd_gpio') +def test_gpio_set_generic(u_boot_console): + """Test the 'gpio set' command. + + A specific gpio pin configured by user as output + (mentioned in gpio_op_pin) is verified for + 'set' option + + """ + + f = u_boot_console.config.env.get('env__gpio_dev_config',False) + if not f: + pytest.skip("gpio not configured") + + gpio_pin_adr = f['gpio_op_pin']; + gpio_set_value = f['gpio_set_value']; + + + cmd = 'gpio set ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_set_value + assert good_response in response + + + +@pytest.mark.buildconfigspec('cmd_gpio') +def test_gpio_clear_generic(u_boot_console): + """Test the 'gpio clear' command. + + A specific gpio pin configured by user as output + (mentioned in gpio_op_pin) is verified for + 'clear' option + """ + + f = u_boot_console.config.env.get('env__gpio_dev_config',False) + if not f: + pytest.skip("gpio not configured") + + gpio_pin_adr = f['gpio_op_pin']; + gpio_clear_value = f['gpio_clear_value']; + + + cmd = 'gpio clear ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_clear_value + assert good_response in response + + +@pytest.mark.buildconfigspec('cmd_gpio') +def test_gpio_toggle_generic(u_boot_console): + """Test the 'gpio toggle' command. + + A specific gpio pin configured by user as output + (mentioned in gpio_op_pin) is verified for + 'toggle' option + """ + + + f = u_boot_console.config.env.get('env__gpio_dev_config',False) + if not f: + pytest.skip("gpio not configured") + + gpio_pin_adr = f['gpio_op_pin']; + gpio_set_value = f['gpio_set_value']; + gpio_clear_value = f['gpio_clear_value']; + + cmd = 'gpio set ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_set_value + assert good_response in response + + cmd = 'gpio toggle ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_clear_value + assert good_response in response + + +@pytest.mark.buildconfigspec('cmd_gpio') +def test_gpio_input_generic(u_boot_console): + """Test the 'gpio input' command. + + Specific gpio pins configured by user as input + (mentioned in gpio_ip_pin_set and gpio_ip_pin_clear) + is verified for logic '1' and logic '0' states + """ + + f = u_boot_console.config.env.get('env__gpio_dev_config',False) + if not f: + pytest.skip("gpio not configured") + + gpio_pin_adr = f['gpio_ip_pin_clear']; + gpio_clear_value = f['gpio_clear_value']; + + + cmd = 'gpio input ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_clear_value + assert good_response in response + + + gpio_pin_adr = f['gpio_ip_pin_set']; + gpio_set_value = f['gpio_set_value']; + + + cmd = 'gpio input ' + gpio_pin_adr + response = u_boot_console.run_command(cmd) + good_response = gpio_set_value + assert good_response in response -- 2.17.1