test/py: Drop u_boot_ prefix on test files
We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # test_android / test_dfu
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
# test, at shutdown etc. These hooks perform functions such as:
|
||||
# - Parsing custom command-line options.
|
||||
# - Pullilng in user-specified board configuration.
|
||||
# - Creating the U-Boot console test fixture.
|
||||
# - Creating the ubman test fixture.
|
||||
# - Creating the HTML log file.
|
||||
# - Monitoring each test's results.
|
||||
# - Implementing custom pytest markers.
|
||||
@@ -25,12 +25,12 @@ import re
|
||||
from _pytest.runner import runtestprotocol
|
||||
import subprocess
|
||||
import sys
|
||||
from spawn import BootFail, Timeout, Unexpected, handle_exception
|
||||
import time
|
||||
from u_boot_spawn import BootFail, Timeout, Unexpected, handle_exception
|
||||
|
||||
# Globals: The HTML log file, and the connection to the U-Boot console.
|
||||
# Globals: The HTML log file, and the top-level fixture
|
||||
log = None
|
||||
console = None
|
||||
ubman_fix = None
|
||||
|
||||
TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@@ -247,7 +247,7 @@ def pytest_configure(config):
|
||||
ubconfig.buildconfig.update(parser.items('root'))
|
||||
|
||||
global log
|
||||
global console
|
||||
global ubman_fix
|
||||
global ubconfig
|
||||
|
||||
(board_type, board_type_extra, board_identity, build_dir, build_dir_extra,
|
||||
@@ -343,11 +343,11 @@ def pytest_configure(config):
|
||||
os.environ['U_BOOT_' + v.upper()] = getattr(ubconfig, v)
|
||||
|
||||
if board_type.startswith('sandbox'):
|
||||
import u_boot_console_sandbox
|
||||
console = u_boot_console_sandbox.ConsoleSandbox(log, ubconfig)
|
||||
import console_sandbox
|
||||
ubman_fix = console_sandbox.ConsoleSandbox(log, ubconfig)
|
||||
else:
|
||||
import u_boot_console_exec_attach
|
||||
console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
|
||||
import console_board
|
||||
ubman_fix = console_board.ConsoleExecAttach(log, ubconfig)
|
||||
|
||||
|
||||
def generate_ut_subtest(metafunc, fixture_name, sym_path):
|
||||
@@ -366,7 +366,7 @@ def generate_ut_subtest(metafunc, fixture_name, sym_path):
|
||||
Returns:
|
||||
Nothing.
|
||||
"""
|
||||
fn = console.config.build_dir + sym_path
|
||||
fn = ubman_fix.config.build_dir + sym_path
|
||||
try:
|
||||
with open(fn, 'rt') as f:
|
||||
lines = f.readlines()
|
||||
@@ -407,8 +407,8 @@ def generate_config(metafunc, fixture_name):
|
||||
"""
|
||||
|
||||
subconfigs = {
|
||||
'brd': console.config.brd,
|
||||
'env': console.config.env,
|
||||
'brd': ubman_fix.config.brd,
|
||||
'env': ubman_fix.config.env,
|
||||
}
|
||||
parts = fixture_name.split('__')
|
||||
if len(parts) < 2:
|
||||
@@ -470,7 +470,7 @@ def u_boot_log(request):
|
||||
The fixture value.
|
||||
"""
|
||||
|
||||
return console.log
|
||||
return ubman_fix.log
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def u_boot_config(request):
|
||||
@@ -483,7 +483,7 @@ def u_boot_config(request):
|
||||
The fixture value.
|
||||
"""
|
||||
|
||||
return console.config
|
||||
return ubman_fix.config
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def ubman(request):
|
||||
@@ -499,18 +499,18 @@ def ubman(request):
|
||||
pytest.skip('Cannot get target connection')
|
||||
return None
|
||||
try:
|
||||
console.ensure_spawned()
|
||||
ubman_fix.ensure_spawned()
|
||||
except OSError as err:
|
||||
handle_exception(ubconfig, console, log, err, 'Lab failure', True)
|
||||
handle_exception(ubconfig, ubman_fix, log, err, 'Lab failure', True)
|
||||
except Timeout as err:
|
||||
handle_exception(ubconfig, console, log, err, 'Lab timeout', True)
|
||||
handle_exception(ubconfig, ubman_fix, log, err, 'Lab timeout', True)
|
||||
except BootFail as err:
|
||||
handle_exception(ubconfig, console, log, err, 'Boot fail', True,
|
||||
console.get_spawn_output())
|
||||
handle_exception(ubconfig, ubman_fix, log, err, 'Boot fail', True,
|
||||
ubman.get_spawn_output())
|
||||
except Unexpected:
|
||||
handle_exception(ubconfig, console, log, err, 'Unexpected test output',
|
||||
handle_exception(ubconfig, ubman_fix, log, err, 'Unexpected test output',
|
||||
False)
|
||||
return console
|
||||
return ubman_fix
|
||||
|
||||
anchors = {}
|
||||
tests_not_run = []
|
||||
@@ -623,8 +623,8 @@ def cleanup():
|
||||
Nothing.
|
||||
"""
|
||||
|
||||
if console:
|
||||
console.close()
|
||||
if ubman_fix:
|
||||
ubman_fix.close()
|
||||
if log:
|
||||
with log.section('Status Report', 'status_report'):
|
||||
log.status_pass('%d passed' % len(tests_passed))
|
||||
@@ -845,7 +845,7 @@ def pytest_runtest_protocol(item, nextitem):
|
||||
test_durations[item.name] = duration
|
||||
|
||||
if failure_cleanup:
|
||||
console.drain_console()
|
||||
ubman_fix.drain_console()
|
||||
|
||||
test_list.append(item.name)
|
||||
tests_not_run.remove(item.name)
|
||||
@@ -855,7 +855,7 @@ def pytest_runtest_protocol(item, nextitem):
|
||||
except:
|
||||
# If something went wrong with logging, it's better to let the test
|
||||
# process continue, which may report other exceptions that triggered
|
||||
# the logging issue (e.g. console.log wasn't created). Hence, just
|
||||
# the logging issue (e.g. ubman_fix.log wasn't created). Hence, just
|
||||
# squash the exception. If the test setup failed due to e.g. syntax
|
||||
# error somewhere else, this won't be seen. However, once that issue
|
||||
# is fixed, if this exception still exists, it will then be logged as
|
||||
@@ -868,6 +868,6 @@ def pytest_runtest_protocol(item, nextitem):
|
||||
log.end_section(item.name)
|
||||
|
||||
if failure_cleanup:
|
||||
console.cleanup_spawn()
|
||||
ubman_fix.cleanup_spawn()
|
||||
|
||||
return True
|
||||
|
Reference in New Issue
Block a user