]> git.itanic.dy.fi Git - linux-stable/commitdiff
perf dlfilter: Add a test for resolve_address()
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 31 Jul 2023 09:18:55 +0000 (12:18 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 15 Aug 2023 19:41:48 +0000 (16:41 -0300)
Extend the "dlfilter C API" test to test
perf_dlfilter_fns.resolve_address(). The test currently fails, but passes
after a subsequent patch.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20230731091857.10681-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/dlfilters/dlfilter-test-api-v0.c

index b1f51efd67d63f84fc7653f8d68d9ebcc73a254d..72f263d491211f65de95b39eab8ec71a7d01d489 100644 (file)
@@ -254,6 +254,30 @@ static int check_addr_al(void *ctx)
        return 0;
 }
 
+static int check_address_al(void *ctx, const struct perf_dlfilter_sample *sample)
+{
+       struct perf_dlfilter_al address_al;
+       const struct perf_dlfilter_al *al;
+
+       al = perf_dlfilter_fns.resolve_ip(ctx);
+       if (!al)
+               return test_fail("resolve_ip() failed");
+
+       address_al.size = sizeof(address_al);
+       if (perf_dlfilter_fns.resolve_address(ctx, sample->ip, &address_al))
+               return test_fail("resolve_address() failed");
+
+       CHECK(address_al.sym && al->sym);
+       CHECK(!strcmp(address_al.sym, al->sym));
+       CHECK(address_al.addr == al->addr);
+       CHECK(address_al.sym_start == al->sym_start);
+       CHECK(address_al.sym_end == al->sym_end);
+       CHECK(address_al.dso && al->dso);
+       CHECK(!strcmp(address_al.dso, al->dso));
+
+       return 0;
+}
+
 static int check_attr(void *ctx)
 {
        struct perf_event_attr *attr = perf_dlfilter_fns.attr(ctx);
@@ -290,7 +314,7 @@ static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void
        if (early && !d->do_early)
                return 0;
 
-       if (check_al(ctx) || check_addr_al(ctx))
+       if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample))
                return -1;
 
        if (early)