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 26 assert ('pinctrl-gpio:' in output) 27 assert ('a5 : gpio output .' in output) 28 assert ('a6 : gpio output .' in output) 29 30 assert ('pinctrl:' in output) 31 assert ('P0 : UART TX.' in output) 32 assert ('P1 : UART RX.' in output) 33 assert ('P2 : I2S SCK.' in output) 34 assert ('P3 : I2S SD.' in output) 35 assert ('P4 : I2S WS.' in output) 36 assert ('P5 : GPIO0 bias-pull-up input-disable.' in output) 37 assert ('P6 : GPIO1 drive-open-drain.' in output) 38 assert ('P7 : GPIO2 bias-pull-down input-enable.' in output) 39 assert ('P8 : GPIO3 bias-disable.' in output) 40 41@pytest.mark.buildconfigspec('cmd_pinmux') 42@pytest.mark.boardspec('sandbox') 43def test_pinmux_list(u_boot_console): 44 """Test that 'pinmux list' returns the pin-controller list.""" 45 output = u_boot_console.run_command('pinmux list') 46 assert 'sandbox_pinctrl' in output 47 48@pytest.mark.buildconfigspec('cmd_pinmux') 49def test_pinmux_dev_bad(u_boot_console): 50 """Test that 'pinmux dev' returns an error when trying to select a 51 wrong pin controller.""" 52 pincontroller = 'bad_pin_controller_name' 53 output = u_boot_console.run_command('pinmux dev ' + pincontroller) 54 expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!' 55 assert (expected_output in output) 56 57@pytest.mark.buildconfigspec('cmd_pinmux') 58@pytest.mark.boardspec('sandbox') 59def test_pinmux_dev(u_boot_console): 60 """Test that 'pinmux dev' select the wanted pin controller.""" 61 pincontroller = 'pinctrl' 62 output = u_boot_console.run_command('pinmux dev ' + pincontroller) 63 expected_output = 'dev: ' + pincontroller 64 assert (expected_output in output) 65 66@pytest.mark.buildconfigspec('cmd_pinmux') 67@pytest.mark.boardspec('sandbox') 68def test_pinmux_status(u_boot_console): 69 """Test that 'pinmux status' displays selected pincontroller's pin 70 muxing descriptions.""" 71 output = u_boot_console.run_command('pinmux status') 72 73 assert (not 'pinctrl-gpio:' in output) 74 assert (not 'pinctrl:' in output) 75 76 assert ('P0 : UART TX.' in output) 77 assert ('P1 : UART RX.' in output) 78 assert ('P2 : I2S SCK.' in output) 79 assert ('P3 : I2S SD.' in output) 80 assert ('P4 : I2S WS.' in output) 81 assert ('P5 : GPIO0 bias-pull-up input-disable.' in output) 82 assert ('P6 : GPIO1 drive-open-drain.' in output) 83 assert ('P7 : GPIO2 bias-pull-down input-enable.' in output) 84 assert ('P8 : GPIO3 bias-disable.' in output) 85