aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2019-12-10 13:22:58 -0800
committerGitHub <noreply@github.com>2019-12-10 13:22:58 -0800
commit9e3decb78644b7fce690acb217b295a40b86ef12 (patch)
tree975301684510c2c4ad0123d7d33054f32babaf1b
parent39234b7491c05e98f84d981f1c7bb6aea005ab30 (diff)
downloadriscv-tests-9e3decb78644b7fce690acb217b295a40b86ef12.zip
riscv-tests-9e3decb78644b7fce690acb217b295a40b86ef12.tar.gz
riscv-tests-9e3decb78644b7fce690acb217b295a40b86ef12.tar.bz2
Improve parallellism in debug test Makefile (#223)
* Improve parallellism in debug test Makefile Now each test is an individual make target, so you can get the most out of however many cores you have. On my 12-core system, `make` went from 2m45s to 42s, and `make all` went from `3m25s` to `2m39s`. If you have few cores, this change may actually slow things down a bit, because ExamineTarget is run for every gdbserver.py invocation. * Remove test target.
-rw-r--r--debug/Makefile20
-rw-r--r--debug/testlib.py23
2 files changed, 28 insertions, 15 deletions
diff --git a/debug/Makefile b/debug/Makefile
index 41d08f5..3efdea8 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -3,6 +3,7 @@ XLEN ?= 64
src_dir ?= .
GDBSERVER_PY = $(src_dir)/gdbserver.py
+TESTS = $(shell $(GDBSERVER_PY) --list-tests $(src_dir)/targets/RISC-V/spike32.py)
default: spike$(XLEN) spike$(XLEN)-2
@@ -11,19 +12,24 @@ all-tests: spike32 spike32-2 spike32-2-rtos spike32-2-hwthread \
all: pylint all-tests
+run.%:
+ echo $@
+ $(GDBSERVER_PY) \
+ $(src_dir)/targets/RISC-V/$(word 2, $(subst ., ,$@)).py \
+ $(word 3, $(subst ., ,$@)) \
+ --isolate \
+ --print-failures \
+ --sim_cmd $(RISCV)/bin/$(RISCV_SIM) \
+ --server_cmd $(RISCV)/bin/openocd
+
# Target to check all the multicore options.
multi-tests: spike32-2 spike64-2-rtos spike32-2-hwthread
pylint:
pylint --rcfile=pylint.rc `git ls-files '*.py'`
-spike%:
- $(GDBSERVER_PY) \
- --isolate \
- --print-failures \
- $(src_dir)/targets/RISC-V/$@.py \
- --sim_cmd $(RISCV)/bin/$(RISCV_SIM) \
- --server_cmd $(RISCV)/bin/openocd
+spike%: $(foreach test, $(TESTS), run.spike%.$(test))
+ echo Finished $@
clean:
rm -f *.pyc
diff --git a/debug/testlib.py b/debug/testlib.py
index 1aa0e5b..fbb0472 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -689,6 +689,18 @@ class PrivateState:
self.gdb.pop_state()
def run_all_tests(module, target, parsed):
+ todo = []
+ for name in dir(module):
+ definition = getattr(module, name)
+ if isinstance(definition, type) and hasattr(definition, 'test') and \
+ (not parsed.test or any(test in name for test in parsed.test)):
+ todo.append((name, definition, None))
+
+ if parsed.list_tests:
+ for name, definition, hart in todo:
+ print(name)
+ return 0
+
try:
os.makedirs(parsed.logs)
except OSError:
@@ -701,7 +713,6 @@ def run_all_tests(module, target, parsed):
global gdb_cmd # pylint: disable=global-statement
gdb_cmd = parsed.gdb
- todo = []
examine_added = False
for hart in target.harts:
if parsed.misaval:
@@ -710,15 +721,9 @@ def run_all_tests(module, target, parsed):
elif hart.misa:
print("Using $misa from hart definition: 0x%x" % hart.misa)
elif not examine_added:
- todo.append(("ExamineTarget", ExamineTarget, None))
+ todo.insert(0, ("ExamineTarget", ExamineTarget, None))
examine_added = True
- for name in dir(module):
- definition = getattr(module, name)
- if isinstance(definition, type) and hasattr(definition, 'test') and \
- (not parsed.test or any(test in name for test in parsed.test)):
- todo.append((name, definition, None))
-
results, count = run_tests(parsed, target, todo)
header("ran %d tests in %.0fs" % (count, time.time() - overall_start),
@@ -786,6 +791,8 @@ def add_test_run_options(parser):
parser.add_argument("--print-log-names", "--pln", action="store_true",
help="Print names of temporary log files as soon as they are "
"created.")
+ parser.add_argument("--list-tests", action="store_true",
+ help="Print out a list of tests, and exit immediately.")
parser.add_argument("test", nargs='*',
help="Run only tests that are named here.")
parser.add_argument("--gdb",