aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2016-09-20 09:47:11 -0700
committerTim Newsome <tim@sifive.com>2016-09-20 09:47:11 -0700
commit923f62fc1dec4244180c00e0b1f8a845aeaa90e8 (patch)
treeb9a40632978925d606590bdb0b802efcf295594a
parentce10cc711f00df9fc97df39094c1cddd49ae212e (diff)
downloadriscv-tests-923f62fc1dec4244180c00e0b1f8a845aeaa90e8.zip
riscv-tests-923f62fc1dec4244180c00e0b1f8a845aeaa90e8.tar.gz
riscv-tests-923f62fc1dec4244180c00e0b1f8a845aeaa90e8.tar.bz2
Minor tweaks to trigger tests for openocd.
-rwxr-xr-xdebug/gdbserver.py25
-rw-r--r--debug/testlib.py1
2 files changed, 16 insertions, 10 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index 75ab292..bb82c4b 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -1,12 +1,13 @@
#!/usr/bin/env python
+import argparse
+import binascii
import os
+import random
+import re
import sys
-import argparse
import tempfile
import time
-import random
-import binascii
import traceback
import testlib
@@ -223,6 +224,10 @@ def assertTrue(a):
if not a:
raise TestFailed("%r is not True" % a)
+def assertRegexpMatches(text, regexp):
+ if not re.search(regexp, text):
+ raise TestFailed("can't find %r in %r" % (regexp, text))
+
class SimpleRegisterTest(GdbTest):
def check_reg(self, name):
a = random.randrange(1<<self.target.xlen)
@@ -428,7 +433,7 @@ class Hwbp1(DebugTest):
for _ in range(2):
output = self.gdb.c()
self.gdb.p("$pc")
- assertIn("Breakpoint ", output)
+ assertRegexpMatches(output, r"[bB]reakpoint")
assertIn("rot13 ", output)
self.exit()
@@ -443,7 +448,7 @@ class Hwbp2(DebugTest):
for expected in ("main", "rot13", "rot13"):
output = self.gdb.c()
self.gdb.p("$pc")
- assertIn("Breakpoint ", output)
+ assertRegexpMatches(output, r"[bB]reakpoint")
assertIn("%s " % expected, output)
self.exit()
@@ -534,9 +539,9 @@ class TriggerTest(GdbTest):
assertIn("_exit", output)
class TriggerExecuteInstant(TriggerTest):
+ """Test an execute breakpoint on the first instruction executed out of
+ debug mode."""
def test(self):
- """Test an execute breakpoint on the first instruction executed out of
- debug mode."""
main_address = self.gdb.p("$pc")
self.gdb.command("hbreak *0x%x" % (main_address + 4))
self.gdb.c()
@@ -552,9 +557,9 @@ class TriggerLoadAddress(TriggerTest):
self.exit()
class TriggerLoadAddressInstant(TriggerTest):
+ """Test a load address breakpoint on the first instruction executed out of
+ debug mode."""
def test(self):
- """Test a load address breakpoint on the first instruction executed out
- of debug mode."""
self.gdb.command("b just_before_read_loop")
self.gdb.c()
read_loop = self.gdb.p("&read_loop")
@@ -573,7 +578,7 @@ class TriggerStoreAddress(TriggerTest):
self.gdb.p("(&data)+3"))
self.exit()
-class TriggerStoreAddressInstance(TriggerTest):
+class TriggerStoreAddressInstant(TriggerTest):
def test(self):
"""Test a store address breakpoint on the first instruction executed out
of debug mode."""
diff --git a/debug/testlib.py b/debug/testlib.py
index 0e504d1..987d71e 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -130,6 +130,7 @@ class Openocd(object):
cmd.append("-d")
logfile = open(Openocd.logname, "w")
logfile.write("+ %s\n" % " ".join(cmd))
+ logfile.flush()
self.process = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=logfile, stderr=logfile)
# TODO: Pick a random port