Skip to content

Commit 0009a26

Browse files
committed
Add a way to exclude tests by specifying an exclusion file
This patch adds a way to specify a yaml file which specifies either for each target individually or for all targets to exclude tests. Example file format is included in excluded.yaml.example.
1 parent 7b52ba3 commit 0009a26

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
@@ -947,6 +948,32 @@ def __enter__(self):
947948
def __exit__(self, _type, _value, _traceback):
948949
self.gdb.pop_state()
949950

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

1015+
excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name)
1016+
target.skip_tests += excluded_tests
1017+
9881018
results, count = run_tests(parsed, target, todo)
9891019

9901020
header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':')
@@ -1065,6 +1095,8 @@ def add_test_run_options(parser):
10651095
parser.add_argument("--misaval",
10661096
help="Don't run ExamineTarget, just assume the misa value which is "
10671097
"specified.")
1098+
parser.add_argument("--exclude-tests",
1099+
help="Specify yaml file listing tests to exclude")
10681100

10691101
def header(title, dash='-', length=78):
10701102
if title:

0 commit comments

Comments
 (0)