test/py: use " for docstrings
Python's coding style docs indicate to use " not ' for docstrings.
test/py has other violations of the coding style docs, since the docs
specify a stranger style than I would expect, but nobody has complained
about those yet:-)
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
diff --git a/test/py/conftest.py b/test/py/conftest.py
index c1f19ce..a4e54c6 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -29,7 +29,7 @@
console = None
def mkdir_p(path):
- '''Create a directory path.
+ """Create a directory path.
This includes creating any intermediate/parent directories. Any errors
caused due to already extant directories are ignored.
@@ -39,7 +39,7 @@
Returns:
Nothing.
- '''
+ """
try:
os.makedirs(path)
@@ -50,14 +50,14 @@
raise
def pytest_addoption(parser):
- '''pytest hook: Add custom command-line options to the cmdline parser.
+ """pytest hook: Add custom command-line options to the cmdline parser.
Args:
parser: The pytest command-line parser.
Returns:
Nothing.
- '''
+ """
parser.addoption('--build-dir', default=None,
help='U-Boot build directory (O=)')
@@ -73,14 +73,14 @@
help='Compile U-Boot before running tests')
def pytest_configure(config):
- '''pytest hook: Perform custom initialization at startup time.
+ """pytest hook: Perform custom initialization at startup time.
Args:
config: The pytest configuration.
Returns:
Nothing.
- '''
+ """
global log
global console
@@ -190,7 +190,7 @@
console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
def pytest_generate_tests(metafunc):
- '''pytest hook: parameterize test functions based on custom rules.
+ """pytest hook: parameterize test functions based on custom rules.
If a test function takes parameter(s) (fixture names) of the form brd__xxx
or env__xxx, the brd and env configuration dictionaries are consulted to
@@ -202,7 +202,7 @@
Returns:
Nothing.
- '''
+ """
subconfigs = {
'brd': console.config.brd,
@@ -229,14 +229,14 @@
@pytest.fixture(scope='function')
def u_boot_console(request):
- '''Generate the value of a test's u_boot_console fixture.
+ """Generate the value of a test's u_boot_console fixture.
Args:
request: The pytest request.
Returns:
The fixture value.
- '''
+ """
console.ensure_spawned()
return console
@@ -247,7 +247,7 @@
tests_passed = set()
def pytest_itemcollected(item):
- '''pytest hook: Called once for each test found during collection.
+ """pytest hook: Called once for each test found during collection.
This enables our custom result analysis code to see the list of all tests
that should eventually be run.
@@ -257,12 +257,12 @@
Returns:
Nothing.
- '''
+ """
tests_not_run.add(item.name)
def cleanup():
- '''Clean up all global state.
+ """Clean up all global state.
Executed (via atexit) once the entire test process is complete. This
includes logging the status of all tests, and the identity of any failed
@@ -273,7 +273,7 @@
Returns:
Nothing.
- '''
+ """
if console:
console.close()
@@ -295,7 +295,7 @@
atexit.register(cleanup)
def setup_boardspec(item):
- '''Process any 'boardspec' marker for a test.
+ """Process any 'boardspec' marker for a test.
Such a marker lists the set of board types that a test does/doesn't
support. If tests are being executed on an unsupported board, the test is
@@ -306,7 +306,7 @@
Returns:
Nothing.
- '''
+ """
mark = item.get_marker('boardspec')
if not mark:
@@ -323,7 +323,7 @@
pytest.skip('board not supported')
def setup_buildconfigspec(item):
- '''Process any 'buildconfigspec' marker for a test.
+ """Process any 'buildconfigspec' marker for a test.
Such a marker lists some U-Boot configuration feature that the test
requires. If tests are being executed on an U-Boot build that doesn't
@@ -334,7 +334,7 @@
Returns:
Nothing.
- '''
+ """
mark = item.get_marker('buildconfigspec')
if not mark:
@@ -344,7 +344,7 @@
pytest.skip('.config feature not enabled')
def pytest_runtest_setup(item):
- '''pytest hook: Configure (set up) a test item.
+ """pytest hook: Configure (set up) a test item.
Called once for each test to perform any custom configuration. This hook
is used to skip the test if certain conditions apply.
@@ -354,14 +354,14 @@
Returns:
Nothing.
- '''
+ """
log.start_section(item.name)
setup_boardspec(item)
setup_buildconfigspec(item)
def pytest_runtest_protocol(item, nextitem):
- '''pytest hook: Called to execute a test.
+ """pytest hook: Called to execute a test.
This hook wraps the standard pytest runtestprotocol() function in order
to acquire visibility into, and record, each test function's result.
@@ -372,7 +372,7 @@
Returns:
A list of pytest reports (test result data).
- '''
+ """
reports = runtestprotocol(item, nextitem=nextitem)
failed = None
diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index 5059bbf..c2a3b89 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -14,12 +14,12 @@
mod_dir = os.path.dirname(os.path.abspath(__file__))
class LogfileStream(object):
- '''A file-like object used to write a single logical stream of data into
+ """A file-like object used to write a single logical stream of data into
a multiplexed log file. Objects of this type should be created by factory
- functions in the Logfile class rather than directly.'''
+ functions in the Logfile class rather than directly."""
def __init__(self, logfile, name, chained_file):
- '''Initialize a new object.
+ """Initialize a new object.
Args:
logfile: The Logfile object to log to.
@@ -29,26 +29,26 @@
Returns:
Nothing.
- '''
+ """
self.logfile = logfile
self.name = name
self.chained_file = chained_file
def close(self):
- '''Dummy function so that this class is "file-like".
+ """Dummy function so that this class is "file-like".
Args:
None.
Returns:
Nothing.
- '''
+ """
pass
def write(self, data, implicit=False):
- '''Write data to the log stream.
+ """Write data to the log stream.
Args:
data: The data to write tot he file.
@@ -60,33 +60,33 @@
Returns:
Nothing.
- '''
+ """
self.logfile.write(self, data, implicit)
if self.chained_file:
self.chained_file.write(data)
def flush(self):
- '''Flush the log stream, to ensure correct log interleaving.
+ """Flush the log stream, to ensure correct log interleaving.
Args:
None.
Returns:
Nothing.
- '''
+ """
self.logfile.flush()
if self.chained_file:
self.chained_file.flush()
class RunAndLog(object):
- '''A utility object used to execute sub-processes and log their output to
+ """A utility object used to execute sub-processes and log their output to
a multiplexed log file. Objects of this type should be created by factory
- functions in the Logfile class rather than directly.'''
+ functions in the Logfile class rather than directly."""
def __init__(self, logfile, name, chained_file):
- '''Initialize a new object.
+ """Initialize a new object.
Args:
logfile: The Logfile object to log to.
@@ -96,18 +96,18 @@
Returns:
Nothing.
- '''
+ """
self.logfile = logfile
self.name = name
self.chained_file = chained_file
def close(self):
- '''Clean up any resources managed by this object.'''
+ """Clean up any resources managed by this object."""
pass
def run(self, cmd, cwd=None, ignore_errors=False):
- '''Run a command as a sub-process, and log the results.
+ """Run a command as a sub-process, and log the results.
Args:
cmd: The command to execute.
@@ -120,7 +120,7 @@
Returns:
Nothing.
- '''
+ """
msg = "+" + " ".join(cmd) + "\n"
if self.chained_file:
@@ -163,13 +163,13 @@
raise exception
class SectionCtxMgr(object):
- '''A context manager for Python's "with" statement, which allows a certain
+ """A context manager for Python's "with" statement, which allows a certain
portion of test code to be logged to a separate section of the log file.
Objects of this type should be created by factory functions in the Logfile
- class rather than directly.'''
+ class rather than directly."""
def __init__(self, log, marker):
- '''Initialize a new object.
+ """Initialize a new object.
Args:
log: The Logfile object to log to.
@@ -177,7 +177,7 @@
Returns:
Nothing.
- '''
+ """
self.log = log
self.marker = marker
@@ -189,18 +189,18 @@
self.log.end_section(self.marker)
class Logfile(object):
- '''Generates an HTML-formatted log file containing multiple streams of
- data, each represented in a well-delineated/-structured fashion.'''
+ """Generates an HTML-formatted log file containing multiple streams of
+ data, each represented in a well-delineated/-structured fashion."""
def __init__(self, fn):
- '''Initialize a new object.
+ """Initialize a new object.
Args:
fn: The filename to write to.
Returns:
Nothing.
- '''
+ """
self.f = open(fn, "wt")
self.last_stream = None
@@ -217,7 +217,7 @@
""")
def close(self):
- '''Close the log file.
+ """Close the log file.
After calling this function, no more data may be written to the log.
@@ -226,7 +226,7 @@
Returns:
Nothing.
- '''
+ """
self.f.write("""\
</tt>
@@ -241,7 +241,7 @@
"".join(chr(c) for c in range(127, 256)))
def _escape(self, data):
- '''Render data format suitable for inclusion in an HTML document.
+ """Render data format suitable for inclusion in an HTML document.
This includes HTML-escaping certain characters, and translating
control characters to a hexadecimal representation.
@@ -251,7 +251,7 @@
Returns:
An escaped version of the data.
- '''
+ """
data = data.replace(chr(13), "")
data = "".join((c in self._nonprint) and ("%%%02x" % ord(c)) or
@@ -260,14 +260,14 @@
return data
def _terminate_stream(self):
- '''Write HTML to the log file to terminate the current stream's data.
+ """Write HTML to the log file to terminate the current stream's data.
Args:
None.
Returns:
Nothing.
- '''
+ """
self.cur_evt += 1
if not self.last_stream:
@@ -280,7 +280,7 @@
self.last_stream = None
def _note(self, note_type, msg):
- '''Write a note or one-off message to the log file.
+ """Write a note or one-off message to the log file.
Args:
note_type: The type of note. This must be a value supported by the
@@ -289,7 +289,7 @@
Returns:
Nothing.
- '''
+ """
self._terminate_stream()
self.f.write("<div class=\"" + note_type + "\">\n<pre>")
@@ -297,14 +297,14 @@
self.f.write("\n</pre></div>\n")
def start_section(self, marker):
- '''Begin a new nested section in the log file.
+ """Begin a new nested section in the log file.
Args:
marker: The name of the section that is starting.
Returns:
Nothing.
- '''
+ """
self._terminate_stream()
self.blocks.append(marker)
@@ -314,7 +314,7 @@
"\">Section: " + blk_path + "</div>\n")
def end_section(self, marker):
- '''Terminate the current nested section in the log file.
+ """Terminate the current nested section in the log file.
This function validates proper nesting of start_section() and
end_section() calls. If a mismatch is found, an exception is raised.
@@ -324,7 +324,7 @@
Returns:
Nothing.
- '''
+ """
if (not self.blocks) or (marker != self.blocks[-1]):
raise Exception("Block nesting mismatch: \"%s\" \"%s\"" %
@@ -337,7 +337,7 @@
self.blocks.pop()
def section(self, marker):
- '''Create a temporary section in the log file.
+ """Create a temporary section in the log file.
This function creates a context manager for Python's "with" statement,
which allows a certain portion of test code to be logged to a separate
@@ -352,96 +352,96 @@
Returns:
A context manager object.
- '''
+ """
return SectionCtxMgr(self, marker)
def error(self, msg):
- '''Write an error note to the log file.
+ """Write an error note to the log file.
Args:
msg: A message describing the error.
Returns:
Nothing.
- '''
+ """
self._note("error", msg)
def warning(self, msg):
- '''Write an warning note to the log file.
+ """Write an warning note to the log file.
Args:
msg: A message describing the warning.
Returns:
Nothing.
- '''
+ """
self._note("warning", msg)
def info(self, msg):
- '''Write an informational note to the log file.
+ """Write an informational note to the log file.
Args:
msg: An informational message.
Returns:
Nothing.
- '''
+ """
self._note("info", msg)
def action(self, msg):
- '''Write an action note to the log file.
+ """Write an action note to the log file.
Args:
msg: A message describing the action that is being logged.
Returns:
Nothing.
- '''
+ """
self._note("action", msg)
def status_pass(self, msg):
- '''Write a note to the log file describing test(s) which passed.
+ """Write a note to the log file describing test(s) which passed.
Args:
msg: A message describing passed test(s).
Returns:
Nothing.
- '''
+ """
self._note("status-pass", msg)
def status_skipped(self, msg):
- '''Write a note to the log file describing skipped test(s).
+ """Write a note to the log file describing skipped test(s).
Args:
msg: A message describing passed test(s).
Returns:
Nothing.
- '''
+ """
self._note("status-skipped", msg)
def status_fail(self, msg):
- '''Write a note to the log file describing failed test(s).
+ """Write a note to the log file describing failed test(s).
Args:
msg: A message describing passed test(s).
Returns:
Nothing.
- '''
+ """
self._note("status-fail", msg)
def get_stream(self, name, chained_file=None):
- '''Create an object to log a single stream's data into the log file.
+ """Create an object to log a single stream's data into the log file.
This creates a "file-like" object that can be written to in order to
write a single stream's data to the log file. The implementation will
@@ -456,12 +456,12 @@
Returns:
A file-like object.
- '''
+ """
return LogfileStream(self, name, chained_file)
def get_runner(self, name, chained_file=None):
- '''Create an object that executes processes and logs their output.
+ """Create an object that executes processes and logs their output.
Args:
name: The name of this sub-process.
@@ -470,12 +470,12 @@
Returns:
A RunAndLog object.
- '''
+ """
return RunAndLog(self, name, chained_file)
def write(self, stream, data, implicit=False):
- '''Write stream data into the log file.
+ """Write stream data into the log file.
This function should only be used by instances of LogfileStream or
RunAndLog.
@@ -491,7 +491,7 @@
Returns:
Nothing.
- '''
+ """
if stream != self.last_stream:
self._terminate_stream()
@@ -507,13 +507,13 @@
self.last_stream = stream
def flush(self):
- '''Flush the log stream, to ensure correct log interleaving.
+ """Flush the log stream, to ensure correct log interleaving.
Args:
None.
Returns:
Nothing.
- '''
+ """
self.f.flush()
diff --git a/test/py/tests/test_000_version.py b/test/py/tests/test_000_version.py
index d262f05..43a02e7 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 6c1a363..0f69eef 100644
--- a/test/py/tests/test_dfu.py
+++ b/test/py/tests/test_dfu.py
@@ -12,7 +12,7 @@
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 @@
(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 @@
@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 @@
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 @@
Returns:
Nothing.
- '''
+ """
fh = u_boot_utils.attempt_to_open_file(
env__usb_dev_port['host_usb_dev_node'])
@@ -120,7 +120,7 @@
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 @@
Returns:
Nothing.
- '''
+ """
try:
u_boot_console.log.action(
@@ -148,7 +148,7 @@
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 @@
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 @@
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 @@
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 @@
Returns:
Nothing.
- '''
+ """
# dfu-util fails reads/uploads if the host file already exists
if os.path.exists(fn):
@@ -199,7 +199,7 @@
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 @@
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 557c3af..651303f 100644
--- a/test/py/tests/test_env.py
+++ b/test/py/tests/test_env.py
@@ -10,34 +10,34 @@
# 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 894f3b5..420090c 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 cf4c3ae..8b88425 100644
--- a/test/py/tests/test_hush_if_test.py
+++ b/test/py/tests/test_hush_if_test.py
@@ -95,7 +95,7 @@
)
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 @@
@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 @@
@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 @@
# 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 32cce4f..5fe2582 100644
--- a/test/py/tests/test_md.py
+++ b/test/py/tests/test_md.py
@@ -8,8 +8,8 @@
@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 @@
@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 9c46551..68eedde 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 @@
"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 @@
@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 @@
@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 @@
@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 @@
@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 1ec3607..d1aa308 100644
--- a/test/py/tests/test_sandbox_exit.py
+++ b/test/py/tests/test_sandbox_exit.py
@@ -9,14 +9,14 @@
@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 719ce61..32e5f83 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 @@
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 @@
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 437b6bb..74add89 100644
--- a/test/py/tests/test_sleep.py
+++ b/test/py/tests/test_sleep.py
@@ -6,8 +6,8 @@
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 f482cfe..21d40a9 100644
--- a/test/py/tests/test_ums.py
+++ b/test/py/tests/test_ums.py
@@ -14,7 +14,7 @@
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 @@
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 @@
Returns:
Nothing.
- '''
+ """
have_writable_fs_partition = 'writable_fs_partition' in env__block_devs[0]
if not have_writable_fs_partition:
@@ -120,7 +120,7 @@
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 @@
Returns:
Nothing.
- '''
+ """
u_boot_console.log.action(
'Starting long-running U-Boot ums shell command')
@@ -142,21 +142,21 @@
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 @@
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 @@
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 2de93e0..c27ab49 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.
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index bb834b0..c500fb3 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -24,12 +24,12 @@
pattern_error_notification = re.compile('## Error: ')
class ConsoleDisableCheck(object):
- '''Context manager (for Python's with statement) that temporarily disables
+ """Context manager (for Python's with statement) that temporarily disables
the specified console output error check. This is useful when deliberately
executing a command that is known to trigger one of the error checks, in
order to test that the error condition is actually raised. This class is
used internally by ConsoleBase::disable_check(); it is not intended for
- direct usage.'''
+ direct usage."""
def __init__(self, console, check_type):
self.console = console
@@ -42,13 +42,13 @@
self.console.disable_check_count[self.check_type] -= 1
class ConsoleBase(object):
- '''The interface through which test functions interact with the U-Boot
+ """The interface through which test functions interact with the U-Boot
console. This primarily involves executing shell commands, capturing their
results, and checking for common error conditions. Some common utilities
- are also provided too.'''
+ are also provided too."""
def __init__(self, log, config, max_fifo_fill):
- '''Initialize a U-Boot console connection.
+ """Initialize a U-Boot console connection.
Can only usefully be called by sub-classes.
@@ -65,7 +65,7 @@
Returns:
Nothing.
- '''
+ """
self.log = log
self.config = config
@@ -88,7 +88,7 @@
self.at_prompt_logevt = None
def close(self):
- '''Terminate the connection to the U-Boot console.
+ """Terminate the connection to the U-Boot console.
This function is only useful once all interaction with U-Boot is
complete. Once this function is called, data cannot be sent to or
@@ -99,7 +99,7 @@
Returns:
Nothing.
- '''
+ """
if self.p:
self.p.close()
@@ -107,7 +107,7 @@
def run_command(self, cmd, wait_for_echo=True, send_nl=True,
wait_for_prompt=True):
- '''Execute a command via the U-Boot console.
+ """Execute a command via the U-Boot console.
The command is always sent to U-Boot.
@@ -142,7 +142,7 @@
The output from U-Boot during command execution. In other
words, the text U-Boot emitted between the point it echod the
command string and emitted the subsequent command prompts.
- '''
+ """
if self.at_prompt and \
self.at_prompt_logevt != self.logstream.logfile.cur_evt:
@@ -198,7 +198,7 @@
raise
def ctrlc(self):
- '''Send a CTRL-C character to U-Boot.
+ """Send a CTRL-C character to U-Boot.
This is useful in order to stop execution of long-running synchronous
commands such as "ums".
@@ -208,13 +208,13 @@
Returns:
Nothing.
- '''
+ """
self.log.action('Sending Ctrl-C')
self.run_command(chr(3), wait_for_echo=False, send_nl=False)
def wait_for(self, text):
- '''Wait for a pattern to be emitted by U-Boot.
+ """Wait for a pattern to be emitted by U-Boot.
This is useful when a long-running command such as "dfu" is executing,
and it periodically emits some text that should show up at a specific
@@ -226,14 +226,14 @@
Returns:
Nothing.
- '''
+ """
if type(text) == type(''):
text = re.escape(text)
self.p.expect([text])
def drain_console(self):
- '''Read from and log the U-Boot console for a short time.
+ """Read from and log the U-Boot console for a short time.
U-Boot's console output is only logged when the test code actively
waits for U-Boot to emit specific data. There are cases where tests
@@ -248,7 +248,7 @@
Returns:
Nothing.
- '''
+ """
# If we are already not connected to U-Boot, there's nothing to drain.
# This should only happen when a previous call to run_command() or
@@ -270,7 +270,7 @@
self.p.timeout = orig_timeout
def ensure_spawned(self):
- '''Ensure a connection to a correctly running U-Boot instance.
+ """Ensure a connection to a correctly running U-Boot instance.
This may require spawning a new Sandbox process or resetting target
hardware, as defined by the implementation sub-class.
@@ -282,7 +282,7 @@
Returns:
Nothing.
- '''
+ """
if self.p:
return
@@ -320,7 +320,7 @@
raise
def cleanup_spawn(self):
- '''Shut down all interaction with the U-Boot instance.
+ """Shut down all interaction with the U-Boot instance.
This is used when an error is detected prior to re-establishing a
connection with a fresh U-Boot instance.
@@ -332,7 +332,7 @@
Returns:
Nothing.
- '''
+ """
try:
if self.p:
@@ -342,7 +342,7 @@
self.p = None
def validate_version_string_in_text(self, text):
- '''Assert that a command's output includes the U-Boot signon message.
+ """Assert that a command's output includes the U-Boot signon message.
This is primarily useful for validating the "version" command without
duplicating the signon text regex in a test function.
@@ -352,12 +352,12 @@
Returns:
Nothing. An exception is raised if the validation fails.
- '''
+ """
assert(self.u_boot_version_string in text)
def disable_check(self, check_type):
- '''Temporarily disable an error check of U-Boot's output.
+ """Temporarily disable an error check of U-Boot's output.
Create a new context manager (for use with the "with" statement) which
temporarily disables a particular console output error check.
@@ -368,6 +368,6 @@
Returns:
A context manager object.
- '''
+ """
return ConsoleDisableCheck(self, check_type)
diff --git a/test/py/u_boot_console_exec_attach.py b/test/py/u_boot_console_exec_attach.py
index 0ca9e7c..19520cb 100644
--- a/test/py/u_boot_console_exec_attach.py
+++ b/test/py/u_boot_console_exec_attach.py
@@ -11,15 +11,15 @@
from u_boot_console_base import ConsoleBase
class ConsoleExecAttach(ConsoleBase):
- '''Represents a physical connection to a U-Boot console, typically via a
+ """Represents a physical connection to a U-Boot console, typically via a
serial port. This implementation executes a sub-process to attach to the
console, expecting that the stdin/out of the sub-process will be forwarded
to/from the physical hardware. This approach isolates the test infra-
structure from the user-/installation-specific details of how to
- communicate with, and the identity of, serial ports etc.'''
+ communicate with, and the identity of, serial ports etc."""
def __init__(self, log, config):
- '''Initialize a U-Boot console connection.
+ """Initialize a U-Boot console connection.
Args:
log: A multiplexed_log.Logfile instance.
@@ -27,7 +27,7 @@
Returns:
Nothing.
- '''
+ """
# The max_fifo_fill value might need tweaking per-board/-SoC?
# 1 would be safe anywhere, but is very slow (a pexpect issue?).
@@ -42,7 +42,7 @@
runner.close()
def get_spawn(self):
- '''Connect to a fresh U-Boot instance.
+ """Connect to a fresh U-Boot instance.
The target board is reset, so that U-Boot begins running from scratch.
@@ -51,7 +51,7 @@
Returns:
A u_boot_spawn.Spawn object that is attached to U-Boot.
- '''
+ """
args = [self.config.board_type, self.config.board_identity]
s = Spawn(['u-boot-test-console'] + args)
diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py
index eb84150..267f8b0 100644
--- a/test/py/u_boot_console_sandbox.py
+++ b/test/py/u_boot_console_sandbox.py
@@ -10,11 +10,11 @@
from u_boot_console_base import ConsoleBase
class ConsoleSandbox(ConsoleBase):
- '''Represents a connection to a sandbox U-Boot console, executed as a sub-
- process.'''
+ """Represents a connection to a sandbox U-Boot console, executed as a sub-
+ process."""
def __init__(self, log, config):
- '''Initialize a U-Boot console connection.
+ """Initialize a U-Boot console connection.
Args:
log: A multiplexed_log.Logfile instance.
@@ -22,12 +22,12 @@
Returns:
Nothing.
- '''
+ """
super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
def get_spawn(self):
- '''Connect to a fresh U-Boot instance.
+ """Connect to a fresh U-Boot instance.
A new sandbox process is created, so that U-Boot begins running from
scratch.
@@ -37,25 +37,25 @@
Returns:
A u_boot_spawn.Spawn object that is attached to U-Boot.
- '''
+ """
return Spawn([self.config.build_dir + '/u-boot'])
def kill(self, sig):
- '''Send a specific Unix signal to the sandbox process.
+ """Send a specific Unix signal to the sandbox process.
Args:
sig: The Unix signal to send to the process.
Returns:
Nothing.
- '''
+ """
self.log.action('kill %d' % sig)
self.p.kill(sig)
def validate_exited(self):
- '''Determine whether the sandbox process has exited.
+ """Determine whether the sandbox process has exited.
If required, this function waits a reasonable time for the process to
exit.
@@ -65,7 +65,7 @@
Returns:
Boolean indicating whether the process has exited.
- '''
+ """
p = self.p
self.p = None
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index df4c675..d508075 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -12,23 +12,23 @@
import time
class Timeout(Exception):
- '''An exception sub-class that indicates that a timeout occurred.'''
+ """An exception sub-class that indicates that a timeout occurred."""
pass
class Spawn(object):
- '''Represents the stdio of a freshly created sub-process. Commands may be
+ """Represents the stdio of a freshly created sub-process. Commands may be
sent to the process, and responses waited for.
- '''
+ """
def __init__(self, args):
- '''Spawn (fork/exec) the sub-process.
+ """Spawn (fork/exec) the sub-process.
Args:
args: array of processs arguments. argv[0] is the command to execute.
Returns:
Nothing.
- '''
+ """
self.waited = False
self.buf = ''
@@ -56,26 +56,26 @@
self.poll.register(self.fd, select.POLLIN | select.POLLPRI | select.POLLERR | select.POLLHUP | select.POLLNVAL)
def kill(self, sig):
- '''Send unix signal "sig" to the child process.
+ """Send unix signal "sig" to the child process.
Args:
sig: The signal number to send.
Returns:
Nothing.
- '''
+ """
os.kill(self.pid, sig)
def isalive(self):
- '''Determine whether the child process is still running.
+ """Determine whether the child process is still running.
Args:
None.
Returns:
Boolean indicating whether process is alive.
- '''
+ """
if self.waited:
return False
@@ -88,19 +88,19 @@
return False
def send(self, data):
- '''Send data to the sub-process's stdin.
+ """Send data to the sub-process's stdin.
Args:
data: The data to send to the process.
Returns:
Nothing.
- '''
+ """
os.write(self.fd, data)
def expect(self, patterns):
- '''Wait for the sub-process to emit specific data.
+ """Wait for the sub-process to emit specific data.
This function waits for the process to emit one pattern from the
supplied list of patterns, or for a timeout to occur.
@@ -116,7 +116,7 @@
Notable exceptions:
Timeout, if the process did not emit any of the patterns within
the expected time.
- '''
+ """
for pi in xrange(len(patterns)):
if type(patterns[pi]) == type(''):
@@ -161,7 +161,7 @@
self.logfile_read.flush()
def close(self):
- '''Close the stdio connection to the sub-process.
+ """Close the stdio connection to the sub-process.
This also waits a reasonable time for the sub-process to stop running.
@@ -170,7 +170,7 @@
Returns:
Nothing.
- '''
+ """
os.close(self.fd)
for i in xrange(100):
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index 522390a..72d24e4 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -11,21 +11,21 @@
import time
def md5sum_data(data):
- '''Calculate the MD5 hash of some data.
+ """Calculate the MD5 hash of some data.
Args:
data: The data to hash.
Returns:
The hash of the data, as a binary string.
- '''
+ """
h = hashlib.md5()
h.update(data)
return h.digest()
def md5sum_file(fn, max_length=None):
- '''Calculate the MD5 hash of the contents of a file.
+ """Calculate the MD5 hash of the contents of a file.
Args:
fn: The filename of the file to hash.
@@ -35,7 +35,7 @@
Returns:
The hash of the file content, as a binary string.
- '''
+ """
with open(fn, 'rb') as fh:
if max_length:
@@ -46,11 +46,11 @@
return md5sum_data(data)
class PersistentRandomFile(object):
- '''Generate and store information about a persistent file containing
- random data.'''
+ """Generate and store information about a persistent file containing
+ random data."""
def __init__(self, u_boot_console, fn, size):
- '''Create or process the persistent file.
+ """Create or process the persistent file.
If the file does not exist, it is generated.
@@ -66,7 +66,7 @@
Returns:
Nothing.
- '''
+ """
self.fn = fn
@@ -85,7 +85,7 @@
self.content_hash = md5sum_data(data)
def attempt_to_open_file(fn):
- '''Attempt to open a file, without throwing exceptions.
+ """Attempt to open a file, without throwing exceptions.
Any errors (exceptions) that occur during the attempt to open the file
are ignored. This is useful in order to test whether a file (in
@@ -98,7 +98,7 @@
Returns:
An open file handle to the file, or None if the file could not be
opened.
- '''
+ """
try:
return open(fn, 'rb')
@@ -106,7 +106,7 @@
return None
def wait_until_open_succeeds(fn):
- '''Poll until a file can be opened, or a timeout occurs.
+ """Poll until a file can be opened, or a timeout occurs.
Continually attempt to open a file, and return when this succeeds, or
raise an exception after a timeout.
@@ -116,7 +116,7 @@
Returns:
An open file handle to the file.
- '''
+ """
for i in xrange(100):
fh = attempt_to_open_file(fn)
@@ -126,7 +126,7 @@
raise Exception('File could not be opened')
def wait_until_file_open_fails(fn, ignore_errors):
- '''Poll until a file cannot be opened, or a timeout occurs.
+ """Poll until a file cannot be opened, or a timeout occurs.
Continually attempt to open a file, and return when this fails, or
raise an exception after a timeout.
@@ -139,7 +139,7 @@
Returns:
Nothing.
- '''
+ """
for i in xrange(100):
fh = attempt_to_open_file(fn)
@@ -152,7 +152,7 @@
raise Exception('File can still be opened')
def run_and_log(u_boot_console, cmd, ignore_errors=False):
- '''Run a command and log its output.
+ """Run a command and log its output.
Args:
u_boot_console: A console connection to U-Boot.
@@ -164,7 +164,7 @@
Returns:
Nothing.
- '''
+ """
runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
runner.run(cmd, ignore_errors=ignore_errors)
@@ -172,7 +172,7 @@
ram_base = None
def find_ram_base(u_boot_console):
- '''Find the running U-Boot's RAM location.
+ """Find the running U-Boot's RAM location.
Probe the running U-Boot to determine the address of the first bank
of RAM. This is useful for tests that test reading/writing RAM, or
@@ -186,7 +186,7 @@
Returns:
The address of U-Boot's first RAM bank, as an integer.
- '''
+ """
global ram_base
if u_boot_console.config.buildconfig.get('config_cmd_bdi', 'n') != 'y':