diff options
Diffstat (limited to 'test/py/tests')
-rw-r--r-- | test/py/tests/test_000_version.py | 2 | ||||
-rw-r--r-- | test/py/tests/test_dfu.py | 32 | ||||
-rw-r--r-- | test/py/tests/test_env.py | 54 | ||||
-rw-r--r-- | test/py/tests/test_help.py | 2 | ||||
-rw-r--r-- | test/py/tests/test_hush_if_test.py | 10 | ||||
-rw-r--r-- | test/py/tests/test_md.py | 8 | ||||
-rw-r--r-- | test/py/tests/test_net.py | 24 | ||||
-rw-r--r-- | test/py/tests/test_sandbox_exit.py | 4 | ||||
-rw-r--r-- | test/py/tests/test_shell_basics.py | 10 | ||||
-rw-r--r-- | test/py/tests/test_sleep.py | 4 | ||||
-rw-r--r-- | test/py/tests/test_ums.py | 24 | ||||
-rw-r--r-- | test/py/tests/test_unknown_cmd.py | 4 |
12 files changed, 89 insertions, 89 deletions
diff --git a/test/py/tests/test_000_version.py b/test/py/tests/test_000_version.py index d262f0534e..43a02e74f7 100644 --- a/test/py/tests/test_000_version.py +++ b/test/py/tests/test_000_version.py @@ -9,7 +9,7 @@ # command prompt. def test_version(u_boot_console): - '''Test that the "version" command prints the U-Boot version.''' + """Test that the "version" command prints the U-Boot version.""" # "version" prints the U-Boot sign-on message. This is usually considered # an error, so that any unexpected reboot causes an error. Here, this diff --git a/test/py/tests/test_dfu.py b/test/py/tests/test_dfu.py index 6c1a363b02..0f69eef66b 100644 --- a/test/py/tests/test_dfu.py +++ b/test/py/tests/test_dfu.py @@ -12,7 +12,7 @@ import os.path import pytest import u_boot_utils -''' +""" Note: This test relies on: a) boardenv_* to contain configuration values to define which USB ports are @@ -44,7 +44,7 @@ ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNELS=="3-13", MODE:="66 (You may wish to change the group ID instead of setting the permissions wide open. All that matters is that the user ID running the test can access the device.) -''' +""" # The set of file sizes to test. These values trigger various edge-cases such # as one less than, equal to, and one greater than typical USB max packet @@ -71,7 +71,7 @@ first_usb_dev_port = None @pytest.mark.buildconfigspec('cmd_dfu') def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): - '''Test the "dfu" command; the host system must be able to enumerate a USB + """Test the "dfu" command; the host system must be able to enumerate a USB device when "dfu" is running, various DFU transfers are tested, and the USB device must disappear when "dfu" is aborted. @@ -86,10 +86,10 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ def start_dfu(): - '''Start U-Boot's dfu shell command. + """Start U-Boot's dfu shell command. This also waits for the host-side USB enumeration process to complete. @@ -98,7 +98,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ fh = u_boot_utils.attempt_to_open_file( env__usb_dev_port['host_usb_dev_node']) @@ -120,7 +120,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): fh.close() def stop_dfu(ignore_errors): - '''Stop U-Boot's dfu shell command from executing. + """Stop U-Boot's dfu shell command from executing. This also waits for the host-side USB de-enumeration process to complete. @@ -133,7 +133,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ try: u_boot_console.log.action( @@ -148,7 +148,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): raise def run_dfu_util(alt_setting, fn, up_dn_load_arg): - '''Invoke dfu-util on the host. + """Invoke dfu-util on the host. Args: alt_setting: The DFU "alternate setting" identifier to interact @@ -159,7 +159,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ cmd = ['dfu-util', '-a', str(alt_setting), up_dn_load_arg, fn] if 'host_usb_port_path' in env__usb_dev_port: @@ -168,7 +168,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): u_boot_console.wait_for('Ctrl+C to exit ...') def dfu_write(alt_setting, fn): - '''Write a file to the target board using DFU. + """Write a file to the target board using DFU. Args: alt_setting: The DFU "alternate setting" identifier to interact @@ -177,12 +177,12 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ run_dfu_util(alt_setting, fn, '-D') def dfu_read(alt_setting, fn): - '''Read a file from the target board using DFU. + """Read a file from the target board using DFU. Args: alt_setting: The DFU "alternate setting" identifier to interact @@ -191,7 +191,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ # dfu-util fails reads/uploads if the host file already exists if os.path.exists(fn): @@ -199,7 +199,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): run_dfu_util(alt_setting, fn, '-U') def dfu_write_read_check(size): - '''Test DFU transfers of a specific size of data + """Test DFU transfers of a specific size of data This function first writes data to the board then reads it back and compares the written and read back data. Measures are taken to avoid @@ -210,7 +210,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config): Returns: Nothing. - ''' + """ test_f = u_boot_utils.PersistentRandomFile(u_boot_console, 'dfu_%d.bin' % size, size) diff --git a/test/py/tests/test_env.py b/test/py/tests/test_env.py index 557c3afe5c..651303f8cd 100644 --- a/test/py/tests/test_env.py +++ b/test/py/tests/test_env.py @@ -10,34 +10,34 @@ import pytest # FIXME: This might be useful for other tests; # perhaps refactor it into ConsoleBase or some other state object? class StateTestEnv(object): - '''Container that represents the state of all U-Boot environment variables. + """Container that represents the state of all U-Boot environment variables. This enables quick determination of existant/non-existant variable names. - ''' + """ def __init__(self, u_boot_console): - '''Initialize a new StateTestEnv object. + """Initialize a new StateTestEnv object. Args: u_boot_console: A U-Boot console. Returns: Nothing. - ''' + """ self.u_boot_console = u_boot_console self.get_env() self.set_var = self.get_non_existent_var() def get_env(self): - '''Read all current environment variables from U-Boot. + """Read all current environment variables from U-Boot. Args: None. Returns: Nothing. - ''' + """ response = self.u_boot_console.run_command('printenv') self.env = {} @@ -48,27 +48,27 @@ class StateTestEnv(object): self.env[var] = value def get_existent_var(self): - '''Return the name of an environment variable that exists. + """Return the name of an environment variable that exists. Args: None. Returns: The name of an environment variable. - ''' + """ for var in self.env: return var def get_non_existent_var(self): - '''Return the name of an environment variable that does not exist. + """Return the name of an environment variable that does not exist. Args: None. Returns: The name of an environment variable. - ''' + """ n = 0 while True: @@ -80,7 +80,7 @@ class StateTestEnv(object): ste = None @pytest.fixture(scope='function') def state_test_env(u_boot_console): - '''pytest fixture to provide a StateTestEnv object to tests.''' + """pytest fixture to provide a StateTestEnv object to tests.""" global ste if not ste: @@ -88,7 +88,7 @@ def state_test_env(u_boot_console): return ste def unset_var(state_test_env, var): - '''Unset an environment variable. + """Unset an environment variable. This both executes a U-Boot shell command and updates a StateTestEnv object. @@ -99,14 +99,14 @@ def unset_var(state_test_env, var): Returns: Nothing. - ''' + """ state_test_env.u_boot_console.run_command('setenv %s' % var) if var in state_test_env.env: del state_test_env.env[var] def set_var(state_test_env, var, value): - '''Set an environment variable. + """Set an environment variable. This both executes a U-Boot shell command and updates a StateTestEnv object. @@ -118,26 +118,26 @@ def set_var(state_test_env, var, value): Returns: Nothing. - ''' + """ state_test_env.u_boot_console.run_command('setenv %s "%s"' % (var, value)) state_test_env.env[var] = value def validate_empty(state_test_env, var): - '''Validate that a variable is not set, using U-Boot shell commands. + """Validate that a variable is not set, using U-Boot shell commands. Args: var: The variable name to test. Returns: Nothing. - ''' + """ response = state_test_env.u_boot_console.run_command('echo $%s' % var) assert response == '' def validate_set(state_test_env, var, value): - '''Validate that a variable is set, using U-Boot shell commands. + """Validate that a variable is set, using U-Boot shell commands. Args: var: The variable name to test. @@ -145,7 +145,7 @@ def validate_set(state_test_env, var, value): Returns: Nothing. - ''' + """ # echo does not preserve leading, internal, or trailing whitespace in the # value. printenv does, and hence allows more complete testing. @@ -153,20 +153,20 @@ def validate_set(state_test_env, var, value): assert response == ('%s=%s' % (var, value)) def test_env_echo_exists(state_test_env): - '''Test echoing a variable that exists.''' + """Test echoing a variable that exists.""" var = state_test_env.get_existent_var() value = state_test_env.env[var] validate_set(state_test_env, var, value) def test_env_echo_non_existent(state_test_env): - '''Test echoing a variable that doesn't exist.''' + """Test echoing a variable that doesn't exist.""" var = state_test_env.set_var validate_empty(state_test_env, var) def test_env_printenv_non_existent(state_test_env): - '''Test printenv error message for non-existant variables.''' + """Test printenv error message for non-existant variables.""" var = state_test_env.set_var c = state_test_env.u_boot_console @@ -175,14 +175,14 @@ def test_env_printenv_non_existent(state_test_env): assert(response == '## Error: "%s" not defined' % var) def test_env_unset_non_existent(state_test_env): - '''Test unsetting a nonexistent variable.''' + """Test unsetting a nonexistent variable.""" var = state_test_env.get_non_existent_var() unset_var(state_test_env, var) validate_empty(state_test_env, var) def test_env_set_non_existent(state_test_env): - '''Test set a non-existant variable.''' + """Test set a non-existant variable.""" var = state_test_env.set_var value = 'foo' @@ -190,7 +190,7 @@ def test_env_set_non_existent(state_test_env): validate_set(state_test_env, var, value) def test_env_set_existing(state_test_env): - '''Test setting an existant variable.''' + """Test setting an existant variable.""" var = state_test_env.set_var value = 'bar' @@ -198,14 +198,14 @@ def test_env_set_existing(state_test_env): validate_set(state_test_env, var, value) def test_env_unset_existing(state_test_env): - '''Test unsetting a variable.''' + """Test unsetting a variable.""" var = state_test_env.set_var unset_var(state_test_env, var) validate_empty(state_test_env, var) def test_env_expansion_spaces(state_test_env): - '''Test expanding a variable that contains a space in its value.''' + """Test expanding a variable that contains a space in its value.""" var_space = None var_test = None diff --git a/test/py/tests/test_help.py b/test/py/tests/test_help.py index 894f3b5f17..420090cf0d 100644 --- a/test/py/tests/test_help.py +++ b/test/py/tests/test_help.py @@ -4,6 +4,6 @@ # SPDX-License-Identifier: GPL-2.0 def test_help(u_boot_console): - '''Test that the "help" command can be executed.''' + """Test that the "help" command can be executed.""" u_boot_console.run_command('help') diff --git a/test/py/tests/test_hush_if_test.py b/test/py/tests/test_hush_if_test.py index cf4c3aeeb7..8b88425a65 100644 --- a/test/py/tests/test_hush_if_test.py +++ b/test/py/tests/test_hush_if_test.py @@ -95,7 +95,7 @@ subtests = ( ) def exec_hush_if(u_boot_console, expr, result): - '''Execute a shell "if" command, and validate its result.''' + """Execute a shell "if" command, and validate its result.""" cmd = 'if ' + expr + '; then echo true; else echo false; fi' response = u_boot_console.run_command(cmd) @@ -103,7 +103,7 @@ def exec_hush_if(u_boot_console, expr, result): @pytest.mark.buildconfigspec('sys_hush_parser') def test_hush_if_test_setup(u_boot_console): - '''Set up environment variables used during the "if" tests.''' + """Set up environment variables used during the "if" tests.""" u_boot_console.run_command('setenv ut_var_nonexistent') u_boot_console.run_command('setenv ut_var_exists 1') @@ -111,13 +111,13 @@ def test_hush_if_test_setup(u_boot_console): @pytest.mark.buildconfigspec('sys_hush_parser') @pytest.mark.parametrize('expr,result', subtests) def test_hush_if_test(u_boot_console, expr, result): - '''Test a single "if test" condition.''' + """Test a single "if test" condition.""" exec_hush_if(u_boot_console, expr, result) @pytest.mark.buildconfigspec('sys_hush_parser') def test_hush_if_test_teardown(u_boot_console): - '''Clean up environment variables used during the "if" tests.''' + """Clean up environment variables used during the "if" tests.""" u_boot_console.run_command('setenv ut_var_exists') @@ -126,7 +126,7 @@ def test_hush_if_test_teardown(u_boot_console): # Of those, only UMS currently allows file removal though. @pytest.mark.boardspec('sandbox') def test_hush_if_test_host_file_exists(u_boot_console): - '''Test the "if test -e" shell command.''' + """Test the "if test -e" shell command.""" test_file = u_boot_console.config.result_dir + \ '/creating_this_file_breaks_u_boot_tests' diff --git a/test/py/tests/test_md.py b/test/py/tests/test_md.py index 32cce4f15c..5fe25826b3 100644 --- a/test/py/tests/test_md.py +++ b/test/py/tests/test_md.py @@ -8,8 +8,8 @@ import u_boot_utils @pytest.mark.buildconfigspec('cmd_memory') def test_md(u_boot_console): - '''Test that md reads memory as expected, and that memory can be modified - using the mw command.''' + """Test that md reads memory as expected, and that memory can be modified + using the mw command.""" ram_base = u_boot_utils.find_ram_base(u_boot_console) addr = '%08x' % ram_base @@ -24,8 +24,8 @@ def test_md(u_boot_console): @pytest.mark.buildconfigspec('cmd_memory') def test_md_repeat(u_boot_console): - '''Test command repeat (via executing an empty command) operates correctly - for "md"; the command must repeat and dump an incrementing address.''' + """Test command repeat (via executing an empty command) operates correctly + for "md"; the command must repeat and dump an incrementing address.""" ram_base = u_boot_utils.find_ram_base(u_boot_console) addr_base = '%08x' % ram_base diff --git a/test/py/tests/test_net.py b/test/py/tests/test_net.py index 9c46551e8c..68eedde7c8 100644 --- a/test/py/tests/test_net.py +++ b/test/py/tests/test_net.py @@ -8,7 +8,7 @@ import pytest import u_boot_utils -''' +""" Note: This test relies on boardenv_* containing configuration values to define which the network environment available for testing. Without this, this test will be automatically skipped. @@ -46,16 +46,16 @@ env__net_tftp_readable_file = { "size": 5058624, "crc32": "c2244b26", } -''' +""" net_set_up = False def test_net_pre_commands(u_boot_console): - '''Execute any commands required to enable network hardware. + """Execute any commands required to enable network hardware. These commands are provided by the boardenv_* file; see the comment at the beginning of this file. - ''' + """ init_usb = u_boot_console.config.env.get('env__net_uses_usb', False) if init_usb: @@ -67,11 +67,11 @@ def test_net_pre_commands(u_boot_console): @pytest.mark.buildconfigspec('cmd_dhcp') def test_net_dhcp(u_boot_console): - '''Test the dhcp command. + """Test the dhcp command. The boardenv_* file may be used to enable/disable this test; see the comment at the beginning of this file. - ''' + """ test_dhcp = u_boot_console.config.env.get('env__net_dhcp_server', False) if not test_dhcp: @@ -86,11 +86,11 @@ def test_net_dhcp(u_boot_console): @pytest.mark.buildconfigspec('net') def test_net_setup_static(u_boot_console): - '''Set up a static IP configuration. + """Set up a static IP configuration. The configuration is provided by the boardenv_* file; see the comment at the beginning of this file. - ''' + """ env_vars = u_boot_console.config.env.get('env__net_static_env_vars', None) if not env_vars: @@ -104,12 +104,12 @@ def test_net_setup_static(u_boot_console): @pytest.mark.buildconfigspec('cmd_ping') def test_net_ping(u_boot_console): - '''Test the ping command. + """Test the ping command. The $serverip (as set up by either test_net_dhcp or test_net_setup_static) is pinged. The test validates that the host is alive, as reported by the ping command's output. - ''' + """ if not net_set_up: pytest.skip("Network not initialized") @@ -119,14 +119,14 @@ def test_net_ping(u_boot_console): @pytest.mark.buildconfigspec('cmd_net') def test_net_tftpboot(u_boot_console): - '''Test the tftpboot command. + """Test the tftpboot command. A file is downloaded from the TFTP server, its size and optionally its CRC32 are validated. The details of the file to download are provided by the boardenv_* file; see the comment at the beginning of this file. - ''' + """ if not net_set_up: pytest.skip("Network not initialized") diff --git a/test/py/tests/test_sandbox_exit.py b/test/py/tests/test_sandbox_exit.py index 1ec3607eb2..d1aa3083f4 100644 --- a/test/py/tests/test_sandbox_exit.py +++ b/test/py/tests/test_sandbox_exit.py @@ -9,14 +9,14 @@ import signal @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('reset') def test_reset(u_boot_console): - '''Test that the "reset" command exits sandbox process.''' + """Test that the "reset" command exits sandbox process.""" u_boot_console.run_command('reset', wait_for_prompt=False) assert(u_boot_console.validate_exited()) @pytest.mark.boardspec('sandbox') def test_ctrl_c(u_boot_console): - '''Test that sending SIGINT to sandbox causes it to exit.''' + """Test that sending SIGINT to sandbox causes it to exit.""" u_boot_console.kill(signal.SIGINT) assert(u_boot_console.validate_exited()) diff --git a/test/py/tests/test_shell_basics.py b/test/py/tests/test_shell_basics.py index 719ce611d7..32e5f83015 100644 --- a/test/py/tests/test_shell_basics.py +++ b/test/py/tests/test_shell_basics.py @@ -5,13 +5,13 @@ # Test basic shell functionality, such as commands separate by semi-colons. def test_shell_execute(u_boot_console): - '''Test any shell command.''' + """Test any shell command.""" response = u_boot_console.run_command('echo hello') assert response.strip() == 'hello' def test_shell_semicolon_two(u_boot_console): - '''Test two shell commands separate by a semi-colon.''' + """Test two shell commands separate by a semi-colon.""" cmd = 'echo hello; echo world' response = u_boot_console.run_command(cmd) @@ -19,8 +19,8 @@ def test_shell_semicolon_two(u_boot_console): assert response.index('hello') < response.index('world') def test_shell_semicolon_three(u_boot_console): - '''Test three shell commands separate by a semi-colon, with variable - expansion dependencies between them.''' + """Test three shell commands separate by a semi-colon, with variable + expansion dependencies between them.""" cmd = 'setenv list 1; setenv list ${list}2; setenv list ${list}3; ' + \ 'echo ${list}' @@ -29,7 +29,7 @@ def test_shell_semicolon_three(u_boot_console): u_boot_console.run_command('setenv list') def test_shell_run(u_boot_console): - '''Test the "run" shell command.''' + """Test the "run" shell command.""" u_boot_console.run_command('setenv foo \"setenv monty 1; setenv python 2\"') u_boot_console.run_command('run foo') diff --git a/test/py/tests/test_sleep.py b/test/py/tests/test_sleep.py index 437b6bb9fe..74add891c3 100644 --- a/test/py/tests/test_sleep.py +++ b/test/py/tests/test_sleep.py @@ -6,8 +6,8 @@ import pytest import time def test_sleep(u_boot_console): - '''Test the sleep command, and validate that it sleeps for approximately - the correct amount of time.''' + """Test the sleep command, and validate that it sleeps for approximately + the correct amount of time.""" # 3s isn't too long, but is enough to cross a few second boundaries. sleep_time = 3 diff --git a/test/py/tests/test_ums.py b/test/py/tests/test_ums.py index f482cfeca1..21d40a9725 100644 --- a/test/py/tests/test_ums.py +++ b/test/py/tests/test_ums.py @@ -14,7 +14,7 @@ import re import time import u_boot_utils -''' +""" Note: This test relies on: a) boardenv_* to contain configuration values to define which USB ports are @@ -69,11 +69,11 @@ root permissions. For example: This entry is only needed if any block_devs above contain a writable_fs_partition value. -''' +""" @pytest.mark.buildconfigspec('cmd_usb_mass_storage') def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): - '''Test the "ums" command; the host system must be able to enumerate a UMS + """Test the "ums" command; the host system must be able to enumerate a UMS device when "ums" is running, block and optionally file I/O are tested, and this device must disappear when "ums" is aborted. @@ -88,7 +88,7 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): Returns: Nothing. - ''' + """ have_writable_fs_partition = 'writable_fs_partition' in env__block_devs[0] if not have_writable_fs_partition: @@ -120,7 +120,7 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn def start_ums(): - '''Start U-Boot's ums shell command. + """Start U-Boot's ums shell command. This also waits for the host-side USB enumeration process to complete. @@ -129,7 +129,7 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): Returns: Nothing. - ''' + """ u_boot_console.log.action( 'Starting long-running U-Boot ums shell command') @@ -142,21 +142,21 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): fh.close() def mount(): - '''Mount the block device that U-Boot exports. + """Mount the block device that U-Boot exports. Args: None. Returns: Nothing. - ''' + """ u_boot_console.log.action('Mounting exported UMS device') cmd = ('/bin/mount', host_ums_part_node) u_boot_utils.run_and_log(u_boot_console, cmd) def umount(ignore_errors): - '''Unmount the block device that U-Boot exports. + """Unmount the block device that U-Boot exports. Args: ignore_errors: Ignore any errors. This is useful if an error has @@ -166,14 +166,14 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): Returns: Nothing. - ''' + """ u_boot_console.log.action('Unmounting UMS device') cmd = ('/bin/umount', host_ums_part_node) u_boot_utils.run_and_log(u_boot_console, cmd, ignore_errors) def stop_ums(ignore_errors): - '''Stop U-Boot's ums shell command from executing. + """Stop U-Boot's ums shell command from executing. This also waits for the host-side USB de-enumeration process to complete. @@ -186,7 +186,7 @@ def test_ums(u_boot_console, env__usb_dev_port, env__block_devs): Returns: Nothing. - ''' + """ u_boot_console.log.action( 'Stopping long-running U-Boot ums shell command') diff --git a/test/py/tests/test_unknown_cmd.py b/test/py/tests/test_unknown_cmd.py index 2de93e0026..c27ab49d55 100644 --- a/test/py/tests/test_unknown_cmd.py +++ b/test/py/tests/test_unknown_cmd.py @@ -4,8 +4,8 @@ # SPDX-License-Identifier: GPL-2.0 def test_unknown_command(u_boot_console): - '''Test that executing an unknown command causes U-Boot to print an - error.''' + """Test that executing an unknown command causes U-Boot to print an + error.""" # The "unknown command" error is actively expected here, # so error detection for it is disabled. |