def get_dwarf2(location): """ Using NM """ for _, _, path_to_source, _ in dwarf2.get_dwarfs(location): if path_to_source: yield path_to_source
def test_dwarf2_error_shash_x86_64(self): test_file = 'dwarf/shash.x86_64' test_loc = self.get_test_loc(test_file) emsg1 = 'File format is ambiguous' try: list(dwarf2.get_dwarfs(test_loc)) except Exception as e: assert emsg1 in str(e)
def test_dwarf2_error_amd64_exec(self): test_file = 'dwarf/amd64_exec' test_loc = self.get_test_loc(test_file) emsg1 = 'File format is ambiguous' try: list(dwarf2.get_dwarfs(test_loc)) except Exception as e: assert emsg1 in str(e)
def test_dwarf2_error_misc_elfs_cpp_test_o(self): test_file = 'misc_elfs/cpp-test.o' test_loc = self.get_test_loc(test_file) emsg1 = 'File format is ambiguous' try: list(dwarf2.get_dwarfs(test_loc)) except Exception as e: assert emsg1 in str(e)
def check_dwarf(self, test_file, expected_file, regen=False): test_loc = self.get_test_loc(test_file) result = [list(r) for r in dwarf2.get_dwarfs(test_loc)] expected_loc = self.get_test_loc(expected_file) if regen: with open(expected_loc, 'wb') as exc: json.dump(result, exc, indent=2, encoding='utf-8') with open(expected_loc, 'rb') as exc: expected = json.load(exc, encoding='utf-8', object_pairs_hook=dict) assert sorted(expected) == sorted(result)
def test_dwarf2_empty_on_non_existing_file(self): test_file = 'dwarf/32.fsize.chgg_DOES_NOT_EXIST' result = dwarf2.get_dwarfs(test_file) self.assertRaises(IOError, list, result)