diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/arch/x86/unit/asm_test.py | 10 | ||||
| -rw-r--r-- | test/arch/x86/unit/mn_div.py | 17 | ||||
| -rw-r--r-- | test/expression/parser.py | 16 | ||||
| -rwxr-xr-x | test/test_all.py | 3 |
4 files changed, 46 insertions, 0 deletions
diff --git a/test/arch/x86/unit/asm_test.py b/test/arch/x86/unit/asm_test.py index aba47df1..8a6b215c 100644 --- a/test/arch/x86/unit/asm_test.py +++ b/test/arch/x86/unit/asm_test.py @@ -90,3 +90,13 @@ class Asm_Test_16(Asm_Test): self.myjit.vm.add_memory_page(self.run_addr, PAGE_READ | PAGE_WRITE, self.assembly) self.myjit.push_uint16_t(self.ret_addr) self.myjit.add_breakpoint(self.ret_addr, lambda x:False) + +class Asm_Test_64(Asm_Test): + arch_name = "x86_64" + arch_attrib = 64 + ret_addr = 0x1337beef + + def init_machine(self): + self.myjit.vm.add_memory_page(self.run_addr, PAGE_READ | PAGE_WRITE, self.assembly) + self.myjit.push_uint64_t(self.ret_addr) + self.myjit.add_breakpoint(self.ret_addr, lambda x:False) diff --git a/test/arch/x86/unit/mn_div.py b/test/arch/x86/unit/mn_div.py new file mode 100644 index 00000000..84569607 --- /dev/null +++ b/test/arch/x86/unit/mn_div.py @@ -0,0 +1,17 @@ +import sys +from asm_test import Asm_Test_64 + +class Test_DIV(Asm_Test_64): + TXT = ''' +main: + MOV RAX, 0x8877665544332211 + MOV RBX, 0x11223344556677 + DIV RBX + RET + ''' + def check(self): + assert self.myjit.cpu.RAX == 0x7F7 + assert self.myjit.cpu.RDX == 0x440 + +if __name__ == "__main__": + [test(*sys.argv[1:])() for test in [Test_DIV]] diff --git a/test/expression/parser.py b/test/expression/parser.py new file mode 100644 index 00000000..9c01c8a1 --- /dev/null +++ b/test/expression/parser.py @@ -0,0 +1,16 @@ +from miasm2.expression.parser import str_to_expr +from miasm2.expression.expression import ExprInt, ExprId, ExprSlice, ExprMem, \ + ExprCond, ExprCompose, ExprOp, ExprAff + +for expr_test in [ExprInt(0x12, 32), + ExprId('test', 32), + ExprSlice(ExprInt(0x10, 32), 0, 8), + ExprMem(ExprInt(0x10, 32), 32), + ExprCond(ExprInt(0x10, 32), ExprInt(0x11, 32), ExprInt(0x12, 32)), + ExprCompose(ExprInt(0x10, 16), ExprInt(0x11, 8), ExprInt(0x12, 8)), + ExprInt(0x11, 8) + ExprInt(0x12, 8), + ExprAff(ExprId('EAX', 32), ExprInt(0x12, 32)), + ]: + + print 'Test: %s' % expr_test + assert str_to_expr(repr(expr_test)) == expr_test diff --git a/test/test_all.py b/test/test_all.py index 41954ff1..3da2dbb5 100755 --- a/test/test_all.py +++ b/test/test_all.py @@ -60,6 +60,7 @@ class ArchUnitTest(RegressionTest): # script -> blacklisted jitter blacklist = { "x86/unit/mn_float.py": ["python", "llvm"], + "x86/unit/mn_div.py": ["tcc", "gcc"], } for script in ["x86/sem.py", "x86/unit/mn_strings.py", @@ -80,6 +81,7 @@ for script in ["x86/sem.py", "x86/unit/mn_pushpop.py", "x86/unit/mn_seh.py", "x86/unit/mn_cpuid.py", + "x86/unit/mn_div.py", "arm/arch.py", "arm/sem.py", "aarch64/unit/mn_ubfm.py", @@ -241,6 +243,7 @@ for script in ["modint.py", "simplifications.py", "expression_helper.py", "expr_pickle.py", + "parser.py", ]: testset += RegressionTest([script], base_dir="expression") |