예제 #1
0
파일: dart.py 프로젝트: 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
예제 #2
0
파일: dart.py 프로젝트: 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
예제 #3
0
파일: dart.py 프로젝트: Auzzy/pystick
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
예제 #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