made mem sizes equal for compare purposes
authorklehman <klehman9@comcast.net>
Wed, 22 Sep 2021 13:44:28 +0000 (09:44 -0400)
committerklehman <klehman9@comcast.net>
Wed, 22 Sep 2021 13:44:28 +0000 (09:44 -0400)
src/openpower/test/state.py

index 95f57ef8d7aff56d5f3b2b856a3d32f3aefd6599..0e4b78af9d08e27f706406c5e9c9ce23ed4207b7 100644 (file)
@@ -67,8 +67,14 @@ class State:
             (self.state_type, s2.state_type, repr(self.code)))
 
     def compare_mem(self, s2):
-        for i in self.mem:
-            self.dut.assertEqual(self.mem[i], s2.mem[i],
+        # copy dics to preserve state mem then pad empty locs
+        s1mem, s2mem = self.mem.copy(), s2.mem.copy()
+        for i in set(self.mem).difference(set(s2.mem)):
+            s2mem[i] = 0
+        for i in set(s2.mem).difference(set(self.mem)):
+            s1mem[i] = 0
+        for i in s1mem:
+            self.dut.assertEqual(s1mem[i], s2mem[i],
                 "mem mismatch location %d %s" % (i, self.code))