Skip to content

Commit

Permalink
delete PMP configs
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:PAN-Ziyue/riscv-tests
  • Loading branch information
PAN-Ziyue committed Nov 15, 2021
2 parents 08ce4ed + 709a478 commit e0b0986
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 33 deletions.
21 changes: 20 additions & 1 deletion debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,21 @@ class MemTestBlock2(MemTestBlock):
def test(self):
return self.test_block(2)

class DisconnectTest(GdbTest):
def test(self):
old_values = self.gdb.info_registers("all", ops=20)
self.gdb.disconnect()
self.gdb.connect()
self.gdb.select_hart(self.hart)
new_values = self.gdb.info_registers("all", ops=20)

regnames = set(old_values.keys()).union(set(new_values.keys()))
for regname in regnames:
if regname in ("mcycle", "minstret", "instret", "cycle"):
continue
assertEqual(old_values[regname], new_values[regname],
"Register %s didn't match" % regname)

class InstantHaltTest(GdbTest):
def test(self):
"""Assert that reset is really resetting what it should."""
Expand Down Expand Up @@ -553,7 +568,9 @@ def test(self):
last_pc = None
advances = 0
jumps = 0
for _ in range(10):
start = time.time()
count = 10
for _ in range(count):
self.gdb.stepi()
pc = self.gdb.p("$pc")
assertNotEqual(last_pc, pc)
Expand All @@ -562,6 +579,8 @@ def test(self):
else:
jumps += 1
last_pc = pc
end = time.time()
print("%.2f seconds/step" % ((end - start) / count))
# Some basic sanity that we're not running between breakpoints or
# something.
assertGreater(jumps, 1)
Expand Down
2 changes: 2 additions & 0 deletions debug/targets/RISC-V/spike-2-hwthread.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ foreach t [target names] {
riscv expose_custom 1,12345-12348
}

riscv resume_order reversed

init

set challenge [riscv authdata_read]
Expand Down
70 changes: 38 additions & 32 deletions debug/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,6 @@ def __init__(self, target, ports, cmd=None, timeout=60, binaries=None):
child.logfile = logfile
child.logfile.write(("+ %s\n" % self.cmd).encode())
self.children.append(child)
self.active_child = self.children[0]

def connect(self):
for port, child, binary in zip(self.ports, self.children,
self.binaries):
self.select_child(child)
self.wait()
self.command("set style enabled off", reset_delays=None)
Expand All @@ -599,28 +594,42 @@ def connect(self):
# Force consistency.
self.command("set print entry-values no", reset_delays=None)
self.command("set remotetimeout %d" % self.timeout,
reset_delays=None)
self.command("target extended-remote localhost:%d" % port, ops=10,
reset_delays=None)
if binary:
output = self.command("file %s" % binary)
assertIn("Reading symbols", output)
threads = self.threads()
for t in threads:
hartid = None
if t.name:
m = re.search(r"Hart (\d+)", t.name)
if m:
hartid = int(m.group(1))
if hartid is None:
if self.harts:
hartid = max(self.harts) + 1
else:
hartid = 0
# solo: True iff this is the only thread on this child
self.harts[hartid] = {'child': child,
'thread': t,
'solo': len(threads) == 1}
reset_delays=None)
self.command("set remotetimeout %d" % self.target.timeout_sec)
self.active_child = self.children[0]

def connect(self):
with PrivateState(self):
for port, child, binary in zip(self.ports, self.children,
self.binaries):
self.select_child(child)
self.command("target extended-remote localhost:%d" % port,
ops=10, reset_delays=None)
if binary:
output = self.command("file %s" % binary)
assertIn("Reading symbols", output)
threads = self.threads()
for t in threads:
hartid = None
if t.name:
m = re.search(r"Hart (\d+)", t.name)
if m:
hartid = int(m.group(1))
if hartid is None:
if self.harts:
hartid = max(self.harts) + 1
else:
hartid = 0
# solo: True iff this is the only thread on this child
self.harts[hartid] = {'child': child,
'thread': t,
'solo': len(threads) == 1}

def disconnect(self):
with PrivateState(self):
for child in self.children:
self.select_child(child)
self.command("disconnect")

def __del__(self):
for child in self.children:
Expand Down Expand Up @@ -1143,9 +1152,6 @@ def classSetup(self):
self.logs += self.gdb.lognames()
self.gdb.connect()

self.gdb.global_command("set remotetimeout %d" %
self.target.timeout_sec)

for cmd in self.target.gdb_setup:
self.gdb.command(cmd)

Expand Down Expand Up @@ -1236,9 +1242,9 @@ def __init__(self, message=""):
Exception.__init__(self)
self.message = message

def assertEqual(a, b):
def assertEqual(a, b, comment=None):
if a != b:
raise TestFailed("%r != %r" % (a, b))
raise TestFailed("%r != %r" % (a, b), comment)

def assertNotEqual(a, b, comment=None):
if a == b:
Expand Down

0 comments on commit e0b0986

Please sign in to comment.