Beispiel #1
0
import logging

from miasm2.expression.expression import *
from miasm2.expression.simplifications import expr_simp, expr_simp_explicit, \
    ExpressionSimplifier, log_exprsimp

from miasm2.expression.simplifications_cond import ExprOp_inf_signed, ExprOp_inf_unsigned, ExprOp_equal

parser = ArgumentParser("Expression simplification regression tests")
parser.add_argument("--z3", action="store_true", help="Enable check against z3")
parser.add_argument("-v", "--verbose", action="store_true",
                    help="Verbose simplify")
args = parser.parse_args()

if args.verbose:
    log_exprsimp.setLevel(logging.DEBUG)

# Additional imports and definitions
if args.z3:
    import z3
    from miasm2.ir.translators import Translator
    trans = Translator.to_language("z3")

    def check(expr_in, expr_out):
        """Check that expr_in is always equals to expr_out"""
        print "Ensure %s = %s" % (expr_in, expr_out)
        solver = z3.Solver()
        solver.add(trans.from_expr(expr_in) != trans.from_expr(expr_out))

        result = solver.check()
Beispiel #2
0
import logging

from miasm2.expression.expression import *
from miasm2.expression.simplifications import expr_simp, expr_simp_explicit, \
    ExpressionSimplifier, log_exprsimp

from miasm2.expression.simplifications_cond import ExprOp_inf_signed, ExprOp_inf_unsigned, ExprOp_equal

parser = ArgumentParser("Expression simplification regression tests")
parser.add_argument("--z3", action="store_true", help="Enable check against z3")
parser.add_argument("-v", "--verbose", action="store_true",
                    help="Verbose simplify")
args = parser.parse_args()

if args.verbose:
    log_exprsimp.setLevel(logging.DEBUG)

# Additionnal imports and definitions
if args.z3:
    import z3
    from miasm2.ir.translators import Translator
    trans = Translator.to_language("z3")

    def check(expr_in, expr_out):
        """Check that expr_in is always equals to expr_out"""
        print "Ensure %s = %s" % (expr_in, expr_out)
        solver = z3.Solver()
        solver.add(trans.from_expr(expr_in) != trans.from_expr(expr_out))

        result = solver.check()