Skip to contentSkip to conversation

perf test: Fix perf-record on Yocto

PATCH New [email protected] 1 participant 1 message Jul 20, 2024 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test: Fix perf-record on Yocto

From: "Chen Pei" <[email protected]>

There is a perf test case: PERF_RECORD_* events & perf_sample fields, which will fail on the system built by Yocto, and the log is as follows:

  # perf test -v 5
    5: PERF_RECORD_* events & perf_sample fields                       :
  --- start ---
  test child forked, pid 2341
  Using CPUID 0x5b7-0x0-0x0
  mmap size 1052672B
  2095118675900 0 PERF_RECORD_COMM exec: sleep:2342/2342
  2095119056100 0 PERF_RECORD_MMAP2 ...: r-xp /bin/sleep.coreutils
  2095119387900 0 PERF_RECORD_MMAP2 ...: r-xp /lib/ld-2.33.so
  2095119814200 0 PERF_RECORD_MMAP2 ...: r-xp [vdso]
  2095122676300 0 PERF_RECORD_MMAP2 ...: r-xp /lib/libc-2.33.so
  2096139253600 0 PERF_RECORD_EXIT(2342:2342):(2341:2341)
  PERF_RECORD_MMAP for sleep missing!
  test child finished with -1
  ---- end ----
  PERF_RECORD_* events & perf_sample fields: FAILED!

This is because the sleep command provided by coreutils in the Yocto environment is actually sleep.coreutils, that is:

  # which sleep
  /bin/sleep
  # ls -l /bin/sleep
  lrwxrwxrwx 1 root root 20 Mar  9  2018 /bin/sleep -> /bin/sleep.coreutils

So, just add the condition of sleep.coreutils to found_coreutils_mmap.

---
 tools/perf/tests/perf-record.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/tests/perf-record.c +2 -1
index 1c4feec1adff..7b189723d3cf 100644
@@ -259,7 +259,8 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
 						if (!found_cmd_mmap)
 							found_cmd_mmap = !strcmp(bname + 1, cmd);
 						if (!found_coreutils_mmap)
-							found_coreutils_mmap = !strcmp(bname + 1, "coreutils");
+							found_coreutils_mmap = !strcmp(bname + 1, "coreutils") ||
+												   !strcmp(bname + 1, "sleep.coreutils");
 						if (!found_libc_mmap)
 							found_libc_mmap = !strncmp(bname + 1, "libc", 4);
 						if (!found_ld_mmap)
Signature · 1 line
2.17.1