Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit37959e2

Browse files
authored
gh-118518: Check for perf version and not kernel version in test_perf_profiler (#118640)
1 parent2c19987 commit37959e2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎Lib/test/test_perf_profiler.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,23 @@ def compile_trampolines_for_all_functions():
479479
iff"py::foo_fork:{script}"inlineorf"py::bar_fork:{script}"inline:
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-
withopen("/proc/version")asf:
485-
version=f.readline().split()[2]
486-
exceptFileNotFoundError:
487+
output=subprocess.check_output(["perf","--version"],text=True)
488+
except (subprocess.CalledProcessError,FileNotFoundError):
487489
returnFalse
490+
version=output.split()[2]
491+
version=version.split("-")[0]
488492
version=version.split(".")
489-
returnint(version[0])>majoror (int(version[0])==majorandint(version[1])>=minor)
493+
version=tuple(map(int,version))
494+
returnversion>= (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
classTestPerfProfilerWithDwarf(unittest.TestCase,TestPerfProfilerMixin):
494500
defrun_perf(self,script_dir,script,activate_trampoline=True):
495501
ifactivate_trampoline:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp