Skip to content

Commit 271655f

Browse files
authored
Merge pull request #477 from MarekVCodasip/test-exclusion
Add a way to exclude tests by specifying an exclusion file
2 parents d0d1b08 + 0009a26 commit 271655f

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

debug/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ run.%:
2323
--isolate \
2424
--print-failures \
2525
--sim_cmd $(RISCV)/bin/$(RISCV_SIM) \
26-
--server_cmd $(RISCV)/bin/openocd
26+
--server_cmd $(RISCV)/bin/openocd \
27+
$(if $(EXCLUDE_TESTS),--exclude-tests $(EXCLUDE_TESTS))
2728

2829
# Target to check all the multicore options.
2930
multi-tests: spike32-2 spike32-2-hwthread

debug/excluded.yaml.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This is an example file showing the exclusion list format.
2+
# It can be passed to gdb_server.py using the --exclude-tests argument.
3+
4+
5+
# Tests excluded for all targets
6+
all:
7+
- SimpleF18Test
8+
9+
# Tests excluded for the "spike32" target only
10+
spike32:
11+
- MemTest32
12+
- PrivRw
13+
- Sv32Test
14+
15+
# Tests excluded for the "spike64" target only
16+
spike64:
17+
- UserInterrupt

debug/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pexpect>=4.0.0
2+
pyyaml>=3.12

debug/testlib.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import traceback
1212

1313
import pexpect
14+
import yaml
1415

1516
print_log_names = False
1617
real_stdout = sys.stdout
@@ -944,6 +945,32 @@ def __enter__(self):
944945
def __exit__(self, _type, _value, _traceback):
945946
self.gdb.pop_state()
946947

948+
949+
def load_excluded_tests(excluded_tests_file, target_name):
950+
result = []
951+
if excluded_tests_file is None or len(excluded_tests_file) == 0:
952+
return result
953+
954+
target_excludes = {}
955+
with open(excluded_tests_file) as file:
956+
raw_data = yaml.safe_load(file)
957+
for (target, test_list) in raw_data.items():
958+
if not isinstance(test_list, list):
959+
raise ValueError(f"Target {target!r} does not contain a test list", excluded_tests_file, test_list)
960+
if not all(isinstance(s, str) for s in test_list):
961+
raise ValueError(f"Not every element in the target test list {target!r} is a string",
962+
excluded_tests_file, test_list)
963+
964+
target_excludes.update(raw_data)
965+
966+
if target_name in target_excludes:
967+
result += target_excludes[target_name]
968+
if "all" in target_excludes:
969+
result += target_excludes["all"]
970+
971+
return result
972+
973+
947974
def run_all_tests(module, target, parsed):
948975
todo = []
949976
for name in dir(module):
@@ -982,6 +1009,9 @@ def run_all_tests(module, target, parsed):
9821009
todo.insert(0, ("ExamineTarget", ExamineTarget, None))
9831010
examine_added = True
9841011

1012+
excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name)
1013+
target.skip_tests += excluded_tests
1014+
9851015
results, count = run_tests(parsed, target, todo)
9861016

9871017
header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':')
@@ -1068,6 +1098,8 @@ def add_test_run_options(parser):
10681098
parser.add_argument("--misaval",
10691099
help="Don't run ExamineTarget, just assume the misa value which is "
10701100
"specified.")
1101+
parser.add_argument("--exclude-tests",
1102+
help="Specify yaml file listing tests to exclude")
10711103

10721104
def header(title, dash='-', length=78):
10731105
if title:

0 commit comments

Comments
 (0)