aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2023-06-17 16:49:27 -0700
committerAndrew Waterman <andrew@sifive.com>2023-06-17 16:49:27 -0700
commit903ec29f902da41537411e210e7b6002eed7fb7e (patch)
tree8667b508844dee223d8b9544dcdd2a843beca3e5
parentc636ad356c3d5fd7d5ee565c59ab7bdc3f3852f5 (diff)
downloadriscv-isa-sim-903ec29f902da41537411e210e7b6002eed7fb7e.zip
riscv-isa-sim-903ec29f902da41537411e210e7b6002eed7fb7e.tar.gz
riscv-isa-sim-903ec29f902da41537411e210e7b6002eed7fb7e.tar.bz2
Remove legacy debug test
These are now tested in CI using the riscv-tests repository.
-rwxr-xr-xtests/ebreak.py26
-rw-r--r--tests/ebreak.s5
-rw-r--r--tests/testlib.py116
3 files changed, 0 insertions, 147 deletions
diff --git a/tests/ebreak.py b/tests/ebreak.py
deleted file mode 100755
index dd7e658..0000000
--- a/tests/ebreak.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/python
-
-import os
-import testlib
-import unittest
-import tempfile
-import time
-
-class EbreakTest(unittest.TestCase):
- def setUp(self):
- self.binary = testlib.compile("ebreak.s")
-
- def test_noport(self):
- """Make sure that we can run past ebreak when --gdb-port isn't used."""
- spike = testlib.Spike(self.binary, with_gdb=False, timeout=10)
- result = spike.wait()
- self.assertEqual(result, 0)
-
- def test_nogdb(self):
- """Make sure that we can run past ebreak when gdb isn't attached."""
- spike = testlib.Spike(self.binary, timeout=10)
- result = spike.wait()
- self.assertEqual(result, 0)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/ebreak.s b/tests/ebreak.s
deleted file mode 100644
index 99f3e07..0000000
--- a/tests/ebreak.s
+++ /dev/null
@@ -1,5 +0,0 @@
- .global main
-main:
- li a0, 0
- ebreak
- ret
diff --git a/tests/testlib.py b/tests/testlib.py
deleted file mode 100644
index d5e8d79..0000000
--- a/tests/testlib.py
+++ /dev/null
@@ -1,116 +0,0 @@
-import os.path
-import pexpect
-import subprocess
-import tempfile
-import testlib
-import unittest
-
-# Note that gdb comes with its own testsuite. I was unable to figure out how to
-# run that testsuite against the spike simulator.
-
-def find_file(path):
- for directory in (os.getcwd(), os.path.dirname(testlib.__file__)):
- fullpath = os.path.join(directory, path)
- if os.path.exists(fullpath):
- return fullpath
- return None
-
-def compile(*args):
- """Compile a single .c file into a binary."""
- dst = os.path.splitext(args[0])[0]
- cc = os.path.expandvars("$RISCV/bin/riscv64-unknown-elf-gcc")
- cmd = [cc, "-g", "-O", "-o", dst]
- for arg in args:
- found = find_file(arg)
- if found:
- cmd.append(found)
- else:
- cmd.append(arg)
- 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
- import socket
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.bind(("",0))
- port = s.getsockname()[1]
- s.close()
- return port
-
-class Spike(object):
- def __init__(self, binary, halted=False, with_gdb=True, timeout=None):
- """Launch spike. Return tuple of its process and the port it's running on."""
- cmd = []
- if timeout:
- cmd += ["timeout", str(timeout)]
-
- cmd += [find_file("spike")]
- if halted:
- cmd.append('-H')
- if with_gdb:
- self.port = unused_port()
- cmd += ['--gdb-port', str(self.port)]
- cmd.append('pk')
- if binary:
- cmd.append(binary)
- logfile = open("spike.log", "w")
- self.process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=logfile,
- stderr=logfile)
-
- def __del__(self):
- try:
- self.process.kill()
- self.process.wait()
- except OSError:
- pass
-
- def wait(self, *args, **kwargs):
- return self.process.wait(*args, **kwargs)
-
-class Gdb(object):
- def __init__(self):
- path = os.path.expandvars("$RISCV/bin/riscv64-unknown-elf-gdb")
- self.child = pexpect.spawn(path)
- self.child.logfile = file("gdb.log", "w")
- self.wait()
- self.command("set width 0")
- self.command("set height 0")
- # Force consistency.
- self.command("set print entry-values no")
-
- def wait(self):
- """Wait for prompt."""
- self.child.expect("\(gdb\)")
-
- def command(self, command, timeout=-1):
- self.child.sendline(command)
- self.child.expect("\n", timeout=timeout)
- self.child.expect("\(gdb\)", timeout=timeout)
- return self.child.before.strip()
-
- def c(self, wait=True):
- if wait:
- return self.command("c")
- else:
- self.child.sendline("c")
- self.child.expect("Continuing")
-
- def interrupt(self):
- self.child.send("\003");
- self.child.expect("\(gdb\)")
-
- def x(self, address, size='w'):
- output = self.command("x/%s %s" % (size, address))
- value = int(output.split(':')[1].strip(), 0)
- return value
-
- def p(self, obj):
- output = self.command("p %s" % obj)
- value = int(output.split('=')[-1].strip())
- return value
-
- def stepi(self):
- return self.command("stepi")