From: klehman Date: Tue, 21 Sep 2021 18:08:19 +0000 (-0400) Subject: added teststate_check_mem X-Git-Tag: sv_maxu_works-initial~853 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c4cbf72541f8f8ff7e9ec5191d1ed321a4f89d5;p=openpower-isa.git added teststate_check_mem --- diff --git a/src/openpower/test/state.py b/src/openpower/test/state.py index d7886fe8..95f57ef8 100644 --- a/src/openpower/test/state.py +++ b/src/openpower/test/state.py @@ -67,11 +67,9 @@ class State: (self.state_type, s2.state_type, repr(self.code))) def compare_mem(self, s2): - for i, (self.mem, s2.mem) in enumerate( - zip(self.mem, s2.mem)): - self.dut.assertEqual(self.mem, s2.mem, - "mem mismatch %s %d %s %s" % (self.code, i, - self.mem, s2.mem)) + for i in self.mem: + self.dut.assertEqual(self.mem[i], s2.mem[i], + "mem mismatch location %d %s" % (i, self.code)) class SimState(State): @@ -195,3 +193,18 @@ def teststate_check_regs(dut, states, test, code): state, against = slist[i], slist[i+1] state.compare(against) + +def teststate_check_mem(dut, states, test, code): + """teststate_check_mem: compares a set of Power ISA objects + to check if they have the same "state" (memory) + """ + slist = [] + # create one TestState per "thing" + for stype, totest in states.items(): + state = yield from TestState(stype, totest, dut, code) + slist.append(state) + # compare each "thing" against the next "thing" in the list. + # (no need to do an O(N^2) comparison here, they *all* have to be the same + for i in range(len(slist)-1): + state, against = slist[i], slist[i+1] + state.compare_mem(against)