Patrice Chotard | f41a824 | 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" |
Patrick Delaunay | 4c60fd9 | 2021-05-21 09:47:31 +0200 | [diff] [blame] | 16 | command displays error message.""" |
Patrice Chotard | f41a824 | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 17 | output = u_boot_console.run_command('pinmux status') |
Patrick Delaunay | 4c60fd9 | 2021-05-21 09:47:31 +0200 | [diff] [blame] | 18 | assert 'pin-controller device not selected' in output |
Patrice Chotard | f41a824 | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 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 | e5301ba | 2020-01-13 11:35:15 +0100 | [diff] [blame] | 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) |
Sean Anderson | 7f0f180 | 2020-09-14 11:01:57 -0400 | [diff] [blame] | 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) |
Patrice Chotard | f41a824 | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 40 | |
| 41 | @pytest.mark.buildconfigspec('cmd_pinmux') |
| 42 | @pytest.mark.boardspec('sandbox') |
| 43 | def 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') |
| 49 | def 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') |
| 59 | def 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') |
| 68 | def test_pinmux_status(u_boot_console): |
| 69 | """Test that 'pinmux status' displays selected pincontroller's pin |
| 70 | muxing descriptions.""" |
Simon Glass | 2aa1188 | 2022-08-06 17:51:45 -0600 | [diff] [blame] | 71 | u_boot_console.run_command('pinmux dev pinctrl') |
Patrice Chotard | f41a824 | 2018-10-24 14:10:23 +0200 | [diff] [blame] | 72 | output = u_boot_console.run_command('pinmux status') |
Patrick Delaunay | e5301ba | 2020-01-13 11:35:15 +0100 | [diff] [blame] | 73 | |
| 74 | assert (not 'pinctrl-gpio:' in output) |
| 75 | assert (not 'pinctrl:' in output) |
| 76 | |
Sean Anderson | 7f0f180 | 2020-09-14 11:01:57 -0400 | [diff] [blame] | 77 | assert ('P0 : UART TX.' in output) |
| 78 | assert ('P1 : UART RX.' in output) |
| 79 | assert ('P2 : I2S SCK.' in output) |
| 80 | assert ('P3 : I2S SD.' in output) |
| 81 | assert ('P4 : I2S WS.' in output) |
| 82 | assert ('P5 : GPIO0 bias-pull-up input-disable.' in output) |
| 83 | assert ('P6 : GPIO1 drive-open-drain.' in output) |
| 84 | assert ('P7 : GPIO2 bias-pull-down input-enable.' in output) |
| 85 | assert ('P8 : GPIO3 bias-disable.' in output) |