1import angr 2import os 3import nose 4 5test_location = str(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../binaries/tests')) 6arches = {'i386', 'x86_64'} 7 8def main(): 9 test_ddg_memvar_addresses() 10 11def test_ddg_memvar_addresses(): 12 for arch in arches: 13 run_ddg_memvar_addresses(arch) 14 15def run_ddg_memvar_addresses(arch): 16 test_file = os.path.join(test_location, arch, 'simple_data_dependence') 17 proj = angr.Project(test_file, auto_load_libs=False) 18 cfg = proj.analyses.CFGEmulated(context_sensitivity_level=2, keep_state=True, state_add_options=angr.sim_options.refs) 19 ddg = proj.analyses.DDG(cfg) 20 21 for node in ddg._data_graph.nodes(): 22 if isinstance(node.variable, angr.sim_variable.SimMemoryVariable): 23 nose.tools.assert_true(0 <= node.variable.addr < (1 << proj.arch.bits), msg="Program variable {} has an invalid address: {}".format(node.variable, node.variable.addr)) 24 25if __name__ == "__main__": 26 main() 27