From patchwork Tue Apr 13 12:15:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 420687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18485C433ED for ; Tue, 13 Apr 2021 12:16:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E73806128E for ; Tue, 13 Apr 2021 12:16:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345482AbhDMMRC convert rfc822-to-8bit (ORCPT ); Tue, 13 Apr 2021 08:17:02 -0400 Received: from us-smtp-delivery-44.mimecast.com ([207.211.30.44]:32362 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243979AbhDMMQV (ORCPT ); Tue, 13 Apr 2021 08:16:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-6hzOu45_OQ6dHaQUMcxa7w-1; Tue, 13 Apr 2021 08:15:56 -0400 X-MC-Unique: 6hzOu45_OQ6dHaQUMcxa7w-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B2F71856A63; Tue, 13 Apr 2021 12:15:42 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.196.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id D05BE10023B0; Tue, 13 Apr 2021 12:15:38 +0000 (UTC) From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Daniel Xu , Steven Rostedt , Jesper Brouer , =?utf-8?q?Toke_H=C3=B8ilan?= =?utf-8?q?d-J=C3=B8rgensen?= , Viktor Malik Subject: [PATCHv2 RFC bpf-next 6/7] selftests/bpf: Add ftrace probe to fentry test Date: Tue, 13 Apr 2021 14:15:15 +0200 Message-Id: <20210413121516.1467989-7-jolsa@kernel.org> In-Reply-To: <20210413121516.1467989-1-jolsa@kernel.org> References: <20210413121516.1467989-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Adding 2 more tests for fentry probe test, to show/test ftrace probe. Signed-off-by: Jiri Olsa --- .../selftests/bpf/prog_tests/fentry_test.c | 5 ++++- tools/testing/selftests/bpf/progs/fentry_test.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/fentry_test.c b/tools/testing/selftests/bpf/prog_tests/fentry_test.c index 04ebbf1cb390..70f414cb3bfd 100644 --- a/tools/testing/selftests/bpf/prog_tests/fentry_test.c +++ b/tools/testing/selftests/bpf/prog_tests/fentry_test.c @@ -26,12 +26,15 @@ void test_fentry_test(void) err, errno, retval, duration); result = (__u64 *)fentry_skel->bss; - for (i = 0; i < 6; i++) { + for (i = 0; i < 8; i++) { if (CHECK(result[i] != 1, "result", "fentry_test%d failed err %lld\n", i + 1, result[i])) goto cleanup; } + ASSERT_EQ(result[8], 8, "result"); + ASSERT_EQ(result[9], 2, "result"); + cleanup: fentry_test__destroy(fentry_skel); } diff --git a/tools/testing/selftests/bpf/progs/fentry_test.c b/tools/testing/selftests/bpf/progs/fentry_test.c index 52a550d281d9..b32b589923a4 100644 --- a/tools/testing/selftests/bpf/progs/fentry_test.c +++ b/tools/testing/selftests/bpf/progs/fentry_test.c @@ -77,3 +77,19 @@ int BPF_PROG(test8, struct bpf_fentry_test_t *arg) test8_result = 1; return 0; } + +__u64 test9_result = 0; +SEC("fentry.ftrace/bpf_fentry_test*") +int BPF_PROG(test9) +{ + test9_result++; + return 0; +} + +__u64 test10_result = 0; +SEC("fentry.ftrace/bpf_fentry_test1|bpf_fentry_test2") +int BPF_PROG(test10) +{ + test10_result++; + return 0; +}