about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/asmblock.py9
-rwxr-xr-xtest/test_all.py29
2 files changed, 25 insertions, 13 deletions
diff --git a/test/core/asmblock.py b/test/core/asmblock.py
index cd1d262a..c3e1d11d 100644
--- a/test/core/asmblock.py
+++ b/test/core/asmblock.py
@@ -1,6 +1,6 @@
 from pdb import pm
 
-from miasm2.arch.x86.disasm import dis_x86_32
+from miasm2.analysis.machine import Machine
 from miasm2.analysis.binary import Container
 from miasm2.core.asmblock import AsmCFG, AsmConstraint, AsmBlock, \
     AsmBlockBad, AsmConstraintTo, AsmConstraintNext, \
@@ -13,7 +13,8 @@ data = "5589e583ec10837d08007509c745fc01100000eb73837d08017709c745fc02100000eb64
 cont = Container.from_string(data)
 
 # Test Disasm engine
-mdis = dis_x86_32(cont.bin_stream)
+machine = Machine("x86_32")
+mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db)
 ## Disassembly of one block
 first_block = mdis.dis_block(0)
 assert len(first_block.lines) == 5
@@ -215,7 +216,7 @@ asmcfg.sanity_check()
 # Test block_merge
 data2 = "31c0eb0c31c9750c31d2eb0c31ffebf831dbebf031edebfc31f6ebf031e4c3".decode("hex")
 cont2 = Container.from_string(data2)
-mdis = dis_x86_32(cont2.bin_stream)
+mdis = machine.dis_engine(cont2.bin_stream, loc_db=cont2.loc_db)
 ## Elements to merge
 asmcfg = mdis.dis_multiblock(0)
 ## Block alone
@@ -301,7 +302,7 @@ assert asmcfg.edges2constraint[(tob.loc_key, lbl_newb)] == AsmConstraint.c_to
 # Check double block split
 data = "74097405b8020000007405b803000000b804000000c3".decode('hex')
 cont = Container.from_string(data)
-mdis = dis_x86_32(cont.bin_stream)
+mdis = machine.dis_engine(cont.bin_stream, loc_db=cont.loc_db)
 asmcfg = mdis.dis_multiblock(0)
 ## Check resulting disasm
 assert len(asmcfg.nodes()) == 6
diff --git a/test/test_all.py b/test/test_all.py
index 42843e90..459d529e 100755
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -538,6 +538,11 @@ test_x86_32_if_reg = ExampleShellcode(['x86_32', 'x86_32_if_reg.S', "x86_32_if_r
 test_x86_32_seh = ExampleShellcode(["x86_32", "x86_32_seh.S", "x86_32_seh.bin",
                                     "--PE"])
 test_x86_32_dead = ExampleShellcode(['x86_32', 'x86_32_dead.S', "x86_32_dead.bin"])
+test_x86_32_dis = ExampleShellcode(
+    [
+        "x86_32", "test_x86_32_dis.S", "test_x86_32_dis.bin", "--PE"
+    ]
+)
 
 test_human = ExampleShellcode(["x86_64", "human.S", "human.bin"])
 
@@ -557,6 +562,7 @@ testset += test_x86_32_if_reg
 testset += test_x86_32_seh
 testset += test_x86_32_dead
 testset += test_human
+testset += test_x86_32_dis
 
 class ExampleDisassembler(Example):
     """Disassembler examples specificities:
@@ -565,15 +571,20 @@ class ExampleDisassembler(Example):
     example_dir = "disasm"
 
 
-for script, prods in [(["single_instr.py"], []),
-                      (["callback.py"], []),
-                      (["function.py"], ["graph.dot"]),
-                      (["file.py", Example.get_sample("box_upx.exe"),
-                        "0x407570"], ["graph.dot"]),
-                      (["full.py", Example.get_sample("box_upx.exe")],
-                       ["graph_execflow.dot", "lines.dot"]),
-                      ]:
-    testset += ExampleDisassembler(script, products=prods)
+for script, prods, depends in [
+        (["single_instr.py"], [], []),
+        (["callback.py"], [], []),
+        (["dis_x86_string.py"], ["str_cfg.dot"], []),
+        (["dis_binary.py", Example.get_sample("test_x86_32_dis.bin"),
+        ], ["bin_cfg.dot"], [test_x86_32_dis]),
+        (["dis_binary_ir.py", Example.get_sample("test_x86_32_dis.bin"),
+        ], ["bin_ir_cfg.dot"], [test_x86_32_dis]),
+        (["dis_binary_ira.py", Example.get_sample("test_x86_32_dis.bin"),
+        ], ["bin_ira_cfg.dot"], [test_x86_32_dis]),
+        (["full.py", Example.get_sample("box_upx.exe")],
+         ["graph_execflow.dot", "lines.dot"], []),
+]:
+    testset += ExampleDisassembler(script, products=prods, depends=depends)
 
 
 class ExampleDisasmFull(ExampleDisassembler):