#!/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
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)
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()
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()
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()
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")
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."""
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