Skip to content

Commit 8aa0d9e

Browse files
committed
Add support.supports_perf_trampoline_profiling() function
1 parent 3756938 commit 8aa0d9e

5 files changed

Lines changed: 11 additions & 26 deletions

File tree

‎Lib/test/libregrtest/skipped.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,6 @@ def expected_to_be_skipped(test_name):
282282

283283
if test_name in ('test_perf_profiler', 'test_perfmaps', 'test_samply_profiler'):
284284
# need perf trampoline profiling
285-
import sysconfig
286-
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
287-
return (not perf_trampoline or int(perf_trampoline) != 1)
285+
return not support.supports_perf_trampoline_profiling()
288286

289287
return False

‎Lib/test/support/__init__.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,3 +3614,10 @@ def inject_memory_error_cm(start=0, stop=0):
36143614
yield
36153615
finally:
36163616
_testcapi.remove_mem_hooks()
3617+
3618+
3619+
def supports_perf_trampoline_profiling():
3620+
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
3621+
if not perf_trampoline:
3622+
return False
3623+
return int(perf_trampoline) == 1

‎Lib/test/test_perf_profiler.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,7 @@
2323
raise unittest.SkipTest("test crash randomly on ASAN/MSAN build")
2424

2525

26-
def supports_trampoline_profiling():
27-
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
28-
if not perf_trampoline:
29-
return False
30-
return int(perf_trampoline) == 1
31-
32-
33-
if not supports_trampoline_profiling():
26+
if not support.supports_perf_trampoline_profiling():
3427
raise unittest.SkipTest("perf trampoline profiling not supported")
3528

3629

‎Lib/test/test_perfmaps.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@
88
except ImportError:
99
raise unittest.SkipTest("requires _testinternalcapi")
1010

11-
def supports_trampoline_profiling():
12-
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
13-
if not perf_trampoline:
14-
return False
15-
return int(perf_trampoline) == 1
16-
17-
if not supports_trampoline_profiling():
11+
if not support.supports_perf_trampoline_profiling():
1812
raise unittest.SkipTest("perf trampoline profiling not supported")
1913

2014
class TestPerfMapWriting(unittest.TestCase):

‎Lib/test/test_samply_profiler.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,7 @@
2020
raise unittest.SkipTest("test crash randomly on ASAN/MSAN build")
2121

2222

23-
def supports_trampoline_profiling():
24-
perf_trampoline = sysconfig.get_config_var("PY_HAVE_PERF_TRAMPOLINE")
25-
if not perf_trampoline:
26-
return False
27-
return int(perf_trampoline) == 1
28-
29-
30-
if not supports_trampoline_profiling():
23+
if not support.supports_perf_trampoline_profiling():
3124
raise unittest.SkipTest("perf trampoline profiling not supported")
3225

3326

0 commit comments

Comments
 (0)