Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test dso-data: Correctly free test file in read test

The DSO data read test opens a file but as dsos__exit is used the test
file isn't closed. This causes the subsequent subtests in don't fork
(-F) mode to fail as one more than expected file descriptor is open.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250318043151.137973-4-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
ca218209 5ac22c35

+12 -12
+12 -12
tools/perf/tests/dso-data.c
··· 114 114 return fd; 115 115 } 116 116 117 + static void dsos__delete(struct dsos *dsos) 118 + { 119 + for (unsigned int i = 0; i < dsos->cnt; i++) { 120 + struct dso *dso = dsos->dsos[i]; 121 + 122 + dso__data_close(dso); 123 + unlink(dso__name(dso)); 124 + } 125 + dsos__exit(dsos); 126 + } 127 + 117 128 static int test__dso_data(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 118 129 { 119 130 struct machine machine; ··· 183 172 } 184 173 185 174 dso__put(dso); 186 - dsos__exit(&machine.dsos); 175 + dsos__delete(&machine.dsos); 187 176 unlink(file); 188 177 return 0; 189 178 } ··· 231 220 } 232 221 233 222 return 0; 234 - } 235 - 236 - static void dsos__delete(struct dsos *dsos) 237 - { 238 - for (unsigned int i = 0; i < dsos->cnt; i++) { 239 - struct dso *dso = dsos->dsos[i]; 240 - 241 - dso__data_close(dso); 242 - unlink(dso__name(dso)); 243 - } 244 - dsos__exit(dsos); 245 223 } 246 224 247 225 static int set_fd_limit(int n)