[PATCH v2 10/10] perf test: Fix dso data tests

From: Namhyung Kim

Date: Tue Oct 06 2026 - 19:46:08 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.

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

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

dso = dso__new(file);
+ /* 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);
@@ -225,6 +228,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);
+ /* 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 get dso", dso);
TEST_ASSERT_VAL("failed to add dso", !dsos__add(dsos, dso));
dso__put(dso);
--
2.56.0.rc1.315.gc6ed9934b7-goog