From: Tim Newsome Date: Tue, 20 Jun 2017 22:02:28 +0000 (-0700) Subject: Smoketest multicore. X-Git-Url: https://git.libre-soc.org/?p=riscv-tests.git;a=commitdiff_plain;h=9ff4594d26f485495f47d4473905af9c4f10caa8 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. --- diff --git a/debug/programs/infinite_loop.S b/debug/programs/infinite_loop.S new file mode 100644 index 0000000..4b83143 --- /dev/null +++ b/debug/programs/infinite_loop.S @@ -0,0 +1,40 @@ +#include "encoding.h" + + .global main + + // Load constants into all registers so we can test no register are + // clobbered after attaching. +main: + csrr x1, CSR_MISA + slli x2, x1, 1 + slli x3, x2, 1 + slli x4, x3, 1 + slli x5, x4, 1 + slli x6, x5, 1 + slli x7, x6, 1 + slli x8, x7, 1 + slli x9, x8, 1 + slli x10, x9, 1 + slli x11, x10, 1 + slli x12, x11, 1 + slli x13, x12, 1 + slli x14, x13, 1 + slli x15, x14, 1 + slli x16, x15, 1 + slli x17, x16, 1 + slli x18, x17, 1 + slli x19, x18, 1 + slli x20, x19, 1 + slli x21, x20, 1 + slli x22, x21, 1 + slli x23, x22, 1 + slli x24, x23, 1 + slli x25, x24, 1 + slli x26, x25, 1 + slli x27, x26, 1 + slli x28, x27, 1 + slli x29, x28, 1 + slli x30, x29, 1 + slli x31, x30, 1 +1: + j 1b diff --git a/debug/programs/infinite_loop.c b/debug/programs/infinite_loop.c deleted file mode 100644 index 350d1de..0000000 --- a/debug/programs/infinite_loop.c +++ /dev/null @@ -1,9 +0,0 @@ -volatile int forever = 1; - -int main() -{ - while (forever) - ; - - return 1; -} 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")