diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-02-15 16:22:21 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2017-03-13 14:13:14 +0100 |
| commit | d0727aa74bf264580e82f37abc9833b75804daca (patch) | |
| tree | e5ec4298599a5907b45d009c4da2755c6ba523c0 /test | |
| parent | e1fc2de7e4d8662d5b97ceb7d7a9b9ba24acddaa (diff) | |
| download | miasm-d0727aa74bf264580e82f37abc9833b75804daca.tar.gz miasm-d0727aa74bf264580e82f37abc9833b75804daca.zip | |
Asmbloc: rename asm_label to AsmLabel
Diffstat (limited to 'test')
| -rw-r--r-- | test/analysis/depgraph.py | 24 | ||||
| -rw-r--r-- | test/core/asmbloc.py | 18 | ||||
| -rw-r--r-- | test/core/sembuilder.py | 8 | ||||
| -rw-r--r-- | test/ir/analysis.py | 16 | ||||
| -rw-r--r-- | test/ir/translators/z3_ir.py | 6 |
5 files changed, 36 insertions, 36 deletions
diff --git a/test/analysis/depgraph.py b/test/analysis/depgraph.py index 429f7dc8..f84f19cc 100644 --- a/test/analysis/depgraph.py +++ b/test/analysis/depgraph.py @@ -1,7 +1,7 @@ """Regression test module for DependencyGraph""" from miasm2.expression.expression import ExprId, ExprInt32, ExprAff, ExprCond, \ ExprInt -from miasm2.core.asmbloc import asm_label +from miasm2.core.asmbloc import AsmLabel from miasm2.ir.analysis import ira from miasm2.ir.ir import IRBlock, AssignBlock from miasm2.core.graph import DiGraph @@ -42,13 +42,13 @@ CST33 = ExprInt32(0x33) CST35 = ExprInt32(0x35) CST37 = ExprInt32(0x37) -LBL0 = asm_label("lbl0") -LBL1 = asm_label("lbl1") -LBL2 = asm_label("lbl2") -LBL3 = asm_label("lbl3") -LBL4 = asm_label("lbl4") -LBL5 = asm_label("lbl5") -LBL6 = asm_label("lbl6") +LBL0 = AsmLabel("lbl0") +LBL1 = AsmLabel("lbl1") +LBL2 = AsmLabel("lbl2") +LBL3 = AsmLabel("lbl3") +LBL4 = AsmLabel("lbl4") +LBL5 = AsmLabel("lbl5") +LBL6 = AsmLabel("lbl6") def gen_irblock(label, exprs_list): """ Returns an IRBlock with empty lines. @@ -114,7 +114,7 @@ def bloc2graph(irgraph, label=False, lines=True): # Generate basic blocks out_blocks = [] for label in irgraph.graph.nodes(): - if isinstance(label, asm_label): + if isinstance(label, AsmLabel): label_name = label.name else: label_name = str(label) @@ -123,7 +123,7 @@ def bloc2graph(irgraph, label=False, lines=True): irblock = irgraph.blocks[label] else: irblock = None - if isinstance(label, asm_label): + if isinstance(label, AsmLabel): out_block = '%s [\n' % label.name else: out_block = '%s [\n' % label @@ -154,11 +154,11 @@ def bloc2graph(irgraph, label=False, lines=True): out += out_blocks # Generate links for src, dst in irgraph.graph.edges(): - if isinstance(src, asm_label): + if isinstance(src, AsmLabel): src_name = src.name else: src_name = str(src) - if isinstance(dst, asm_label): + if isinstance(dst, AsmLabel): dst_name = dst.name else: dst_name = str(dst) diff --git a/test/core/asmbloc.py b/test/core/asmbloc.py index ef68b5db..4b6947d6 100644 --- a/test/core/asmbloc.py +++ b/test/core/asmbloc.py @@ -3,7 +3,7 @@ from pdb import pm from miasm2.arch.x86.disasm import dis_x86_32 from miasm2.analysis.binary import Container from miasm2.core.asmbloc import AsmCFG, asm_constraint, AsmBlock, \ - asm_label, AsmBlockBad, asm_constraint_to, asm_constraint_next, \ + AsmLabel, AsmBlockBad, asm_constraint_to, asm_constraint_next, \ bbl_simplifier from miasm2.core.graph import DiGraphSimplifier, MatchGraphJoker from miasm2.expression.expression import ExprId @@ -98,7 +98,7 @@ open("graph2.dot", "w").write(blocks.dot()) # Test helper methods ## Label2block should always be updated assert blocks.label2block(first_block.label) == first_block -my_block = AsmBlock(asm_label("testlabel")) +my_block = AsmBlock(AsmLabel("testlabel")) blocks.add_node(my_block) assert len(blocks) == 3 assert blocks.label2block(first_block.label) == first_block @@ -108,7 +108,7 @@ assert blocks.label2block(my_block.label) == my_block assert len(list(blocks.get_bad_blocks())) == 0 assert len(list(blocks.get_bad_blocks_predecessors())) == 0 ### Add a bad block, not linked -my_bad_block = AsmBlockBad(asm_label("testlabel_bad")) +my_bad_block = AsmBlockBad(AsmLabel("testlabel_bad")) blocks.add_node(my_bad_block) assert list(blocks.get_bad_blocks()) == [my_bad_block] assert len(list(blocks.get_bad_blocks_predecessors())) == 0 @@ -126,7 +126,7 @@ assert len(list(blocks.get_bad_blocks_predecessors(strict=True))) == 0 ## Sanity check blocks.sanity_check() ### Next on itself -my_block_ni = AsmBlock(asm_label("testlabel_nextitself")) +my_block_ni = AsmBlock(AsmLabel("testlabel_nextitself")) my_block_ni.bto.add(asm_constraint_next(my_block_ni.label)) blocks.add_node(my_block_ni) error_raised = False @@ -139,10 +139,10 @@ assert error_raised blocks.del_node(my_block_ni) blocks.sanity_check() ### Multiple next on the same node -my_block_target = AsmBlock(asm_label("testlabel_target")) +my_block_target = AsmBlock(AsmLabel("testlabel_target")) blocks.add_node(my_block_target) -my_block_src1 = AsmBlock(asm_label("testlabel_src1")) -my_block_src2 = AsmBlock(asm_label("testlabel_src2")) +my_block_src1 = AsmBlock(AsmLabel("testlabel_src1")) +my_block_src2 = AsmBlock(AsmLabel("testlabel_src2")) my_block_src1.bto.add(asm_constraint_next(my_block_target.label)) blocks.add_node(my_block_src1) ### OK for now @@ -171,8 +171,8 @@ assert blocks.label2block(my_block_src1.label).max_size == 0 ## Check pendings ### Create a pending element -my_block_src = AsmBlock(asm_label("testlabel_pend_src")) -my_block_dst = AsmBlock(asm_label("testlabel_pend_dst")) +my_block_src = AsmBlock(AsmLabel("testlabel_pend_src")) +my_block_dst = AsmBlock(AsmLabel("testlabel_pend_dst")) my_block_src.bto.add(asm_constraint_to(my_block_dst.label)) blocks.add_node(my_block_src) ### Check resulting state diff --git a/test/core/sembuilder.py b/test/core/sembuilder.py index 3a575727..d0109092 100644 --- a/test/core/sembuilder.py +++ b/test/core/sembuilder.py @@ -3,7 +3,7 @@ from pdb import pm from miasm2.core.sembuilder import SemBuilder import miasm2.expression.expression as m2_expr -from miasm2.core.asmbloc import asm_label +from miasm2.core.asmbloc import AsmLabel # Test classes class IR(object): @@ -11,13 +11,13 @@ class IR(object): IRDst = m2_expr.ExprId("IRDst") def get_next_instr(self, _): - return asm_label("NEXT") + return AsmLabel("NEXT") def get_next_label(self, _): - return asm_label("NEXT") + return AsmLabel("NEXT") def gen_label(self): - return asm_label("GEN") + return AsmLabel("GEN") class Instr(object): mode = 32 diff --git a/test/ir/analysis.py b/test/ir/analysis.py index 2446b5ba..0350fb23 100644 --- a/test/ir/analysis.py +++ b/test/ir/analysis.py @@ -1,6 +1,6 @@ """ Test cases for dead code elimination""" from miasm2.expression.expression import ExprId, ExprInt32, ExprAff, ExprMem -from miasm2.core.asmbloc import asm_label +from miasm2.core.asmbloc import AsmLabel from miasm2.ir.analysis import ira from miasm2.ir.ir import IRBlock, AssignBlock @@ -23,13 +23,13 @@ CST1 = ExprInt32(0x11) CST2 = ExprInt32(0x12) CST3 = ExprInt32(0x13) -LBL0 = asm_label("lbl0") -LBL1 = asm_label("lbl1") -LBL2 = asm_label("lbl2") -LBL3 = asm_label("lbl3") -LBL4 = asm_label("lbl4") -LBL5 = asm_label("lbl5") -LBL6 = asm_label("lbl6") +LBL0 = AsmLabel("lbl0") +LBL1 = AsmLabel("lbl1") +LBL2 = AsmLabel("lbl2") +LBL3 = AsmLabel("lbl3") +LBL4 = AsmLabel("lbl4") +LBL5 = AsmLabel("lbl5") +LBL6 = AsmLabel("lbl6") diff --git a/test/ir/translators/z3_ir.py b/test/ir/translators/z3_ir.py index 5fcfe25e..9a75a320 100644 --- a/test/ir/translators/z3_ir.py +++ b/test/ir/translators/z3_ir.py @@ -1,6 +1,6 @@ import z3 -from miasm2.core.asmbloc import asm_label +from miasm2.core.asmbloc import AsmLabel from miasm2.expression.expression import * from miasm2.ir.translators.translator import Translator from miasm2.ir.translators.z3_ir import Z3Mem @@ -139,13 +139,13 @@ for miasm_int, res in [(five, -5), (four, -4)]: assert equiv(ez3, z3_e6) # -------------------------------------------------------------------------- -e7 = ExprId(asm_label("label_histoire", 0xdeadbeef), 32) +e7 = ExprId(AsmLabel("label_histoire", 0xdeadbeef), 32) ez3 = Translator.to_language('z3').from_expr(e7) z3_e7 = z3.BitVecVal(0xdeadbeef, 32) assert equiv(ez3, z3_e7) # Should just not throw anything to pass -e8 = ExprId(asm_label("label_jambe"), 32) +e8 = ExprId(AsmLabel("label_jambe"), 32) ez3 = Translator.to_language('z3').from_expr(e8) assert not equiv(ez3, z3_e7) |