Patrice Chotard | 0fc8afc | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | import pytest |
| 4 | import u_boot_utils |
| 5 | |
| 6 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 7 | def 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') |
| 14 | def 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') |
| 22 | def 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') |
Patrick Delaunay | 939cbe9 | 2020-01-13 11:35:12 +0100 | [diff] [blame^] | 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 | assert ('GPIO0 : gpio bias-pull-up input-disable.' in output) |
| 31 | assert ('GPIO1 : gpio drive-open-drain.' in output) |
| 32 | assert ('GPIO2 : gpio bias-pull-down input-enable.' in output) |
| 33 | assert ('GPIO3 : gpio bias-disable.' in output) |
Patrice Chotard | 0fc8afc | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 34 | |
| 35 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 36 | @pytest.mark.boardspec('sandbox') |
| 37 | def test_pinmux_list(u_boot_console): |
| 38 | """Test that 'pinmux list' returns the pin-controller list.""" |
| 39 | output = u_boot_console.run_command('pinmux list') |
| 40 | assert 'sandbox_pinctrl' in output |
| 41 | |
| 42 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 43 | def test_pinmux_dev_bad(u_boot_console): |
| 44 | """Test that 'pinmux dev' returns an error when trying to select a |
| 45 | wrong pin controller.""" |
| 46 | pincontroller = 'bad_pin_controller_name' |
| 47 | output = u_boot_console.run_command('pinmux dev ' + pincontroller) |
| 48 | expected_output = 'Can\'t get the pin-controller: ' + pincontroller + '!' |
| 49 | assert (expected_output in output) |
| 50 | |
| 51 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 52 | @pytest.mark.boardspec('sandbox') |
| 53 | def test_pinmux_dev(u_boot_console): |
| 54 | """Test that 'pinmux dev' select the wanted pin controller.""" |
| 55 | pincontroller = 'pinctrl' |
| 56 | output = u_boot_console.run_command('pinmux dev ' + pincontroller) |
| 57 | expected_output = 'dev: ' + pincontroller |
| 58 | assert (expected_output in output) |
| 59 | |
| 60 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 61 | @pytest.mark.boardspec('sandbox') |
| 62 | def test_pinmux_status(u_boot_console): |
| 63 | """Test that 'pinmux status' displays selected pincontroller's pin |
| 64 | muxing descriptions.""" |
| 65 | output = u_boot_console.run_command('pinmux status') |
Patrick Delaunay | 939cbe9 | 2020-01-13 11:35:12 +0100 | [diff] [blame^] | 66 | assert ('SCL : I2C SCL.' in output) |
| 67 | assert ('SDA : I2C SDA.' in output) |
| 68 | assert ('TX : Uart TX.' in output) |
| 69 | assert ('RX : Uart RX.' in output) |
| 70 | assert ('W1 : 1-wire gpio.' in output) |
| 71 | assert ('GPIO0 : gpio bias-pull-up input-disable.' in output) |
| 72 | assert ('GPIO1 : gpio drive-open-drain.' in output) |
| 73 | assert ('GPIO2 : gpio bias-pull-down input-enable.' in output) |
| 74 | assert ('GPIO3 : gpio bias-disable.' in output) |