about summary refs log tree commit diff stats
path: root/test/test_all.py
diff options
context:
space:
mode:
authorCamille Mougey <commial@gmail.com>2015-02-13 14:16:52 +0100
committerCamille Mougey <commial@gmail.com>2015-02-13 14:16:52 +0100
commit13a3fcbb168589703d56d6c36312d788f68786e3 (patch)
treeb54647a953afbb30b0939d90e9ac256604093b74 /test/test_all.py
parent9af3164437657d93916b3658c483d6c3e4949cd5 (diff)
parentef6c6b0b855800375758058863861f28657b5ba7 (diff)
downloadmiasm-13a3fcbb168589703d56d6c36312d788f68786e3.tar.gz
miasm-13a3fcbb168589703d56d6c36312d788f68786e3.zip
Merge pull request #69 from serpilliere/x86_fix_op_32_in_64
X86 fix op 32 in 64
Diffstat (limited to 'test/test_all.py')
-rw-r--r--test/test_all.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/test/test_all.py b/test/test_all.py
index 66620375..5f0721fc 100644
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -42,6 +42,56 @@ for script in ["x86/sem.py",
                "mips32/arch.py",
                ]:
     testset += RegressionTest([script], base_dir="arch")
+
+
+## Semantic
+class SemanticTestAsm(RegressionTest):
+    """Assemble an asm file"""
+
+    shellcode_script = os.path.join("example", "asm", "shellcode.py")
+    container_dct = {"PE": "--PE"}
+
+    def __init__(self, arch, container, *args, **kwargs):
+        super(SemanticTestAsm, self).__init__(*args, **kwargs)
+        self.base_dir = os.path.join(self.base_dir, "..")
+        sample_dir = os.path.join("test", "samples", arch)
+        base_filename = os.path.join(sample_dir, self.command_line[0])
+        input_filename = base_filename + ".S"
+        output_filename = base_filename + ".bin"
+        self.command_line = [self.shellcode_script,
+                             arch,
+                             input_filename,
+                             output_filename,
+                             self.container_dct.get(container, '')]
+        self.products = [output_filename, "graph.txt"]
+
+
+class SemanticTestExec(RegressionTest):
+    """Execute a binary file"""
+
+    launcher_dct = {("PE", "x86_64"): "sandbox_pe_x86_64.py"}
+    launcher_base = os.path.join("example", "jitter")
+
+    def __init__(self, arch, container, address, *args, **kwargs):
+        super(SemanticTestExec, self).__init__(*args, **kwargs)
+        self.base_dir = os.path.join(self.base_dir, "..")
+        sample_dir = os.path.join("test", "samples", arch)
+        base_filename = os.path.join(sample_dir, self.command_line[0])
+        input_filename = base_filename + ".bin"
+        launcher = os.path.join(self.launcher_base,
+                                self.launcher_dct[(container, arch)])
+        self.command_line = [launcher,
+                             input_filename,
+                             "-a", hex(address)]
+        self.products = []
+
+
+
+test_x86_64_mul_div = SemanticTestAsm("x86_64", "PE", ["mul_div"])
+testset += test_x86_64_mul_div
+testset += SemanticTestExec("x86_64", "PE", 0x401000, ["mul_div"],
+                            depends=[test_x86_64_mul_div])
+
 ## Core
 for script in ["interval.py",
                "graph.py",
@@ -116,7 +166,6 @@ class ExampleShellcode(ExampleAssembler):
                              self.command_line[3:]
         self.products = [self.command_line[3], "graph.txt"]
 
-
 testset += ExampleShellcode(['x86_32', 'x86_32_manip_ptr.S', "demo_x86_32.bin"])
 
 test_box = {}