aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-07-18 09:57:37 -0700
committerTim Newsome <tim@sifive.com>2016-07-19 11:24:25 -0700
commitf254dce79dc5a278328699d65da2516545f5d31c (patch)
tree4548756c01d96cd9a6419b27b62e8a73aea3e452
parentdc3bfcbc943ea9b3fc50c5737490d51865fbc8ab (diff)
downloadriscv-tests-f254dce79dc5a278328699d65da2516545f5d31c.zip
riscv-tests-f254dce79dc5a278328699d65da2516545f5d31c.tar.gz
riscv-tests-f254dce79dc5a278328699d65da2516545f5d31c.tar.bz2
Add Makefile.
Add --isolate argument which enables the 32- and 64-bit spikes to be tested simultaneously.
-rw-r--r--debug/Makefile12
-rwxr-xr-xdebug/gdbserver.py44
-rw-r--r--debug/testlib.py5
3 files changed, 42 insertions, 19 deletions
diff --git a/debug/Makefile b/debug/Makefile
new file mode 100644
index 0000000..a138f25
--- /dev/null
+++ b/debug/Makefile
@@ -0,0 +1,12 @@
+RISCV_SIM ?= spike
+
+all: spike32.log spike64.log
+
+spike32.log:
+ ./gdbserver.py --isolate --spike32 --cmd $(RISCV_SIM) > $@ 2>&1
+
+spike64.log:
+ ./gdbserver.py --isolate --spike --cmd $(RISCV_SIM) > $@ 2>&1
+
+clean:
+ rm -f *.log
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 6b7ac03..bafd7ac 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -409,28 +409,28 @@ class RegsTest(DeleteServer):
class DownloadTest(DeleteServer):
def setUp(self):
length = min(2**20, target.ram_size - 2048)
- fd = file("download.c", "w")
- fd.write("#include <stdint.h>\n")
- fd.write("unsigned int crc32a(uint8_t *message, unsigned int size);\n")
- fd.write("uint32_t length = %d;\n" % length)
- fd.write("uint8_t d[%d] = {\n" % length)
+ download_c = tempfile.NamedTemporaryFile(prefix="download_", suffix=".c")
+ download_c.write("#include <stdint.h>\n")
+ download_c.write("unsigned int crc32a(uint8_t *message, unsigned int size);\n")
+ download_c.write("uint32_t length = %d;\n" % length)
+ download_c.write("uint8_t d[%d] = {\n" % length)
self.crc = 0
for i in range(length / 16):
- fd.write(" /* 0x%04x */ " % (i * 16));
+ download_c.write(" /* 0x%04x */ " % (i * 16));
for _ in range(16):
value = random.randrange(1<<8)
- fd.write("%d, " % value)
+ download_c.write("%d, " % value)
self.crc = binascii.crc32("%c" % value, self.crc)
- fd.write("\n");
- fd.write("};\n");
- fd.write("uint8_t *data = &d[0];\n");
- fd.write("uint32_t main() { return crc32a(data, length); }\n")
- fd.close()
+ download_c.write("\n");
+ download_c.write("};\n");
+ download_c.write("uint8_t *data = &d[0];\n");
+ download_c.write("uint32_t main() { return crc32a(data, length); }\n")
+ download_c.flush()
if self.crc < 0:
self.crc += 2**32
- self.binary = target.compile("download.c", "programs/checksum.c")
+ self.binary = target.compile(download_c.name, "programs/checksum.c")
self.server = target.server()
self.gdb = testlib.Gdb()
self.gdb.command("file %s" % self.binary)
@@ -466,12 +466,22 @@ class Target(object):
raise NotImplementedError
def compile(self, *sources):
- return testlib.compile(sources +
+ binary_name = "%s_%s" % (
+ self.name,
+ os.path.basename(os.path.splitext(sources[0])[0]))
+ if parsed.isolate:
+ self.temporary_binary = tempfile.NamedTemporaryFile(
+ prefix=binary_name + "_")
+ binary_name = self.temporary_binary.name
+ testlib.compile(sources +
("programs/entry.S", "programs/init.c",
"-I", "../env",
"-T", "targets/%s/link.lds" % (self.directory or self.name),
"-nostartfiles",
- "-mcmodel=medany"), xlen=self.xlen)
+ "-mcmodel=medany",
+ "-o", binary_name),
+ xlen=self.xlen)
+ return binary_name
class Spike64Target(Target):
name = "spike"
@@ -526,6 +536,10 @@ def main():
dest="target")
parser.add_argument("--cmd",
help="The command to use to start the debug server.")
+ parser.add_argument("--isolate", action="store_true",
+ help="Try to run in such a way that multiple instances can run at "
+ "the same time. This may make it harder to debug a failure if it "
+ "does occur.")
parser.add_argument("unittest", nargs="*")
global parsed
parsed = parser.parse_args()
diff --git a/debug/testlib.py b/debug/testlib.py
index e9b17d0..5e7f366 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -17,10 +17,8 @@ def find_file(path):
return None
def compile(args, xlen=32):
- """Compile a single .c file into a binary."""
- dst = os.path.splitext(args[0])[0]
cc = os.path.expandvars("$RISCV/bin/riscv%d-unknown-elf-gcc" % xlen)
- cmd = [cc, "-g", "-o", dst]
+ cmd = [cc, "-g"]
for arg in args:
found = find_file(arg)
if found:
@@ -30,7 +28,6 @@ def compile(args, xlen=32):
cmd = " ".join(cmd)
result = os.system(cmd)
assert result == 0, "%r failed" % cmd
- return dst
def unused_port():
# http://stackoverflow.com/questions/2838244/get-open-tcp-port-in-python/2838309#2838309