test/py: Shorten u_boot_console
This fixture name is quite long and results in lots of verbose code.
We know this is U-Boot so the 'u_boot_' part is not necessary.
But it is also a bit of a misnomer, since it provides access to all the
information available to tests. It is not just the console.
It would be too confusing to use con as it would be confused with
config and it is probably too short.
So shorten it to 'ubman'.
Signed-off-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/u-boot/CAFLszTgPa4aT_J9h9pqeTtLCVn4x2JvLWRcWRD8NaN3uoSAtyA@mail.gmail.com/
diff --git a/test/py/tests/test_gpio.py b/test/py/tests/test_gpio.py
index 3e16e63..5c9d0b6 100644
--- a/test/py/tests/test_gpio.py
+++ b/test/py/tests/test_gpio.py
@@ -14,51 +14,51 @@
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_input(u_boot_console):
+def test_gpio_input(ubman):
"""Test that gpio input correctly returns the value of a gpio pin."""
- response = u_boot_console.run_command('gpio input 0; echo rc:$?')
+ response = ubman.run_command('gpio input 0; echo rc:$?')
expected_response = 'rc:0'
assert(expected_response in response)
- response = u_boot_console.run_command('gpio toggle 0; gpio input 0; echo rc:$?')
+ response = ubman.run_command('gpio toggle 0; gpio input 0; echo rc:$?')
expected_response = 'rc:1'
assert(expected_response in response)
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_exit_statuses(u_boot_console):
+def test_gpio_exit_statuses(ubman):
"""Test that non-input gpio commands correctly return the command
success/failure status."""
expected_response = 'rc:0'
- response = u_boot_console.run_command('gpio clear 0; echo rc:$?')
+ response = ubman.run_command('gpio clear 0; echo rc:$?')
assert(expected_response in response)
- response = u_boot_console.run_command('gpio set 0; echo rc:$?')
+ response = ubman.run_command('gpio set 0; echo rc:$?')
assert(expected_response in response)
- response = u_boot_console.run_command('gpio toggle 0; echo rc:$?')
+ response = ubman.run_command('gpio toggle 0; echo rc:$?')
assert(expected_response in response)
- response = u_boot_console.run_command('gpio status -a; echo rc:$?')
+ response = ubman.run_command('gpio status -a; echo rc:$?')
assert(expected_response in response)
expected_response = 'rc:1'
- response = u_boot_console.run_command('gpio nonexistent-command; echo rc:$?')
+ response = ubman.run_command('gpio nonexistent-command; echo rc:$?')
assert(expected_response in response)
- response = u_boot_console.run_command('gpio input 200; echo rc:$?')
+ response = ubman.run_command('gpio input 200; echo rc:$?')
assert(expected_response in response)
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_read(u_boot_console):
+def test_gpio_read(ubman):
"""Test that gpio read correctly sets the variable to the value of a gpio pin."""
- u_boot_console.run_command('gpio clear 0')
- response = u_boot_console.run_command('gpio read var 0; echo val:$var,rc:$?')
+ ubman.run_command('gpio clear 0')
+ response = ubman.run_command('gpio read var 0; echo val:$var,rc:$?')
expected_response = 'val:0,rc:0'
assert(expected_response in response)
- response = u_boot_console.run_command('gpio toggle 0; gpio read var 0; echo val:$var,rc:$?')
+ response = ubman.run_command('gpio toggle 0; gpio read var 0; echo val:$var,rc:$?')
expected_response = 'val:1,rc:0'
assert(expected_response in response)
- response = u_boot_console.run_command('setenv var; gpio read var nonexistent-gpio; echo val:$var,rc:$?')
+ response = ubman.run_command('setenv var; gpio read var nonexistent-gpio; echo val:$var,rc:$?')
expected_response = 'val:,rc:1'
assert(expected_response in response)
@@ -97,7 +97,7 @@
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_status_all_generic(u_boot_console):
+def test_gpio_status_all_generic(ubman):
"""Test the 'gpio status' command.
Displays all gpio pins available on the Board.
@@ -108,7 +108,7 @@
number of such pins and mention that count in 'gpio_str_count'.
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config',False)
+ f = ubman.config.env.get('env__gpio_dev_config',False)
if not f:
pytest.skip("gpio not configured")
@@ -116,14 +116,14 @@
#Display all the GPIO ports
cmd = 'gpio status -a'
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
for str_value in range(1,gpio_str_count + 1):
assert f["gpio_str_%d" %(str_value)] in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_set_generic(u_boot_console):
+def test_gpio_set_generic(ubman):
"""Test the 'gpio set' command.
A specific gpio pin configured by user as output
@@ -132,7 +132,7 @@
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config',False)
+ f = ubman.config.env.get('env__gpio_dev_config',False)
if not f:
pytest.skip("gpio not configured")
@@ -141,14 +141,14 @@
cmd = 'gpio set ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_set_value
assert good_response in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_clear_generic(u_boot_console):
+def test_gpio_clear_generic(ubman):
"""Test the 'gpio clear' command.
A specific gpio pin configured by user as output
@@ -156,7 +156,7 @@
'clear' option
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config',False)
+ f = ubman.config.env.get('env__gpio_dev_config',False)
if not f:
pytest.skip("gpio not configured")
@@ -165,13 +165,13 @@
cmd = 'gpio clear ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_clear_value
assert good_response in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_toggle_generic(u_boot_console):
+def test_gpio_toggle_generic(ubman):
"""Test the 'gpio toggle' command.
A specific gpio pin configured by user as output
@@ -180,7 +180,7 @@
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config',False)
+ f = ubman.config.env.get('env__gpio_dev_config',False)
if not f:
pytest.skip("gpio not configured")
@@ -189,18 +189,18 @@
gpio_clear_value = f['gpio_clear_value'];
cmd = 'gpio set ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_set_value
assert good_response in response
cmd = 'gpio toggle ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_clear_value
assert good_response in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_input_generic(u_boot_console):
+def test_gpio_input_generic(ubman):
"""Test the 'gpio input' command.
Specific gpio pins configured by user as input
@@ -208,7 +208,7 @@
is verified for logic '1' and logic '0' states
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config',False)
+ f = ubman.config.env.get('env__gpio_dev_config',False)
if not f:
pytest.skip("gpio not configured")
@@ -217,7 +217,7 @@
cmd = 'gpio input ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_clear_value
assert good_response in response
@@ -227,12 +227,12 @@
cmd = 'gpio input ' + gpio_pin_adr
- response = u_boot_console.run_command(cmd)
+ response = ubman.run_command(cmd)
good_response = gpio_set_value
assert good_response in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_pins_generic(u_boot_console):
+def test_gpio_pins_generic(ubman):
"""Test various gpio related functionality, such as the input, set, clear,
and toggle for the set of gpio pin list.
@@ -241,7 +241,7 @@
commands.
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config', False)
+ f = ubman.config.env.get('env__gpio_dev_config', False)
if not f:
pytest.skip('gpio not configured')
@@ -251,31 +251,31 @@
for gpin in gpio_pins:
# gpio input
- u_boot_console.run_command(f'gpio input {gpin}')
+ ubman.run_command(f'gpio input {gpin}')
expected_response = f'{gpin}: input:'
- response = u_boot_console.run_command(f'gpio status -a {gpin}')
+ response = ubman.run_command(f'gpio status -a {gpin}')
assert expected_response in response
# gpio set
- u_boot_console.run_command(f'gpio set {gpin}')
+ ubman.run_command(f'gpio set {gpin}')
expected_response = f'{gpin}: output: 1'
- response = u_boot_console.run_command(f'gpio status -a {gpin}')
+ response = ubman.run_command(f'gpio status -a {gpin}')
assert expected_response in response
# gpio clear
- u_boot_console.run_command(f'gpio clear {gpin}')
+ ubman.run_command(f'gpio clear {gpin}')
expected_response = f'{gpin}: output: 0'
- response = u_boot_console.run_command(f'gpio status -a {gpin}')
+ response = ubman.run_command(f'gpio status -a {gpin}')
assert expected_response in response
# gpio toggle
- u_boot_console.run_command(f'gpio toggle {gpin}')
+ ubman.run_command(f'gpio toggle {gpin}')
expected_response = f'{gpin}: output: 1'
- response = u_boot_console.run_command(f'gpio status -a {gpin}')
+ response = ubman.run_command(f'gpio status -a {gpin}')
assert expected_response in response
@pytest.mark.buildconfigspec('cmd_gpio')
-def test_gpio_pins_input_output_generic(u_boot_console):
+def test_gpio_pins_input_output_generic(ubman):
"""Test gpio related functionality such as input and output for the list of
shorted gpio pins provided as a pair of input and output pins. This test
will fail, if the gpio pins are not shorted properly.
@@ -285,7 +285,7 @@
pair to be tested for gpio input output case.
"""
- f = u_boot_console.config.env.get('env__gpio_dev_config', False)
+ f = ubman.config.env.get('env__gpio_dev_config', False)
if not f:
pytest.skip('gpio not configured')
@@ -294,22 +294,22 @@
pytest.skip('gpio pin list for input and output are not configured')
for gpins in gpio_pins:
- u_boot_console.run_command(f'gpio input {gpins[0]}')
+ ubman.run_command(f'gpio input {gpins[0]}')
expected_response = f'{gpins[0]}: input:'
- response = u_boot_console.run_command(f'gpio status -a {gpins[0]}')
+ response = ubman.run_command(f'gpio status -a {gpins[0]}')
assert expected_response in response
- u_boot_console.run_command(f'gpio set {gpins[1]}')
+ ubman.run_command(f'gpio set {gpins[1]}')
expected_response = f'{gpins[1]}: output:'
- response = u_boot_console.run_command(f'gpio status -a {gpins[1]}')
+ response = ubman.run_command(f'gpio status -a {gpins[1]}')
assert expected_response in response
- u_boot_console.run_command(f'gpio clear {gpins[1]}')
+ ubman.run_command(f'gpio clear {gpins[1]}')
expected_response = f'{gpins[0]}: input: 0'
- response = u_boot_console.run_command(f'gpio status -a {gpins[0]}')
+ response = ubman.run_command(f'gpio status -a {gpins[0]}')
assert expected_response in response
- u_boot_console.run_command(f'gpio set {gpins[1]}')
+ ubman.run_command(f'gpio set {gpins[1]}')
expected_response = f'{gpins[0]}: input: 1'
- response = u_boot_console.run_command(f'gpio status -a {gpins[0]}')
+ response = ubman.run_command(f'gpio status -a {gpins[0]}')
assert expected_response in response