moving teststate_check_regs written by klehman into openpower-isa
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 16 Sep 2021 16:06:27 +0000 (17:06 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 16 Sep 2021 16:06:27 +0000 (17:06 +0100)
src/openpower/test/state.py

index 31721d14b18a14c5be8e2fa51320090581585ad2..a4d62fc390a1fedf263f38c120b9e967c2e3b8c9 100644 (file)
@@ -155,3 +155,20 @@ def TestState(state_type, to_test, dut, code):
     state.code = code
     yield from state.get_state()
     return state
+
+
+def teststate_check_regs(dut, states, test, code):
+    """teststate_check_regs: compares a set of Power ISA objects
+    to check if they have the same "state" (registers only, at the moment)
+    """
+    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(against)
+