Skip to content

Commit f38f547

Browse files
ahunter6namhyung
authored andcommitted
perf dlfilter: Add a test for object_code()
Extend the "dlfilter C API" test to test perf_dlfilter_fns.object_code(). Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Link: https://lore.kernel.org/r/20230928091033.33998-1-adrian.hunter@intel.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 7a48b58 commit f38f547

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

tools/perf/dlfilters/dlfilter-test-api-v0.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,15 @@ static int check_attr(void *ctx)
289289
return 0;
290290
}
291291

292+
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
293+
{
294+
__u8 buf[15];
295+
296+
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
297+
298+
return 0;
299+
}
300+
292301
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
293302
{
294303
struct filter_data *d = data;
@@ -314,7 +323,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
314323
if (early && !d->do_early)
315324
return 0;
316325

317-
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
326+
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
327+
check_object_code(ctx, sample))
318328
return -1;
319329

320330
if (early)

tools/perf/dlfilters/dlfilter-test-api-v2.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,15 @@ static int check_attr(void *ctx)
308308
return 0;
309309
}
310310

311+
static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
312+
{
313+
__u8 buf[15];
314+
315+
CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
316+
317+
return 0;
318+
}
319+
311320
static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
312321
{
313322
struct filter_data *d = data;
@@ -333,7 +342,8 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
333342
if (early && !d->do_early)
334343
return 0;
335344

336-
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
345+
if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
346+
check_object_code(ctx, sample))
337347
return -1;
338348

339349
if (early)

0 commit comments

Comments
 (0)