add case-based expected results in addme alu_cases
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 11 Nov 2021 11:30:03 +0000 (11:30 +0000)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Thu, 11 Nov 2021 11:30:03 +0000 (11:30 +0000)
creates the expected results based on conditions in the choices and values

src/openpower/test/alu/alu_cases.py

index 26a03aae4c8fd2252b3843200d250d8748e32b27..0e57a6ee051d2b75be7ddb5d4ccf6d3e6d44a306 100644 (file)
@@ -89,10 +89,26 @@ class ALUTestCase(TestAccumulatorBase):
                 initial_regs[16] = value
                 initial_sprs = {}
                 xer = SelectableInt(0, 64)
-                xer[XER_bits['CA']] = 0
+                xer[XER_bits['CA']] = 0  # input carry is 0 (see test below)
                 initial_sprs[special_sprs['XER']] = xer
+
+                # create expected results.  pc should be 4 (one instruction)
+                e = ExpectedState(pc=4)
+                # input value should not be modified
+                e.intregs[16] = value
+                # carry-out should always occur
+                e.ca = 0x3
+                # create output value
+                if value == 0x7ffffffff:
+                    e.intregs[6] = 0x7fffffffe
+                else:
+                    e.intregs[6] = 0xffff7ffff
+                # CR version needs an expected CR
+                if '.' in choice:
+                    e.crregs[0] = 0x4
                 self.add_case(Program(lst, bigendian),
-                              initial_regs, initial_sprs)
+                              initial_regs, initial_sprs,
+                              expected=e)
 
     def case_addme_ca_1(self):
         insns = ["addme", "addme.", "addmeo", "addmeo."]
@@ -104,7 +120,7 @@ class ALUTestCase(TestAccumulatorBase):
                 initial_regs[16] = value
                 initial_sprs = {}
                 xer = SelectableInt(0, 64)
-                xer[XER_bits['CA']] = 1
+                xer[XER_bits['CA']] = 1 # input carry is 1 (differs from above)
                 initial_sprs[special_sprs['XER']] = xer
                 self.add_case(Program(lst, bigendian),
                               initial_regs, initial_sprs)