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/modint.py15
-rw-r--r--test/jitter/jit_options.py31
2 files changed, 29 insertions, 17 deletions
diff --git a/test/expression/modint.py b/test/expression/modint.py
index e7c19d0c..17c12907 100644
--- a/test/expression/modint.py
+++ b/test/expression/modint.py
@@ -8,7 +8,7 @@ d = uint1(0)
 e = uint1(1)
 
 f = uint8(0x1)
-
+g = int8(-3)
 
 print a, b, c
 print a + b, a + c, b + c
@@ -53,7 +53,20 @@ assert(f ^ f == 0)
 assert(f ^ 0 == f)
 assert(0 ^ f == f)
 assert(1 ^ f == 0)
+assert(c / g == -1)
+assert(c / -3 == -1)
+assert(c % g == 1)
+assert(c % -3 == 1)
 
 print e + c, c + e, c - e, e - c
 print 1000 * a
 print hex(a)
+
+define_int(128)
+define_uint(128)
+h = uint128(0x11223344556677889900AABBCCDDEEFF)
+i = int128(-0x9900AABBCCDDEEFF1122334455667788)
+
+assert(i / h == 6)
+assert(i % h == 0x3221aa32bb43cd58d9cc54dd65ee7e)
+
diff --git a/test/jitter/jit_options.py b/test/jitter/jit_options.py
index cc955c64..4fe936d5 100644
--- a/test/jitter/jit_options.py
+++ b/test/jitter/jit_options.py
@@ -5,18 +5,18 @@ from miasm2.analysis.machine import Machine
 from pdb import pm
 
 # Shellcode
-
 # main:
-#       MOV EAX, 0x1
+#       MOV    EAX, 0x10
+#       MOV    EBX, 0x1
 # loop_main:
-#       CMP EAX, 0x10
-#       JZ loop_end
-# loop_inc:
-#       INC EAX
-#       JMP loop_main
+#       SUB    EAX, 0x1
+#       CMOVZ  ECX, EBX
+#       JNZ    loop_main
 # loop_end:
 #       RET
-data = "b80100000083f810740340ebf8c3".decode("hex")
+
+
+data = "b810000000bb0100000083e8010f44cb75f8c3".decode("hex")
 run_addr = 0x40000000
 
 def code_sentinelle(jitter):
@@ -47,10 +47,10 @@ myjit.init_run(run_addr)
 myjit.continue_run()
 
 assert myjit.run is False
-assert myjit.cpu.EAX  == 0x10
+assert myjit.cpu.EAX  == 0x0
 
 ## Let's specify a max_exec_per_call
-## 5: main, loop_main, loop_inc, loop_main, loop_inc
+## 5: main/loop_main, loop_main
 myjit.jit.options["max_exec_per_call"] = 5
 
 first_call = True
@@ -71,8 +71,8 @@ myjit.exec_cb = cb
 myjit.continue_run()
 
 assert myjit.run is True
-# Use a '<=' because it's a 'max_...'
-assert myjit.cpu.EAX <= 3
+# Use a '>=' because it's a 'max_...'
+assert myjit.cpu.EAX >= 0xA
 
 # Test 'jit_maxline'
 print "[+] Run instr one by one"
@@ -91,7 +91,6 @@ myjit.exec_cb = cb
 myjit.continue_run()
 
 assert myjit.run is False
-assert myjit.cpu.EAX  == 0x10
-## dry(1) + main(1) + (loop_main(2) + loop_inc(2))*(0x10 - 1) + loop_main(2) +
-## loop_end(1) = 65
-assert counter == 65
+assert myjit.cpu.EAX  == 0x00
+## main(2) + (loop_main(3))*(0x10) + loop_end(1) + 0x1337beef (1)
+assert counter == 52