diff --git a/tests/testing/Inputs/fake-nm.py b/tests/testing/Inputs/fake-nm.py deleted file mode 100644 --- a/tests/testing/Inputs/fake-nm.py +++ /dev/null @@ -1,7 +0,0 @@ -import sys - -if '--fake-nm-be-non-dynamic' in sys.argv: - if '-D' in sys.argv: - sys.exit(0) - -sys.stdout.write(open(sys.argv[1]).read()) diff --git a/tests/testing/Inputs/fake-objdump.py b/tests/testing/Inputs/fake-objdump.py --- a/tests/testing/Inputs/fake-objdump.py +++ b/tests/testing/Inputs/fake-objdump.py @@ -1,16 +1,19 @@ import sys -for a in sys.argv: - if a.startswith('--start-address'): - addr = a.split('=')[1] - fname = '%s.%s.out' % (sys.argv[1], addr) - sys.stdout.write(open(fname).read()) - sys.exit(0) +def exit_with_fake_output(suffix): + fname = '%s.%s' % (sys.argv[1], suffix) + with open(fname) as f: + sys.stdout.write(f.read()) + sys.exit(0) - if a.startswith('-t'): - fname = '%s.out' % sys.argv[1] - sys.stdout.write(open(fname).read()) - sys.exit(0) + +for arg in sys.argv: + if arg.startswith('--start-address'): + addr = arg.split('=')[1] + exit_with_fake_output('%s.out' % addr) + + if arg.startswith('-t'): + exit_with_fake_output('out') sys.exit(1) diff --git a/tests/testing/Inputs/fib-aarch64.nm.out b/tests/testing/Inputs/fib-aarch64.nm.out deleted file mode 100644 --- a/tests/testing/Inputs/fib-aarch64.nm.out +++ /dev/null @@ -1,31 +0,0 @@ -00000000004017d8 00000000000001e0 d _DYNAMIC -00000000004019b8 0000000000000040 d _GLOBAL_OFFSET_TABLE_ -00000000004007c4 0000000000000004 R _IO_stdin_used -00000000004007cc r __FRAME_END__ -0000000000401a18 d __JCR_END__ -0000000000401a18 d __JCR_LIST__ -0000000000401a20 d __TMC_END__ -0000000000401a20 d __TMC_LIST__ -0000000000401a30 A __bss_start -0000000000401a08 D __data_start -0000000000400658 t __do_global_dtors_aux -0000000000401a20 t __do_global_dtors_aux_fini_array_entry -0000000000401a10 d __dso_handle -0000000000401a28 t __frame_dummy_init_array_entry -0000000000401a30 t __init_array_end -0000000000401a28 t __init_array_start -00000000004007b0 0000000000000004 T __libc_csu_fini -0000000000400738 0000000000000078 T __libc_csu_init -0000000000401a30 A _edata -0000000000401a34 A _end -00000000004007b4 T _fini -00000000004004f0 T _init -0000000000400578 T _start -00000000004005c0 0000000000000014 t call_weak_fn -0000000000401a30 0000000000000001 b completed.7233 -0000000000401a08 W data_start -00000000004005d8 t deregister_tm_clones -00000000004006c8 0000000000000038 T fib -0000000000400688 t frame_dummy -0000000000400700 0000000000000038 T main -0000000000400618 t register_tm_clones diff --git a/tests/testing/Inputs/fib2-aarch64.nm.out b/tests/testing/Inputs/fib2-aarch64.nm.out deleted file mode 100644 --- a/tests/testing/Inputs/fib2-aarch64.nm.out +++ /dev/null @@ -1,31 +0,0 @@ -00000000004017d8 00000000000001e0 d _DYNAMIC -00000000004019b8 0000000000000040 d _GLOBAL_OFFSET_TABLE_ -00000000004007c4 0000000000000004 R _IO_stdin_used -00000000004007cc r __FRAME_END__ -0000000000401a18 d __JCR_END__ -0000000000401a18 d __JCR_LIST__ -0000000000401a20 d __TMC_END__ -0000000000401a20 d __TMC_LIST__ -0000000000401a30 A __bss_start -0000000000401a08 D __data_start -0000000000400658 t __do_global_dtors_aux -0000000000401a20 t __do_global_dtors_aux_fini_array_entry -0000000000401a10 d __dso_handle -0000000000401a28 t __frame_dummy_init_array_entry -0000000000401a30 t __init_array_end -0000000000401a28 t __init_array_start -00000000004007b0 0000000000000004 T __libc_csu_fini -0000000000400738 0000000000000078 T __libc_csu_init -0000000000401a30 A _edata -0000000000401a34 A _end -00000000004007b4 T _fini -00000000004004f0 T _init -0000000000400578 T _start -00000000004005c0 0000000000000014 t call_weak_fn -0000000000401a30 0000000000000001 b completed.7233 -0000000000401a08 W data_start -00000000004005d8 t deregister_tm_clones -00000000004006c8 0000000000000038 T fib -0000000000400688 t frame_dummy -0000000000400700 0000000000000038 T main -0000000000400618 t register_tm_clones diff --git a/tests/testing/cPerf.py b/tests/testing/cPerf.py --- a/tests/testing/cPerf.py +++ b/tests/testing/cPerf.py @@ -170,30 +170,28 @@ def _getInput(self, fname): return os.path.join(self.inputs, fname) + def _loadPerfDataInput(self, fname): + perf_data = self._getInput(fname) + fake_objdump = self._getObjdump(perf_data) + with open(perf_data, 'rb') as f: + return LinuxPerfProfile.deserialize( + f, objdump=fake_objdump, propagateExceptions=True) + def test_check_file(self): self.assertTrue(LinuxPerfProfile.checkFile(self._getInput('fib-aarch64.perf_data'))) def test_aarch64_fib(self): - perf_data = self._getInput('fib-aarch64.perf_data') - p = LinuxPerfProfile.deserialize(open(perf_data, 'rb'), - objdump=self._getObjdump(perf_data), - propagateExceptions=True) + p = self._loadPerfDataInput('fib-aarch64.perf_data') self.assertEqual(p.data, self.expected_data['fib-aarch64']) def test_aarch64_fib2(self): - perf_data = self._getInput('fib2-aarch64.perf_data') - p = LinuxPerfProfile.deserialize(open(perf_data, 'rb'), - objdump=self._getObjdump(perf_data), - propagateExceptions=True) + p = self._loadPerfDataInput('fib2-aarch64.perf_data') self.assertEqual(p.data, self.expected_data['fib2-aarch64']) def test_aarch64_fib2_nondynamic(self): - perf_data = self._getInput('fib2-aarch64.perf_data') - p = LinuxPerfProfile.deserialize(open(perf_data, 'rb'), - objdump=self._getObjdump(perf_data), - propagateExceptions=True) + p = self._loadPerfDataInput('fib2-aarch64.perf_data') self.assertEqual(p.data, self.expected_data['fib2-aarch64']) diff --git a/tests/testing/profilev1impl.py b/tests/testing/profilev1impl.py --- a/tests/testing/profilev1impl.py +++ b/tests/testing/profilev1impl.py @@ -54,7 +54,8 @@ with tempfile.NamedTemporaryFile() as f: Profile.saveFromRendered(s, filename=f.name) - p2 = ProfileV1.deserialize(open(f.name, "rb")) + with open(f.name, 'rb') as f2: + p2 = ProfileV1.deserialize(f2) self.assertEqual(p2.data, self.test_data)