diff options
author | Tim Newsome <tim@sifive.com> | 2018-05-21 11:56:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 11:56:39 -0700 |
commit | 73a4ba0b3a218f31b2e1db9c438a13c951d640a3 (patch) | |
tree | ebd2c72fb4349774cc32b2611d4d58f048de7b72 | |
parent | f9db9282d7db202dc6bd5e29f4745d9932292ac4 (diff) | |
parent | 016147c6167f714c95dbfe9d99d6b983e6202507 (diff) | |
download | riscv-tests-73a4ba0b3a218f31b2e1db9c438a13c951d640a3.zip riscv-tests-73a4ba0b3a218f31b2e1db9c438a13c951d640a3.tar.gz riscv-tests-73a4ba0b3a218f31b2e1db9c438a13c951d640a3.tar.bz2 |
Merge pull request #141 from riscv/mrhstest
Fix MulticoreRunHaltStepiTest
-rwxr-xr-x | debug/gdbserver.py | 56 | ||||
-rw-r--r-- | debug/testlib.py | 13 |
2 files changed, 46 insertions, 23 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py index be89d19..257f8d4 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -562,30 +562,48 @@ class MulticoreRunHaltStepiTest(GdbTest): self.gdb.load() for hart in self.target.harts: self.gdb.select_hart(hart) + self.gdb.p("$mhartid") self.gdb.p("$pc=_start") def test(self): previous_hart_count = [0 for h in self.target.harts] previous_interrupt_count = [0 for h in self.target.harts] - for _ in range(10): - self.gdb.c(wait=False) - time.sleep(2) - self.gdb.interrupt() - self.gdb.p("$mie") - self.gdb.p("$mip") - self.gdb.p("$mstatus") - self.gdb.p("$priv") - self.gdb.p("buf", fmt="") - hart_count = self.gdb.p("hart_count") - interrupt_count = self.gdb.p("interrupt_count") - for i, h in enumerate(self.target.harts): - assertGreater(hart_count[i], previous_hart_count[i]) - assertGreater(interrupt_count[i], previous_interrupt_count[i]) - self.gdb.select_hart(h) - pc = self.gdb.p("$pc") - self.gdb.stepi() - stepped_pc = self.gdb.p("$pc") - assertNotEqual(pc, stepped_pc) + # Check 10 times + for i in range(10): + # 3 attempts for each time we want the check to pass + for attempt in range(3): + self.gdb.global_command("echo round %d attempt %d\\n" % (i, + attempt)) + self.gdb.c_all(wait=False) + time.sleep(2) + self.gdb.interrupt_all() + hart_count = self.gdb.p("hart_count") + interrupt_count = self.gdb.p("interrupt_count") + ok = True + for i, h in enumerate(self.target.harts): + if hart_count[i] <= previous_hart_count[i]: + ok = False + break + if interrupt_count[i] <= previous_interrupt_count[i]: + ok = False + break + self.gdb.p("$mie") + self.gdb.p("$mip") + self.gdb.p("$mstatus") + self.gdb.p("$priv") + self.gdb.p("buf", fmt="") + self.gdb.select_hart(h) + pc = self.gdb.p("$pc") + self.gdb.stepi() + stepped_pc = self.gdb.p("$pc") + assertNotEqual(pc, stepped_pc) + previous_hart_count = hart_count + previous_interrupt_count = interrupt_count + if ok: + break + else: + assert False, \ + "hart count or interrupt didn't increment as expected" class MulticoreRunAllHaltOne(GdbTest): compile_args = ("programs/multicore.c", "-DMULTICORE") diff --git a/debug/testlib.py b/debug/testlib.py index fb5bee3..2fd978c 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -477,7 +477,7 @@ class Gdb(object): self.active_child.sendline("c%s" % async) self.active_child.expect("Continuing", timeout=ops * self.timeout) - def c_all(self): + def c_all(self, wait=True): """ Resume every hart. @@ -494,15 +494,20 @@ class Gdb(object): child.sendline("c") child.expect("Continuing") - # Now wait for them all to halt - for child in self.children: - child.expect(r"\(gdb\)") + if wait: + for child in self.children: + child.expect(r"\(gdb\)") def interrupt(self): self.active_child.send("\003") self.active_child.expect(r"\(gdb\)", timeout=6000) return self.active_child.before.strip() + def interrupt_all(self): + for child in self.children: + self.select_child(child) + self.interrupt() + def x(self, address, size='w'): output = self.command("x/%s %s" % (size, address)) value = int(output.split(':')[1].strip(), 0) |