about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2016-12-15 14:45:34 +0100
committerAjax <commial@gmail.com>2016-12-15 14:45:34 +0100
commitc72b9052db4bb1ee596ee3d05ef49f9f7d71f5c1 (patch)
tree22771fa3ac3393edb0be7560f1f2c46f7b5dc8f1 /test
parent50661f59da48540a6d87ab5f42c41e761a9c11d8 (diff)
downloadmiasm-c72b9052db4bb1ee596ee3d05ef49f9f7d71f5c1.tar.gz
miasm-c72b9052db4bb1ee596ee3d05ef49f9f7d71f5c1.zip
Regression test for apply_expr/apply_change/eval_ir
Diffstat (limited to 'test')
-rw-r--r--test/ir/symbexec.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ir/symbexec.py b/test/ir/symbexec.py
index 6df0bbc3..24b02341 100644
--- a/test/ir/symbexec.py
+++ b/test/ir/symbexec.py
@@ -11,6 +11,7 @@ class TestSymbExec(unittest.TestCase):
             ExprCompose, ExprAff
         from miasm2.arch.x86.sem import ir_x86_32
         from miasm2.ir.symbexec import symbexec
+        from miasm2.ir.ir import AssignBlock
 
         addrX = ExprInt32(-1)
         addr0 = ExprInt32(0)
@@ -59,6 +60,22 @@ class TestSymbExec(unittest.TestCase):
         self.assertEqual(e.apply_expr(ExprAff(id_eax, addr9)), addr9)
         self.assertEqual(e.apply_expr(id_eax), addr9)
 
+        # apply_change / eval_ir / apply_expr
+
+        ## x = a (with a = 0x0)
+        assignblk = AssignBlock()
+        assignblk[id_x] = id_a
+        e.eval_ir(assignblk)
+        self.assertEqual(e.apply_expr(id_x), addr0)
+
+        ## x = a (without replacing 'a' with 0x0)
+        e.apply_change(id_x, id_a)
+        self.assertEqual(e.apply_expr(id_x), id_a)
+
+        ## x = a (with a = 0x0)
+        self.assertEqual(e.apply_expr(assignblk.dst2ExprAff(id_x)), addr0)
+        self.assertEqual(e.apply_expr(id_x), addr0)
+
 if __name__ == '__main__':
     testsuite = unittest.TestLoader().loadTestsFromTestCase(TestSymbExec)
     report = unittest.TextTestRunner(verbosity=2).run(testsuite)