aboutsummaryrefslogtreecommitdiff
path: root/debug/testlib.py
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-06-27 09:26:04 -0700
committerGitHub <noreply@github.com>2023-06-27 09:26:04 -0700
commit271655ffb6f93fbcf4fbd9ad995aabf206a31777 (patch)
treefbfb1c983d08335edf7c4876050f11a1f9d07b78 /debug/testlib.py
parentd0d1b08f8c49354de0a11a0f3dff44eea5eb8281 (diff)
parent0009a2612c532d5fcd057cde091ee1eb692af25e (diff)
downloadriscv-tests-271655ffb6f93fbcf4fbd9ad995aabf206a31777.zip
riscv-tests-271655ffb6f93fbcf4fbd9ad995aabf206a31777.tar.gz
riscv-tests-271655ffb6f93fbcf4fbd9ad995aabf206a31777.tar.bz2
Merge pull request #477 from MarekVCodasip/test-exclusion
Add a way to exclude tests by specifying an exclusion file
Diffstat (limited to 'debug/testlib.py')
-rw-r--r--debug/testlib.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/debug/testlib.py b/debug/testlib.py
index ba2bd7c..1899b20 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -11,6 +11,7 @@ import time
import traceback
import pexpect
+import yaml
print_log_names = False
real_stdout = sys.stdout
@@ -944,6 +945,32 @@ class PrivateState:
def __exit__(self, _type, _value, _traceback):
self.gdb.pop_state()
+
+def load_excluded_tests(excluded_tests_file, target_name):
+ result = []
+ if excluded_tests_file is None or len(excluded_tests_file) == 0:
+ return result
+
+ target_excludes = {}
+ with open(excluded_tests_file) as file:
+ raw_data = yaml.safe_load(file)
+ for (target, test_list) in raw_data.items():
+ if not isinstance(test_list, list):
+ raise ValueError(f"Target {target!r} does not contain a test list", excluded_tests_file, test_list)
+ if not all(isinstance(s, str) for s in test_list):
+ raise ValueError(f"Not every element in the target test list {target!r} is a string",
+ excluded_tests_file, test_list)
+
+ target_excludes.update(raw_data)
+
+ if target_name in target_excludes:
+ result += target_excludes[target_name]
+ if "all" in target_excludes:
+ result += target_excludes["all"]
+
+ return result
+
+
def run_all_tests(module, target, parsed):
todo = []
for name in dir(module):
@@ -982,6 +1009,9 @@ def run_all_tests(module, target, parsed):
todo.insert(0, ("ExamineTarget", ExamineTarget, None))
examine_added = True
+ excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name)
+ target.skip_tests += excluded_tests
+
results, count = run_tests(parsed, target, todo)
header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':')
@@ -1068,6 +1098,8 @@ def add_test_run_options(parser):
parser.add_argument("--misaval",
help="Don't run ExamineTarget, just assume the misa value which is "
"specified.")
+ parser.add_argument("--exclude-tests",
+ help="Specify yaml file listing tests to exclude")
def header(title, dash='-', length=78):
if title: