Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c9cef3

Browse filesBrowse files
committed
gh-118518: Check for perf version and not kernel version in test_perf_profiler
1 parent afbe5bf commit 0c9cef3
Copy full SHA for 0c9cef3

File tree

1 file changed

+12
-6
lines changed
Filter options

1 file changed

+12
-6
lines changed

‎Lib/test/test_perf_profiler.py

Copy file name to clipboardExpand all lines: Lib/test/test_perf_profiler.py
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,23 @@ def compile_trampolines_for_all_functions():
479479
if f"py::foo_fork:{script}" in line or f"py::bar_fork:{script}" in line:
480480
self.assertIn(line, child_perf_file_contents)
481481

482-
def _is_kernel_version_at_least(major, minor):
482+
483+
def _is_perf_vesion_at_least(major, minor):
484+
# The output of perf --version looks like "perf version 6.7-3" but
485+
# it can also be perf version "perf version 5.15.143"
483486
try:
484-
with open("/proc/version") as f:
485-
version = f.readline().split()[2]
486-
except FileNotFoundError:
487+
output = subprocess.check_output(["perf", "--version"], text=True)
488+
except (subprocess.CalledProcessError, FileNotFoundError):
487489
return False
490+
version = output.split()[2]
491+
version = version.split("-")[0]
488492
version = version.split(".")
489-
return int(version[0]) > major or (int(version[0]) == major and int(version[1]) >= minor)
493+
version = tuple(map(int, version))
494+
return version >= (major, minor)
495+
490496

491497
@unittest.skipUnless(perf_command_works(), "perf command doesn't work")
492-
@unittest.skipUnless(_is_kernel_version_at_least(6, 6), "perf command may not work due to a perf bug")
498+
@unittest.skipUnless(_is_perf_vesion_at_least(6, 6), "perf command may not work due to a perf bug")
493499
class TestPerfProfilerWithDwarf(unittest.TestCase, TestPerfProfilerMixin):
494500
def run_perf(self, script_dir, script, activate_trampoline=True):
495501
if activate_trampoline:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.