Exemplo n.º 1
0
Arquivo: dart.py Projeto: Auzzy/school
def execute_program(program, user_func, inputs):
	global stack,solutions,path_constraints

	env = eval_concrete(program,user_func,inputs)
	execute = Execute(env)
	execute.visit(program)
	path_constraints[inputs] = list(execute.path_constraints)

	##### DEBUGGING OUTPUT #####
	print "SYMBOLIC MEMORY"
	for var in execute.symbolic_memory:
		print "{0}: {1}".format(var,str(execute.symbolic_memory[var]))
	if execute.path_constraints:
		print
		print "PATH CONSTRAINTS"
		for const in execute.path_constraints:
			print const
	print
	print "FINAL STACK: "
	print stack
	print
	##### END DEBUGGING OUTPUT #####

	new_solutions = solve_path_constraints(len(stack),execute.path_constraints,execute.symbolic_memory.keys())
	new_solutions = filter_inputs(new_solutions,inputs.keys())

	if directed:
		inputs = random_item(list(new_solutions)) if new_solutions else None
		solutions[inputs] = new_solutions
	else:
		unfinished = [branch for branch in stack if not branch["done"]]
		if unfinished:
			print "At least one branch cannot be taken due to a condition that cannot be completely covered."
		inputs = None
		stack = None
	
	##### DEBUGGING OUTPUT #####
	print
	print "NEW INPUTS"
	print inputs
	print
	print "NEW STACK"
	print stack
	print

	##### END DEBUGGING OUTPUT #####	

	return inputs
Exemplo n.º 2
0
Arquivo: dart.py Projeto: Auzzy/school
def execute_program(program, user_func, inputs):
	global stack,solutions,path_constraints

	env = eval_concrete(program,user_func,inputs)
	execute = Execute(env)
	execute.visit(program)
	path_constraints[inputs] = list(execute.path_constraints)

	new_solutions = solve_path_constraints(len(stack),execute.path_constraints,execute.symbolic_memory.keys())
	new_solutions = filter_inputs(new_solutions,inputs.keys())

	if directed:
		inputs = random_item(list(new_solutions)) if new_solutions else None
		solutions[inputs] = new_solutions
	else:
		inputs = None
		stack = None
	
	return inputs
Exemplo n.º 3
0
def execute_program(program, user_func, inputs):
	global stack,solutions,path_constraints

	env = eval_concrete(program,user_func,inputs)
	execute = Execute(env)
	execute.visit(program)
	path_constraints[inputs] = list(execute.path_constraints)

	new_solutions = solve_path_constraints(len(stack),execute.path_constraints,execute.symbolic_memory.keys())
	new_solutions = filter_inputs(new_solutions,inputs.keys())

	if directed:
		inputs = random_item(list(new_solutions)) if new_solutions else None
		solutions[inputs] = new_solutions
	else:
		unfinished = [branch for branch in stack if not branch["done"]]
		if unfinished:
			print "At least one branch cannot be taken due to a condition that cannot be completely covered."
		inputs = None
		stack = None
	
	return inputs
Exemplo n.º 4
0
def execute_program(program, user_func, inputs):
    global stack, solutions, path_constraints

    env = eval_concrete(program, user_func, inputs)
    execute = Execute(env)
    execute.visit(program)
    path_constraints[inputs] = list(execute.path_constraints)

    new_solutions = solve_path_constraints(len(stack),
                                           execute.path_constraints,
                                           execute.symbolic_memory.keys())
    new_solutions = filter_inputs(new_solutions, inputs.keys())

    if directed:
        inputs = random_item(list(new_solutions)) if new_solutions else None
        solutions[inputs] = new_solutions
    else:
        unfinished = [branch for branch in stack if not branch["done"]]
        if unfinished:
            print "At least one branch cannot be taken due to a condition that cannot be completely covered."
        inputs = None
        stack = None

    return inputs