<s> import sys <EOL> import time <EOL> import os <EOL> import logging <EOL> import nose <EOL> import angr <EOL> import simuvex <EOL> import claripy <EOL> l = logging . getLogger ( "<STR_LIT>" ) <EOL> test_location = str ( os . path . join ( os . path . dirname ( os . path . realpath ( __file__ ) ) , '<STR_LIT>' ) ) <EOL> vfg_0_addresses = { <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } <EOL> def run_vfg_0 ( arch ) : <EOL> proj = angr . Project ( os . path . join ( os . path . join ( test_location , arch ) , "<STR_LIT>" ) , <EOL> use_sim_procedures = True , <EOL> default_analysis_mode = '<STR_LIT>' ) <EOL> cfg = proj . analyses . CFG ( context_sensitivity_level = <NUM_LIT:1> ) <EOL> start = time . time ( ) <EOL> function_start = vfg_0_addresses [ arch ] <EOL> vfg = proj . analyses . VFG ( cfg , function_start = function_start , context_sensitivity_level = <NUM_LIT:2> , interfunction_level = <NUM_LIT:4> , <EOL> remove_options = { simuvex . s_options . OPTIMIZE_IR } <EOL> ) <EOL> end = time . time ( ) <EOL> duration = end - start <EOL> l . info ( "<STR_LIT>" , duration ) <EOL> nose . tools . assert_greater ( len ( vfg . final_states ) , <NUM_LIT:0> ) <EOL> states = vfg . final_states <EOL> nose . tools . assert_equal ( len ( states ) , <NUM_LIT:2> ) <EOL> stack_check_fail = proj . _extern_obj . get_pseudo_addr ( '<STR_LIT>' ) <EOL> nose . tools . assert_equal ( set ( [ s . se . exactly_int ( s . ip ) for s in states ] ) , <EOL> { <EOL> stack_check_fail , <EOL> <NUM_LIT> <EOL> } ) <EOL> state = [ s for s in states if s . se . exactly_int ( s . ip ) == <NUM_LIT> ] [ <NUM_LIT:0> ] <EOL> nose . tools . assert_true ( claripy . backends . vsa . is_true ( state . stack_read ( <NUM_LIT:12> , <NUM_LIT:4> ) >= <NUM_LIT> ) ) <EOL> def broken_vfg_0 ( ) : <EOL> for arch in vfg_0_addresses : <EOL> yield run_vfg_0 , arch <EOL> vfg_1_addresses = { <EOL> '<STR_LIT>' : { <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> } <EOL> } <EOL> def run_vfg_1 ( arch ) : <EOL> proj = angr . Project ( <EOL> os . path . join ( os . path . join ( test_location , arch ) , "<STR_LIT>" ) , <EOL> use_sim_procedures = True , <EOL> ) <EOL> cfg = proj . analyses . CFG ( ) <EOL> vfg = proj . analyses . VFG ( cfg , function_start = <NUM_LIT> , context_sensitivity_level = <NUM_LIT:10> , interfunction_level = <NUM_LIT:10> ) <EOL> all_block_addresses = set ( [ n . addr for n in vfg . graph . nodes ( ) ] ) <EOL> nose . tools . assert_true ( vfg_1_addresses [ arch ] . issubset ( all_block_addresses ) ) <EOL> def test_vfg_1 ( ) : <EOL> for arch in vfg_1_addresses : <EOL> yield run_vfg_1 , arch <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> if len ( sys . argv ) == <NUM_LIT:1> : <EOL> g = globals ( ) <EOL> for f in g . keys ( ) : <EOL> if f . startswith ( '<STR_LIT>' ) and hasattr ( g [ f ] , '<STR_LIT>' ) : <EOL> for test_func , arch_name in globals ( ) [ f ] ( ) : <EOL> test_func ( arch_name ) <EOL> else : <EOL> f = '<STR_LIT>' + sys . argv [ <NUM_LIT:1> ] <EOL> if f in globals ( ) : <EOL> func = globals ( ) [ f ] <EOL> if hasattr ( func , '<STR_LIT>' ) : <EOL> for test_func , arch in func ( ) : <EOL> test_func ( arch ) <EOL> else : <EOL> print '<STR_LIT>' % f </s>
