diff options
author | Tim Newsome <tim@sifive.com> | 2017-06-20 15:02:28 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2017-06-20 15:02:28 -0700 |
commit | 9ff4594d26f485495f47d4473905af9c4f10caa8 (patch) | |
tree | 822f1c2355640dddb31d92e4e748008583ee12d1 /debug/testlib.py | |
parent | 9e313f30205b8172290831c3af18b0779e9b15f2 (diff) | |
download | riscv-tests-9ff4594d26f485495f47d4473905af9c4f10caa8.zip riscv-tests-9ff4594d26f485495f47d4473905af9c4f10caa8.tar.gz riscv-tests-9ff4594d26f485495f47d4473905af9c4f10caa8.tar.bz2 |
Smoketest multicore.
When connecting to gdb, select a random thread and use that for the
current test.
Also replace infinite_loop with something that will later allow
smoketesting of more than one thread.
Diffstat (limited to 'debug/testlib.py')
-rw-r--r-- | debug/testlib.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/debug/testlib.py b/debug/testlib.py index 30c31c5..b8ff5c2 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -1,4 +1,5 @@ import os.path +import random import re import shlex import subprocess @@ -82,7 +83,7 @@ class Spike(object): os.environ['REMOTE_BITBANG_HOST'] = 'localhost' self.infinite_loop = target.compile( "programs/checksum.c", "programs/tiny-malloc.c", - "programs/infinite_loop.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE") + "programs/infinite_loop.S", "-DDEFINE_MALLOC", "-DDEFINE_FREE") cmd.append(self.infinite_loop) logfile = open(self.logname, "w") logfile.write("+ %s\n" % " ".join(cmd)) @@ -219,7 +220,12 @@ class Openocd(object): raise Exception("ERROR: Timed out waiting for OpenOCD to " "examine RISCV core") - self.port = self._get_gdb_server_port() + try: + self.port = self._get_gdb_server_port() + except: + header("OpenOCD log") + sys.stdout.write(log) + raise def _get_gdb_server_port(self): """Get port that OpenOCD's gdb server is listening on.""" @@ -586,9 +592,13 @@ class GdbTest(BaseTest): if self.server.port: self.gdb.command( "target extended-remote localhost:%d" % self.server.port) - # Force gdb to discover threads now, otherwise it might interrupt - # us at some point when it decides by itself to check. - self.gdb.command("info threads") + # Select a random thread. + # TODO: Allow a command line option to force a specific thread. + output = self.gdb.command("info threads") + threads = re.findall(r"Thread (\d+)", output) + if threads: + thread = random.choice(threads) + self.gdb.command("thread %s" % thread) # FIXME: OpenOCD doesn't handle PRIV now #self.gdb.p("$priv=3") |