xref: /openbmc/u-boot/test/py/tests/test_pinmux.py (revision 4c0411eb)
1# SPDX-License-Identifier: GPL-2.0
2
3import pytest
4import u_boot_utils
5
6@pytest.mark.buildconfigspec('cmd_pinmux')
7def test_pinmux_usage_1(u_boot_console):
8    """Test that 'pinmux' command without parameters displays
9    pinmux usage."""
10    output = u_boot_console.run_command('pinmux')
11    assert 'Usage:' in output
12
13@pytest.mark.buildconfigspec('cmd_pinmux')
14def test_pinmux_usage_2(u_boot_console):
15    """Test that 'pinmux status' executed without previous "pinmux dev"
16    command displays pinmux usage."""
17    output = u_boot_console.run_command('pinmux status')
18    assert 'Usage:' in output
19
20@pytest.mark.buildconfigspec('cmd_pinmux')
21@pytest.mark.boardspec('sandbox')
22def test_pinmux_status_all(u_boot_console):
23    """Test that 'pinmux status -a' displays pin's muxing."""
24    output = u_boot_console.run_command('pinmux status -a')
25    assert ('SCL       : I2C SCL' in output)
26    assert ('SDA       : I2C SDA' in output)
27    assert ('TX        : Uart TX' in output)
28    assert ('RX        : Uart RX' in output)
29    assert ('W1        : 1-wire gpio' in output)
30
31@pytest.mark.buildconfigspec('cmd_pinmux')
32@pytest.mark.boardspec('sandbox')
33def test_pinmux_list(u_boot_console):
34    """Test that 'pinmux list' returns the pin-controller list."""
35    output = u_boot_console.run_command('pinmux list')
36    assert 'sandbox_pinctrl' in output
37
38@pytest.mark.buildconfigspec('cmd_pinmux')
39def test_pinmux_dev_bad(u_boot_console):
40    """Test that 'pinmux dev' returns an error when trying to select a
41    wrong pin controller."""
42    pincontroller = 'bad_pin_controller_name'
43    output = u_boot_console.run_command('pinmux dev ' + pincontroller)
44    expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!'
45    assert (expected_output in output)
46
47@pytest.mark.buildconfigspec('cmd_pinmux')
48@pytest.mark.boardspec('sandbox')
49def test_pinmux_dev(u_boot_console):
50    """Test that 'pinmux dev' select the wanted pin controller."""
51    pincontroller = 'pinctrl'
52    output = u_boot_console.run_command('pinmux dev ' + pincontroller)
53    expected_output = 'dev: ' + pincontroller
54    assert (expected_output in output)
55
56@pytest.mark.buildconfigspec('cmd_pinmux')
57@pytest.mark.boardspec('sandbox')
58def test_pinmux_status(u_boot_console):
59    """Test that 'pinmux status' displays selected pincontroller's pin
60    muxing descriptions."""
61    output = u_boot_console.run_command('pinmux status')
62    assert ('SCL       : I2C SCL' in output)
63    assert ('SDA       : I2C SDA' in output)
64    assert ('TX        : Uart TX' in output)
65    assert ('RX        : Uart RX' in output)
66    assert ('W1        : 1-wire gpio' in output)
67