Skip to contentSkip to conversation

perf dlfilter: Add a test for object_code()

PATCH In review Adrian Hunter 2 participants 2 messages Sep 28, 2023 – Oct 12, 2023 perf events

lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

PATCH 1/1 perf dlfilter: Add a test for object_code()

Extend the "dlfilter C API" test to test
perf_dlfilter_fns.object_code().

---
 tools/perf/dlfilters/dlfilter-test-api-v0.c | 12 +++++++++++-
 tools/perf/dlfilters/dlfilter-test-api-v2.c | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/dlfilters/dlfilter-test-api-v0.c +11 -1
index 72f263d49121..4083b1abeaab 100644
@@ -289,6 +289,15 @@ static int check_attr(void *ctx)
 	return 0;
 }
 
+static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
+{
+	__u8 buf[15];
+
+	CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
+
+	return 0;
+}
+
 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
 {
 	struct filter_data *d = data;
@@ -314,7 +323,8 @@ 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) || check_address_al(ctx, sample))
+	if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
+	    check_object_code(ctx, sample))
 		return -1;
 
 	if (early)
tools/perf/dlfilters/dlfilter-test-api-v2.c +11 -1
index 38e593d92920..32ff619e881c 100644
@@ -308,6 +308,15 @@ static int check_attr(void *ctx)
 	return 0;
 }
 
+static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
+{
+	__u8 buf[15];
+
+	CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
+
+	return 0;
+}
+
 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
 {
 	struct filter_data *d = data;
@@ -333,7 +342,8 @@ 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) || check_address_al(ctx, sample))
+	if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
+	    check_object_code(ctx, sample))
 		return -1;
 
 	if (early)
Signature · 1 line
2.34.1
reviewer Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Adrian Hunter

Extend the "dlfilter C API" test to test
perf_dlfilter_fns.object_code().

Thanks,
Ian

Quoted 68 lines
---
 tools/perf/dlfilters/dlfilter-test-api-v0.c | 12 +++++++++++-
 tools/perf/dlfilters/dlfilter-test-api-v2.c | 12 +++++++++++-
 2 files changed, 22 insertions(+), 2 deletions(-)
tools/perf/dlfilters/dlfilter-test-api-v0.c +11 -1
index 72f263d49121..4083b1abeaab 100644
@@ -289,6 +289,15 @@ static int check_attr(void *ctx)
        return 0;
 }
 
+static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
+{
+       __u8 buf[15];
+
+       CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
+
+       return 0;
+}
+
 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
 {
        struct filter_data *d = data;
@@ -314,7 +323,8 @@ 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) || check_address_al(ctx, sample))
+       if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
+           check_object_code(ctx, sample))
                return -1;
 
        if (early)
tools/perf/dlfilters/dlfilter-test-api-v2.c +11 -2
index 38e593d92920..32ff619e881c 100644
@@ -308,6 +308,15 @@ static int check_attr(void *ctx)
        return 0;
 }
 
+static int check_object_code(void *ctx, const struct perf_dlfilter_sample *sample)
+{
+       __u8 buf[15];
+
+       CHECK(perf_dlfilter_fns.object_code(ctx, sample->ip, buf, sizeof(buf)) > 0);
+
+       return 0;
+}
+
 static int do_checks(void *data, const struct perf_dlfilter_sample *sample, void *ctx, bool early)
 {
        struct filter_data *d = data;
@@ -333,7 +342,8 @@ 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) || check_address_al(ctx, sample))
+       if (check_al(ctx) || check_addr_al(ctx) || check_address_al(ctx, sample) ||
+           check_object_code(ctx, sample))
                return -1;
 
        if (early)
--

2.34.1