From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 F41C5C433ED for ; Wed, 14 Apr 2021 11:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C123B6128E for ; Wed, 14 Apr 2021 11:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235313AbhDNLCa (ORCPT ); Wed, 14 Apr 2021 07:02:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21898 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235683AbhDNLC2 (ORCPT ); Wed, 14 Apr 2021 07:02:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618398127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=s8RiYmm9jnM3VI4MYAD3H3NUBQ6LI4/LRxZI2EwGDII=; b=hs232E90Hq85hBA8JMVtkx+FI3iHDw7HQKWN6+Bun+IQ3GuwtGl8Qh79NpSAtpbJhSyKml 0JdGQ/FZy8+8DHpoZkGnOAgK4XH+rGUbNArTj5Bq2Q5cnquDxNJl4wf7T/GY5zwFvbEeCe QCYyoyT6Gc6EuybVnp9EwLuwnhYjMYQ= 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-173-vCqtXdaxMeGgqVXOtvd0hg-1; Wed, 14 Apr 2021 07:02:03 -0400 X-MC-Unique: vCqtXdaxMeGgqVXOtvd0hg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5EDCF835B66; Wed, 14 Apr 2021 11:02:01 +0000 (UTC) Received: from krava (unknown [10.40.196.56]) by smtp.corp.redhat.com (Postfix) with SMTP id 40FDA83BE0; Wed, 14 Apr 2021 11:01:54 +0000 (UTC) Date: Wed, 14 Apr 2021 13:01:53 +0200 From: Jiri Olsa To: Andrii Nakryiko Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Julia Lawall Subject: Re: [PATCHv4 bpf-next 3/5] selftests/bpf: Add re-attach test to fexit_test Message-ID: References: <20210412162502.1417018-1-jolsa@kernel.org> <20210412162502.1417018-4-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, Apr 13, 2021 at 02:55:32PM -0700, Andrii Nakryiko wrote: > On Mon, Apr 12, 2021 at 9:30 AM Jiri Olsa wrote: > > > > Adding the test to re-attach (detach/attach again) tracing > > fexit programs, plus check that already linked program can't > > be attached again. > > > > Also switching to ASSERT* macros. > > > > Signed-off-by: Jiri Olsa > > --- > > .../selftests/bpf/prog_tests/fexit_test.c | 51 +++++++++++++------ > > 1 file changed, 36 insertions(+), 15 deletions(-) > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_test.c b/tools/testing/selftests/bpf/prog_tests/fexit_test.c > > index 78d7a2765c27..c48e10c138bc 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/fexit_test.c > > +++ b/tools/testing/selftests/bpf/prog_tests/fexit_test.c > > @@ -3,35 +3,56 @@ > > #include > > #include "fexit_test.skel.h" > > > > -void test_fexit_test(void) > > +static int fexit_test(struct fexit_test *fexit_skel) > > { > > - struct fexit_test *fexit_skel = NULL; > > int err, prog_fd, i; > > __u32 duration = 0, retval; > > + struct bpf_link *link; > > __u64 *result; > > > > - fexit_skel = fexit_test__open_and_load(); > > - if (CHECK(!fexit_skel, "fexit_skel_load", "fexit skeleton failed\n")) > > - goto cleanup; > > - > > err = fexit_test__attach(fexit_skel); > > - if (CHECK(err, "fexit_attach", "fexit attach failed: %d\n", err)) > > - goto cleanup; > > + if (!ASSERT_OK(err, "fexit_attach")) > > + return err; > > + > > + /* Check that already linked program can't be attached again. */ > > + link = bpf_program__attach(fexit_skel->progs.test1); > > + if (!ASSERT_ERR_PTR(link, "fexit_attach_link")) > > + return -1; > > > > prog_fd = bpf_program__fd(fexit_skel->progs.test1); > > err = bpf_prog_test_run(prog_fd, 1, NULL, 0, > > NULL, NULL, &retval, &duration); > > - CHECK(err || retval, "test_run", > > - "err %d errno %d retval %d duration %d\n", > > - err, errno, retval, duration); > > + ASSERT_OK(err || retval, "test_run"); > > same as in previous patch > > With this fixed, feel free to add my ack to this and previous patch. Thanks! ok, thanks, jirka