about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/arch/mep/asm/test_asm.py4
-rw-r--r--test/arch/mep/asm/test_major_opcode_4.py2
-rw-r--r--test/jitter/jitcore.py47
-rwxr-xr-xtest/test_all.py13
4 files changed, 63 insertions, 3 deletions
diff --git a/test/arch/mep/asm/test_asm.py b/test/arch/mep/asm/test_asm.py
index 7762669a..e8b8afb9 100644
--- a/test/arch/mep/asm/test_asm.py
+++ b/test/arch/mep/asm/test_asm.py
@@ -22,12 +22,12 @@ class TestMisc(object):
         for mn_str, mn_hex in unit_tests:
             print("-" * 49)  # Tests separation
 
-            # Dissassemble
+            # Disassemble
             mn_bin = decode_hex(mn_hex)
             mn = mn_mep.dis(mn_bin, "b")
 
             print("dis: %s -> %s" % (mn_hex.rjust(20), str(mn).rjust(20)))
-            assert(str(mn) == mn_str)  # dissassemble assertion
+            assert(str(mn) == mn_str)  # disassemble assertion
 
             # Assemble and return all possible candidates
             instr = mn_mep.fromstring(str(mn), "b")
diff --git a/test/arch/mep/asm/test_major_opcode_4.py b/test/arch/mep/asm/test_major_opcode_4.py
index a6f57ac2..fd466b62 100644
--- a/test/arch/mep/asm/test_major_opcode_4.py
+++ b/test/arch/mep/asm/test_major_opcode_4.py
@@ -107,7 +107,7 @@ class TestMajor4(object):
         check_instruction("LBU $4, 0x22($TP)", "4ca2", multi=2)
         # Note: the following instruction can not be easily manipulated due to
         # expressions simplifications performed by miasm at assembly and
-        # dissassembly, i.e. ExprMem($TP + 0) is simplified into ExprMem($TP)
+        # disassembly, i.e. ExprMem($TP + 0) is simplified into ExprMem($TP)
         #check_instruction("LBU $6, 0x0($TP)", "4e80", multi=2)
         check_instruction("LBU $7, 0x3C($TP)", "4fbc", multi=2)
         check_instruction("LBU $2, 0x4($TP)", "4a84", multi=2)
diff --git a/test/jitter/jitcore.py b/test/jitter/jitcore.py
new file mode 100644
index 00000000..75360542
--- /dev/null
+++ b/test/jitter/jitcore.py
@@ -0,0 +1,47 @@
+import sys
+
+from miasm.analysis.machine import Machine
+machine = Machine("x86_64")
+jitter = machine.jitter(sys.argv[1])
+
+jitter.cpu.RAX = 16565615892967251934
+assert jitter.cpu.RAX == 16565615892967251934
+
+jitter.cpu.RAX = -1
+assert jitter.cpu.RAX == 0xffffffffffffffff
+
+jitter.cpu.RAX = -2
+assert jitter.cpu.RAX == 0xfffffffffffffffe
+
+jitter.cpu.EAX = -2
+assert jitter.cpu.EAX == 0xfffffffe
+
+jitter.cpu.RAX = -0xffffffffffffffff
+assert jitter.cpu.RAX == 1
+
+try:
+        jitter.cpu.RAX = 0x1ffffffffffffffff
+except TypeError:
+        pass
+else:
+        raise Exception("Should see that 0x1ffffffffffffffff is too big for RAX")
+
+try:
+        jitter.cpu.RAX = 0x10000000000000000
+except TypeError:
+        pass
+else:
+        raise Exception("Should see that 0x10000000000000000 is too big for RAX")
+
+jitter.cpu.EAX = -0xefffffff
+assert jitter.cpu.EAX == 0x10000001
+
+jitter.cpu.EAX = -0xFFFFFFFF
+assert jitter.cpu.EAX == 1
+
+try:
+        jitter.cpu.EAX = -0x1ffffffff
+except TypeError:
+        pass
+else:
+        raise Exception("Should see that -0x1ffffffff is too big for EAX")
diff --git a/test/test_all.py b/test/test_all.py
index a8a0d599..ce223211 100755
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -457,6 +457,7 @@ for i, test_args in enumerate(test_args):
 for script in ["jitload.py",
                "vm_mngr.py",
                "jit_options.py",
+               "jitcore.py",
                "test_post_instr.py",
                "bad_block.py",
                "jmp_out_mem.py",
@@ -696,6 +697,18 @@ for script in [["basic_op.py"],
                ]:
     testset += ExampleExpression(script)
 
+## Loader
+class ExampleLoader(Example):
+    """Loader examples specificities:
+    - script path begins with "loader/"
+    """
+    example_dir = "loader"
+
+
+testset += ExampleLoader(["build_pe.py"], products=["fresh_pe.exe"])
+# A sample is required, so "minidump_to_pe.py" is disabled for now
+
+
 ## Symbolic Execution
 class ExampleSymbolExec(Example):
     """Symbol Exec examples specificities: