about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/expression/expression_helper.py44
-rw-r--r--test/test_all.py2
2 files changed, 45 insertions, 1 deletions
diff --git a/test/expression/expression_helper.py b/test/expression/expression_helper.py
index 3ff6f5da..514a9a51 100644
--- a/test/expression/expression_helper.py
+++ b/test/expression/expression_helper.py
@@ -30,11 +30,55 @@ class TestExpressionExpressionHelper(unittest.TestCase):
 
         # Test the result
         new_expr = vi.equation
+
         ## Force replace in the variable dependency order
         for var_id, var_value in reversed(vi.vars.items()):
             new_expr = new_expr.replace_expr({var_id: var_value})
         self.assertEqual(exprf, new_expr)
 
+        # Test prefix
+        vi = Variables_Identifier(exprf, var_prefix="prefix_v")
+
+        ## Use __str__
+        print vi
+
+        ## Test the result
+        new_expr = vi.equation
+        ### Force replace in the variable dependency order
+        for var_id, var_value in reversed(vi.vars.items()):
+            new_expr = new_expr.replace_expr({var_id: var_value})
+        self.assertEqual(exprf, new_expr)
+
+        # Test an identify on an expression already containing identifier
+        vi = Variables_Identifier(exprf)
+        vi2 = Variables_Identifier(vi.equation)
+
+        ## Test the result
+        new_expr = vi2.equation
+        ### Force replace in the variable dependency order
+        for var_id, var_value in reversed(vi2.vars.items()):
+            new_expr = new_expr.replace_expr({var_id: var_value})
+        self.assertEqual(vi.equation, new_expr)
+
+        ## Corner case: each sub var depends on itself
+        mem1 = m2_expr.ExprMem(ebx, size=32)
+        mem2 = m2_expr.ExprMem(mem1, size=32)
+        cst2 = m2_expr.ExprInt32(-1)
+        expr_mini = ((eax ^ mem2 ^ cst2) & (mem2 ^ (eax + mem2)))[31:32]
+
+        ## Build
+        vi = Variables_Identifier(expr_mini)
+        vi2 = Variables_Identifier(vi.equation)
+
+        ## Test the result
+        new_expr = vi2.equation
+        ### Force replace in the variable dependency order
+        for var_id, var_value in reversed(vi2.vars.items()):
+            new_expr = new_expr.replace_expr({var_id: var_value})
+        self.assertEqual(vi.equation, new_expr)
+
+
+
 if __name__ == '__main__':
     testcase = TestExpressionExpressionHelper
     testsuite = unittest.TestLoader().loadTestsFromTestCase(testcase)
diff --git a/test/test_all.py b/test/test_all.py
index 5de12bf4..66620375 100644
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -120,7 +120,7 @@ class ExampleShellcode(ExampleAssembler):
 testset += ExampleShellcode(['x86_32', 'x86_32_manip_ptr.S', "demo_x86_32.bin"])
 
 test_box = {}
-test_box_names = ["mod", "mod_self", "repmod", "simple", "enc"]
+test_box_names = ["mod", "mod_self", "repmod", "simple", "enc", "pop_esp"]
 for source in test_box_names:
     sample_base = "x86_32_" + source
     args = ["x86_32", sample_base + ".S", sample_base + ".bin", "--PE"]