aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-03-23 16:14:50 -0700
committerTim Newsome <tim@sifive.com>2016-05-23 12:12:10 -0700
commit8571c8791ab141c70f7208acaa1a3edb1ce45a75 (patch)
tree31eefac44abeb574d2102e9cae62672e455c1143 /tests
parentfce39bd572bbbc5ff662f533f026398ea326b93b (diff)
downloadspike-8571c8791ab141c70f7208acaa1a3edb1ce45a75.zip
spike-8571c8791ab141c70f7208acaa1a3edb1ce45a75.tar.gz
spike-8571c8791ab141c70f7208acaa1a3edb1ce45a75.tar.bz2
Test ebreak without gdb.
Currently this test fails.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/ebreak.py21
-rw-r--r--tests/ebreak.s5
-rw-r--r--tests/testlib.py22
3 files changed, 42 insertions, 6 deletions
diff --git a/tests/ebreak.py b/tests/ebreak.py
new file mode 100755
index 0000000..6c3ffdb
--- /dev/null
+++ b/tests/ebreak.py
@@ -0,0 +1,21 @@
+#!/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_ebreak(self):
+ """Make sure that we can run past ebreak without halting when a
+ debugger isn't attached."""
+ spike = testlib.spike(self.binary, with_gdb=False, timeout=10)
+ result = spike.wait()
+ self.assertEqual(result, 0)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/ebreak.s b/tests/ebreak.s
new file mode 100644
index 0000000..99f3e07
--- /dev/null
+++ b/tests/ebreak.s
@@ -0,0 +1,5 @@
+ .global main
+main:
+ li a0, 0
+ ebreak
+ ret
diff --git a/tests/testlib.py b/tests/testlib.py
index 2db2549..4e05616 100644
--- a/tests/testlib.py
+++ b/tests/testlib.py
@@ -34,16 +34,26 @@ def unused_port():
s.close()
return port
-def spike(binary, halted=False):
+def spike(binary, halted=False, with_gdb=True, timeout=None):
"""Launch spike. Return tuple of its process and the port it's running on."""
- cmd = [find_file("spike")]
+ cmd = []
+ if timeout:
+ cmd += ["timeout", str(timeout)]
+
+ cmd += [find_file("spike")]
if halted:
cmd.append('-H')
- port = unused_port()
- cmd += ['--gdb-port', str(port), 'pk', binary]
+ if with_gdb:
+ port = unused_port()
+ cmd += ['--gdb-port', str(port)]
+ cmd += ['pk', binary]
logfile = open("spike.log", "w")
- return subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=logfile,
- stderr=logfile), port
+ process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=logfile,
+ stderr=logfile)
+ if with_gdb:
+ return process, port
+ else:
+ return process
class Gdb(object):
def __init__(self):