[PATCH v3 4/4] perf test: Update PE file test for other locations

From: Namhyung Kim

Date: Mon Oct 12 2026 - 20:01:06 EST


The test__pe_file_parsing() expects the test is in the tools/perf
directory, but it could be root or a separate build directory. Let's
update the logic to try other paths like in the shell_tests__dir_fd().

Also add some debug messages to inform users why it's skipped.

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/tests/pe-file-parsing.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tools/perf/tests/pe-file-parsing.c b/tools/perf/tests/pe-file-parsing.c
index 3979f38bf127c218..190520ffc3ad6d0c 100644
--- a/tools/perf/tests/pe-file-parsing.c
+++ b/tools/perf/tests/pe-file-parsing.c
@@ -74,17 +74,20 @@ static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
{
struct stat st;
char path_dir[PATH_MAX];
-
- /* First try development tree tests. */
- if (!lstat("./tests", &st))
- return run_dir("./tests");
-
- /* Then installed path. */
+ const char * const tests_dirs[] = {
+ "./tools/perf/tests",
+ "./tests",
+ "./source/tests",
+ path_dir,
+ };
snprintf(path_dir, PATH_MAX, "%s/tests", get_argv_exec_path());

- if (!lstat(path_dir, &st))
- return run_dir(path_dir);
+ for (size_t i = 0; i < ARRAY_SIZE(tests_dirs); ++i) {
+ if (!lstat(tests_dirs[i], &st))
+ return run_dir(tests_dirs[i]);
+ }

+ pr_debug("cannot find the tests directory\n");
return TEST_SKIP;
}

@@ -93,6 +96,7 @@ static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
+ pr_debug("libbfd is not available\n");
return TEST_SKIP;
}

--
2.56.0.385.gd3acb90ef8-goog