Пример #1
0
 def check(self, state, memory=[]):
     """Check all registers and flags against an expected state.
     """
     for index, expected in self.expected_registers:
         got = state.rf[index]
         if index > 63:
             reg_name = (key for key, value in reg_map.items() if value==index).next()
         else:
             reg_name = index
         if expected != got:
             raise ValueError("Register %s differs. Expected: %s got: %s" %
                              (reg_name, expected, got))
     self.check_flags(state)
     self.check_memory(memory, state)
Пример #2
0
 def fp_check(self, state, memory=[]):
     """Check all registers and flags against an expected state.
     For registers, convert the contents to a Python float and check that
     the state and expected state do not differ by more than self.epsilon.
     """
     for index, expected in self.expected_registers:
         got = state.rf[index]
         if index > 63:
             reg_name = (key for key, value in reg_map.items() if value==index).next()
         else:
             reg_name = index
         if abs(bits2float(expected) - bits2float(got)) > self.epsilon:
             raise ValueError("Register %s differs by more than %.4f. Expected: %s got: %s" %
                              (reg_name, self.epsilon,
                               bits2float(expected), bits2float(got)))
     self.check_flags(state)
     self.check_memory(memory, state)