Add tests for virtual priv register.
[riscv-tests.git] / debug / testlib.py
index 3339e9b49a88afaf22538f7029ce5e87c48577aa..b3f8f66a822f8529973fa5a46b89f4beba2da52c 100644 (file)
@@ -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
@@ -65,6 +62,7 @@ class Spike(object):
             cmd.append(binary)
         logfile = open("spike.log", "w")
         logfile.write("+ %s\n" % " ".join(cmd))
+        logfile.flush()
         self.process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=logfile,
                 stderr=logfile)
 
@@ -104,10 +102,10 @@ class Openocd(object):
 
 class Gdb(object):
     def __init__(self,
-            path=os.path.expandvars("$RISCV/bin/riscv64-unknown-elf-gdb")):
-        self.child = pexpect.spawn(path)
+            cmd=os.path.expandvars("$RISCV/bin/riscv64-unknown-elf-gdb")):
+        self.child = pexpect.spawn(cmd)
         self.child.logfile = file("gdb.log", "w")
-        self.child.logfile.write("+ %s\n" % path)
+        self.child.logfile.write("+ %s\n" % cmd)
         self.wait()
         self.command("set confirm off")
         self.command("set width 0")