[PATCH v5 11/11] perf test: Fix dso data tests

From: Namhyung Kim

Date: Tue Oct 13 2026 - 13:38:52 EST


Now dso__binary_type() requires that the target file is a valid ELF file
containing ".text" section. But the test only checks cached read/write
operation on a file. Let's set the binary type to bypass the ELF check
to read/write the file properly.

Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/tests/dso-data.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 46bc3f59726004fa..18b7052a2dc575c2 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -138,6 +138,10 @@ static int test__dso_data(struct test_suite *test __maybe_unused, int subtest __
dsos__init(&machine.dsos);

dso = dso__new(file);
+ TEST_ASSERT_VAL("Failed to get dso", dso);
+ /* override the binary type for dso data access */
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__SYSTEM_PATH_DSO);
+ dso__set_bintype_searched(dso);
TEST_ASSERT_VAL("Failed to add dso", !dsos__add(&machine.dsos, dso));
TEST_ASSERT_VAL("Failed to access to dso",
dso__data_fd(dso, &machine) >= 0);
@@ -226,6 +230,9 @@ static int dsos__create(int cnt, int size, struct dsos *dsos)
TEST_ASSERT_VAL("failed to get dso file", file);
dso = dso__new(file);
TEST_ASSERT_VAL("failed to get dso", dso);
+ /* override the binary type for dso data access */
+ dso__set_binary_type(dso, DSO_BINARY_TYPE__SYSTEM_PATH_DSO);
+ dso__set_bintype_searched(dso);
TEST_ASSERT_VAL("failed to add dso", !dsos__add(dsos, dso));
dso__put(dso);
}
--
2.56.0.385.gd3acb90ef8-goog