diff mbox series

[U-Boot,v4,11/11] test/py: test pinmux command

Message ID 1540383023-1807-12-git-send-email-patrice.chotard@st.com
State Accepted
Delegated to: Tom Rini
Headers show
Series Add pinmux command | expand

Commit Message

Patrice CHOTARD Oct. 24, 2018, 12:10 p.m. UTC
Add pinmux test which test the following commands:
  - pinmux list
  - pinmux dev
  - pinmux status

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

Changes in v4:
 - Update sandbox_get_pin_muxing() due to get_pin_muxing()
   prototype changes

Changes in v3:
 - Fix typo

Changes in v2: None

 arch/sandbox/dts/test.dts    |  4 +++
 test/py/tests/test_pinmux.py | 62 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 test/py/tests/test_pinmux.py

Comments

Simon Glass Nov. 3, 2018, 6:07 a.m. UTC | #1
On 24 October 2018 at 06:10, Patrice Chotard <patrice.chotard@st.com> wrote:
> Add pinmux test which test the following commands:
>   - pinmux list
>   - pinmux dev
>   - pinmux status
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> ---
>
> Changes in v4:
>  - Update sandbox_get_pin_muxing() due to get_pin_muxing()
>    prototype changes
>
> Changes in v3:
>  - Fix typo
>
> Changes in v2: None
>
>  arch/sandbox/dts/test.dts    |  4 +++
>  test/py/tests/test_pinmux.py | 62 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
>  create mode 100644 test/py/tests/test_pinmux.py

Reviewed-by: Simon Glass <sjg@chromium.org>

Nice!
Tom Rini Nov. 17, 2018, 1:33 p.m. UTC | #2
On Wed, Oct 24, 2018 at 02:10:23PM +0200, Patrice Chotard wrote:

> Add pinmux test which test the following commands:
>   - pinmux list
>   - pinmux dev
>   - pinmux status
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 57e0dd766317..2d2a812d3535 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -712,6 +712,10 @@ 
 	sandbox_tee {
 		compatible = "sandbox,tee";
 	};
+
+	pinctrl {
+		compatible = "sandbox,pinctrl";
+	};
 };
 
 #include "sandbox_pmic.dtsi"
diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py
new file mode 100644
index 000000000000..f04a2796ee92
--- /dev/null
+++ b/test/py/tests/test_pinmux.py
@@ -0,0 +1,62 @@ 
+# SPDX-License-Identifier: GPL-2.0
+
+import pytest
+import u_boot_utils
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_usage_1(u_boot_console):
+    """Test that 'pinmux' command without parameters displays
+    pinmux usage."""
+    output = u_boot_console.run_command('pinmux')
+    assert 'Usage:' in output
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_usage_2(u_boot_console):
+    """Test that 'pinmux status' executed without previous "pinmux dev"
+    command displays pinmux usage."""
+    output = u_boot_console.run_command('pinmux status')
+    assert 'Usage:' in output
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_status_all(u_boot_console):
+    """Test that 'pinmux status -a' displays pin's muxing."""
+    output = u_boot_console.run_command('pinmux status -a')
+    assert ('SCL       : I2C SCL' in output)
+    assert ('SDA       : I2C SDA' in output)
+    assert ('TX        : Uart TX' in output)
+    assert ('RX        : Uart RX' in output)
+    assert ('W1        : 1-wire gpio' in output)
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_list(u_boot_console):
+    """Test that 'pinmux list' returns the pin-controller list."""
+    output = u_boot_console.run_command('pinmux list')
+    assert 'sandbox_pinctrl' in output
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_dev_bad(u_boot_console):
+    """Test that 'pinmux dev' returns an error when trying to select a
+    wrong pin controller."""
+    pincontroller = 'bad_pin_controller_name'
+    output = u_boot_console.run_command('pinmux dev ' + pincontroller)
+    expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!'
+    assert (expected_output in output)
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_dev(u_boot_console):
+    """Test that 'pinmux dev' select the wanted pin controller."""
+    pincontroller = 'pinctrl'
+    output = u_boot_console.run_command('pinmux dev ' + pincontroller)
+    expected_output = 'dev: ' + pincontroller
+    assert (expected_output in output)
+
+@pytest.mark.buildconfigspec('cmd_pinmux')
+def test_pinmux_status(u_boot_console):
+    """Test that 'pinmux status' displays selected pincontroller's pin
+    muxing descriptions."""
+    output = u_boot_console.run_command('pinmux status')
+    assert ('SCL       : I2C SCL' in output)
+    assert ('SDA       : I2C SDA' in output)
+    assert ('TX        : Uart TX' in output)
+    assert ('RX        : Uart RX' in output)
+    assert ('W1        : 1-wire gpio' in output)