summaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py')
-rw-r--r--test/py/conftest.py9
-rw-r--r--test/py/tests/test_trace.py30
2 files changed, 35 insertions, 4 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py
index d9f074f3817..509d19b449d 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -144,6 +144,9 @@ def get_details(config):
# Get a few provided parameters
build_dir = config.getoption('build_dir')
build_dir_extra = config.getoption('build_dir_extra')
+
+ # The source tree must be the current directory
+ source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
if role:
# When using a role, build_dir and build_dir_extra are normally not set,
# since they are picked up from Labgrid-sjg via the u-boot-test-getrole
@@ -172,15 +175,13 @@ def get_details(config):
# Read the build directories here, in case none were provided in the
# command-line arguments
(board_type, board_type_extra, default_build_dir,
- default_build_dir_extra, source_dir) = (vals['board'],
- vals['board_extra'], vals['build_dir'], vals['build_dir_extra'],
- vals['source_dir'])
+ default_build_dir_extra) = (vals['board'],
+ vals['board_extra'], vals['build_dir'], vals['build_dir_extra'])
else:
board_type = config.getoption('board_type')
board_type_extra = config.getoption('board_type_extra')
board_identity = config.getoption('board_identity')
- source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
default_build_dir = source_dir + '/build-' + board_type
default_build_dir_extra = source_dir + '/build-' + board_type_extra
diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
index ec1e624722c..44239da5280 100644
--- a/test/py/tests/test_trace.py
+++ b/test/py/tests/test_trace.py
@@ -70,6 +70,32 @@ def collect_trace(cons):
return fname, int(dm_f_time[0])
+def wipe_and_collect_trace(cons):
+ """Pause and wipe traces, return the number of calls (should be zero)
+
+ Args:
+ cons (ConsoleBase): U-Boot console
+
+ Returns:
+ int: the number of traced function calls reported by 'trace stats'
+ """
+ cons.run_command('trace pause')
+ cons.run_command('trace wipe')
+ out = cons.run_command('trace stats')
+
+ # The output is something like this:
+ # 117,221 function sites
+ # 0 function calls
+ # 0 untracked function calls
+ # 0 traced function calls
+
+ # Get a dict of values from the output
+ lines = [line.split(maxsplit=1) for line in out.splitlines() if line]
+ vals = {key: val.replace(',', '') for val, key in lines}
+
+ return int(vals['traced function calls'])
+
+
def check_function(cons, fname, proftool, map_fname, trace_dat):
"""Check that the 'function' output works
@@ -304,3 +330,7 @@ def test_trace(u_boot_console):
# This allows for CI being slow to run
diff = abs(fg_time - dm_f_time)
assert diff / dm_f_time < 0.3
+
+ # Check that the trace buffer can be wiped
+ numcalls = wipe_and_collect_trace(cons)
+ assert numcalls == 0