diff options
| -rw-r--r-- | .travis.yml | 2 | ||||
| -rw-r--r-- | miasm2/ir/ir.py | 12 | ||||
| -rwxr-xr-x | test/test_all.py | 33 |
3 files changed, 30 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml index 3583e4ba..81e571c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,4 +49,4 @@ before_script: - "cd miasm;" - "python setup.py build build_ext -I$(pwd)/../virtualenv/include -L$(pwd)/../virtualenv/tinycc" - "python setup.py install" -script: "python -c 'import z3; x = z3.BitVec(chr(0x41), 32)' && cd test && python test_all.py" +script: "python -c 'import z3; x = z3.BitVec(chr(0x41), 32)' && cd test && python test_all.py && git ls-files -o --exclude-standard" diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index e5f0c8db..8154d4da 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -33,7 +33,13 @@ class AssignBlock(object): EAX = EBX EBX = EAX - Also provides common manipulation on this assignments + -> Exchange between EBX and EAX + + AssignBlock can be seen as a dictionnary where keys are the destinations + (ExprId or ExprMem), and values their corresponding sources. + + Also provides common manipulation on this assignments. + """ __slots__ = ["_assigns", "_instr"] @@ -124,6 +130,10 @@ class AssignBlock(object): args = [expr for (expr, _, _) in args] new_src = m2_expr.ExprCompose(*args) + # Sanity check + if not isinstance(new_dst, (m2_expr.ExprId, m2_expr.ExprMem)): + raise TypeError("Destination cannot be a %s" % type(new_dst)) + self._assigns[new_dst] = new_src def __setitem__(self, dst, src): diff --git a/test/test_all.py b/test/test_all.py index 1176545e..41954ff1 100755 --- a/test/test_all.py +++ b/test/test_all.py @@ -275,8 +275,10 @@ testset += RegressionTest(["depgraph.py"], base_dir="analysis", ["graph_test_%02d_%02d.dot" % (test_nb, res_nb) for (test_nb, res_nb) in ((3, 1), (5, 1), (8, 1), (9, 1), (10, 1), - (12, 1), (13, 1), - (14, 1), (15, 1)) + (12, 1), (12, 2), + (13, 1), (13, 2), + (14, 1), (14, 2), + (15, 1)) ]) testset += RegressionTest(["modularintervals.py"], base_dir="analysis") for jitter in ArchUnitTest.jitter_engines: @@ -303,10 +305,11 @@ class TestDepgraph(RegressionTest): def __init__(self, test_nb, implicit, base_addr, target_addr, elements, - *args, **kwargs): + nb_sol, *args, **kwargs): super(TestDepgraph, self).__init__([self.launcher], *args, **kwargs) self.base_dir = os.path.join(self.base_dir, "analysis") + self.products = ["sol_%d.dot" % i for i in xrange(nb_sol)] if implicit: expected_fname = "dg_test_%.2d_implicit_expected.json" self.tags.append(TAGS["z3"]) @@ -326,18 +329,18 @@ class TestDepgraph(RegressionTest): self.command_line.append("-i") # Depgraph emulation regression test -test_args = [(0x401000, 0x40100d, ["EAX"]), - (0x401000, 0x401011, ["EAX"]), - (0x401000, 0x401018, ["EAX"]), - (0x401000, 0x401011, ["EAX"]), - (0x401000, 0x401011, ["EAX"]), - (0x401000, 0x401016, ["EAX"]), - (0x401000, 0x401017, ["EAX"]), - (0x401000, 0x401012, ["EAX", "ECX"]), - (0x401000, 0x401012, ["ECX"]), - (0x401000, 0x40101f, ["EAX", "EBX"]), - (0x401000, 0x401025, ["EAX", "EBX"]), - (0x401000, 0x401007, ["EBX"]), +test_args = [(0x401000, 0x40100d, ["EAX"], 1), + (0x401000, 0x401011, ["EAX"], 1), + (0x401000, 0x401018, ["EAX"], 2), + (0x401000, 0x401011, ["EAX"], 2), + (0x401000, 0x401011, ["EAX"], 1), + (0x401000, 0x401016, ["EAX"], 1), + (0x401000, 0x401017, ["EAX"], 2), + (0x401000, 0x401012, ["EAX", "ECX"], 1), + (0x401000, 0x401012, ["ECX"], 1), + (0x401000, 0x40101f, ["EAX", "EBX"], 2), + (0x401000, 0x401025, ["EAX", "EBX"], 4), + (0x401000, 0x401007, ["EBX"], 3), ] for i, test_args in enumerate(test_args): test_dg = SemanticTestAsm("x86_32", "PE", ["dg_test_%.2d" % i]) |