aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-05-05 17:40:02 -0700
committerTim Newsome <tim@sifive.com>2016-05-23 12:12:12 -0700
commit7e5c1b420d0b332d6663a47182f9a472e400f663 (patch)
tree0fe48621d4111db49252522ade4bc3a14ac25905 /tests
parentf3c39b00ca73f19b3e9685b06afd7107f338ffa2 (diff)
downloadspike-7e5c1b420d0b332d6663a47182f9a472e400f663.zip
spike-7e5c1b420d0b332d6663a47182f9a472e400f663.tar.gz
spike-7e5c1b420d0b332d6663a47182f9a472e400f663.tar.bz2
Halt when gdb user hits ^C.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/gdbserver.py19
-rw-r--r--tests/testlib.py11
2 files changed, 29 insertions, 1 deletions
diff --git a/tests/gdbserver.py b/tests/gdbserver.py
index ac191d5..2979606 100755
--- a/tests/gdbserver.py
+++ b/tests/gdbserver.py
@@ -13,7 +13,6 @@ class DebugTest(unittest.TestCase):
self.gdb = testlib.Gdb()
self.gdb.command("file %s" % self.binary)
self.gdb.command("target extended-remote localhost:%d" % self.port)
- self.gdb.command("p i=0");
def tearDown(self):
self.spike.kill()
@@ -21,6 +20,7 @@ class DebugTest(unittest.TestCase):
def test_turbostep(self):
"""Single step a bunch of times."""
+ self.gdb.command("p i=0");
last_pc = None
for _ in range(100):
self.gdb.command("stepi")
@@ -29,11 +29,13 @@ class DebugTest(unittest.TestCase):
last_pc = pc
def test_exit(self):
+ self.gdb.command("p i=0");
output = self.gdb.command("c")
self.assertIn("Continuing", output)
self.assertIn("Remote connection closed", output)
def test_breakpoint(self):
+ self.gdb.command("p i=0");
self.gdb.command("b print_row")
# The breakpoint should be hit exactly 10 times.
for i in range(10):
@@ -46,6 +48,7 @@ class DebugTest(unittest.TestCase):
self.assertIn("Remote connection closed", output)
def test_registers(self):
+ self.gdb.command("p i=0");
# Try both forms to test gdb.
for cmd in ("info all-registers", "info registers all"):
output = self.gdb.command(cmd)
@@ -66,6 +69,20 @@ class DebugTest(unittest.TestCase):
last_instret = instret
self.gdb.command("stepi")
+ def test_interrupt(self):
+ """Sending gdb ^C while the program is running should cause it to halt."""
+ self.gdb.c(wait=False)
+ time.sleep(0.1)
+ self.gdb.interrupt()
+ self.gdb.command("p i=123");
+ self.gdb.c(wait=False)
+ time.sleep(0.1)
+ self.gdb.interrupt()
+ self.gdb.command("p i=0");
+ output = self.gdb.c()
+ self.assertIn("Continuing", output)
+ self.assertIn("Remote connection closed", output)
+
class RegsTest(unittest.TestCase):
def setUp(self):
self.binary = testlib.compile("regs.s")
diff --git a/tests/testlib.py b/tests/testlib.py
index 4e05616..6233901 100644
--- a/tests/testlib.py
+++ b/tests/testlib.py
@@ -74,6 +74,17 @@ class Gdb(object):
self.child.expect("\(gdb\)")
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)