From patchwork Tue Nov 21 00:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuran Pereira X-Patchwork-Id: 13462337 X-Patchwork-Delegate: bpf@iogearbox.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="qxupbq0B" Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2024.outbound.protection.outlook.com [40.92.65.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 643CE95; Mon, 20 Nov 2023 16:06:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hzgozHlAs3dTrqHoiVKCE/aoQANlwC9CLIjsxpajxyiSZ3q2ZMJ9NcQeeIzo+YKGIqDTQOKyJmyBMmsPDAQVujysE6kZT0fWvPOMwzD4ORZKL2sAJE+MWB4nlLDfgnvhERCAN1rhQsXOCDMkC6A0/TXlN7aS9PysP/HvJ7yJw8wZrM8oFZ0T0othh2vmG0LOE/MxhiISLjx243Vasr5pEAajuwknv8kSaqhDGjUO047Di/sVNqikjj6Hx/yqru5PsaHFbX6COzonlEn/fvrEFxdC0v2GEA3w985kgdTdsEj+ChZJaWVgND35yncGFxJo3by18bDWnOaC4jjkiQmglA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vaWv7+gGNvT8/2OemPY/yw072DI8us4yFD0NbweDiDE=; b=Gyz+jIrKDYVwfocx9++870gn3eqk6mRlbCa+VW+JQW+El8cNpTUiPaxnLEWox2kMH0FNfFiEwSgs9b38i3/isvYtQSf8qa6Si9F6gXwduFsgniVVZvXlPWx5jZbwHXhdbiYh137Vpl5dhPCD9fc7ghVZJcrQM6sbfFpqAZJdWXZ+pw/HqHdmujl1BP14znD63DZBF/c41fB6G2OWXF3cjvvezDg5zhUryMkYa0naLraL4eNuP/q6PbNI4nhCqTUYDNLVTJzbJpoNfQGahYjOb94VWXkTX9Br2WliarWWb6krA5qcfgXQchAs9etcd7uxpiDtQk1nWli534FH7HKKVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vaWv7+gGNvT8/2OemPY/yw072DI8us4yFD0NbweDiDE=; b=qxupbq0BXyVpmu6RgF/IVq6pJNO4a4ZVKwbD+yP2l36R+RRPqfiXcsghcgZO3yws9/zGP79QOI6uvynsIIDjkWS8QutUZYoDx9DjxWVTnqj7oNK6qq1dWp+wbFmlmG15ndAkRWuCSwKQu4JTryS8wGNgDm9TIf5c4JycyGW9eqMcUwUXKH1VDdqrQ1XBomttS/uyB12zSYWpnpsFwBQ14wCdFC+Yt3Qf6ZCQ1yEkO6tX0s8mv77tzbKrd6aCJ/x6IZ29nPqD7YOLhGk45RGdu+hG8vJxwGiDmx7s/F+jwQfOn/yPV/E2i8k0mJKIZuIMw/0S6WLBqGbd573+k03aCQ== Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) by AS2PR10MB7477.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:593::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 00:06:16 +0000 Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450]) by GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450%7]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 00:06:16 +0000 From: Yuran Pereira To: bpf@vger.kernel.org Cc: Yuran Pereira , andrii@kernel.org, ast@kernel.org, haoluo@google.com, john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, sdf@google.com, shuah@kernel.org, song@kernel.org, yonghong.song@linux.dev Subject: [PATCH bpf-next v3 1/4] selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bpf_tcp_ca Date: Tue, 21 Nov 2023 05:35:39 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [fHMVdpxwz9OQbya4iq+gaB9tclLMjrvM] X-ClientProxiedBy: JNXP275CA0036.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:18::24) To GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) X-Microsoft-Original-Message-ID: <20231121000539.421270-1-yuran.pereira@hotmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR10MB6563:EE_|AS2PR10MB7477:EE_ X-MS-Office365-Filtering-Correlation-Id: 85d6a93e-04b8-4a47-968e-08dbea25adda X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2bPTRemX/EeOyugDR2WqaarU5qbuNPJBg2q82L5fx713soOye1VZOVgVGDp7H3Ay3Zk7AaJVmSzayMbI6zBg0AaINBG0GHtpYZogyAP1HcM1VjNO8lU0rpD3Wt5HmIAh8VeBLMjW2Rxs9vzwwAdStkGnXB5EpidnhZAHsgdemvoT2BhEGU9d0QxB6476yAFUOi2/btE4eGC3OCaTgDDJTcEhQkc8cmFlxVL3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Mwu7yoRDEFfw0c95WRFMh9aTmr2coUYZ5BLq+opRfRTOVIjaZA+WCJhgkJUDfkUoD8rdD5+CUcMOiGU6b0qL0kRoGz52opcnSKZjTDd9x40Q5Ih8za/XsCW7wpxzUWc6b7i1Jr2G5j5I8W5YoDiW4QMQ7JhuOTiXxe6YpLDzJVpANa5VK8Ey269akcEz1ptyBo6NeLlb6dZvq5cjigKaA5QefV/x5RnY0Xj533s7BRugFLpILTIzMNxJHkD7qtT5m9iovTYSig/wHsnLD5IbBPB/udt840By2MWlQL2Q2p5V+XwUWWnqzC1mqGbAMVUUwpt+aMN2IBk8dRj2Dzh1W4A68uHKkLIavl6dWXBty2QdLFR48oPjxd7nAkZdK6w3Ql3oxl8DoC4WSfDzuzDP0RKfOvdYnwCsgBcH7EI1ll/whOxABAUCc5iNX+cawz4zpJg9NVEd+CSb2yWEH7qx6tjqrfLtOzezYyNMu9GhcBxqbdwigrPmtTCKWes/9gV/C2pYSiJWI7iRLPmhnZFQzPH6vcMzb3HX3ck6gBWxww4dyT5hYCl9a2Da6W+OZ1mDbTSIoutmmWYmfrv1/P0ETsspsKDXT8pKMLEIg= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 85d6a93e-04b8-4a47-968e-08dbea25adda X-MS-Exchange-CrossTenant-AuthSource: GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 00:06:16.0149 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR10MB7477 X-Patchwork-Delegate: bpf@iogearbox.net bpf_tcp_ca uses the `CHECK` calls even though the use of ASSERT_ series of macros is preferred in the bpf selftests. This patch replaces all `CHECK` calls for equivalent `ASSERT_` macro calls. Signed-off-by: Yuran Pereira --- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index 4aabeaa525d4..a88e6e07e4f5 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -20,15 +20,14 @@ static const unsigned int total_bytes = 10 * 1024 * 1024; static int expected_stg = 0xeB9F; -static int stop, duration; +static int stop; static int settcpca(int fd, const char *tcp_ca) { int err; err = setsockopt(fd, IPPROTO_TCP, TCP_CONGESTION, tcp_ca, strlen(tcp_ca)); - if (CHECK(err == -1, "setsockopt(fd, TCP_CONGESTION)", "errno:%d\n", - errno)) + if (!ASSERT_NEQ(err, -1, "setsockopt")) return -1; return 0; @@ -65,8 +64,7 @@ static void *server(void *arg) bytes += nr_sent; } - CHECK(bytes != total_bytes, "send", "%zd != %u nr_sent:%zd errno:%d\n", - bytes, total_bytes, nr_sent, errno); + ASSERT_EQ(bytes, total_bytes, "send"); done: if (fd >= 0) @@ -92,10 +90,11 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) WRITE_ONCE(stop, 0); lfd = socket(AF_INET6, SOCK_STREAM, 0); - if (CHECK(lfd == -1, "socket", "errno:%d\n", errno)) + if (!ASSERT_NEQ(lfd, -1, "socket")) return; + fd = socket(AF_INET6, SOCK_STREAM, 0); - if (CHECK(fd == -1, "socket", "errno:%d\n", errno)) { + if (!ASSERT_NEQ(fd, -1, "socket")) { close(lfd); return; } @@ -108,26 +107,27 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) sa6.sin6_family = AF_INET6; sa6.sin6_addr = in6addr_loopback; err = bind(lfd, (struct sockaddr *)&sa6, addrlen); - if (CHECK(err == -1, "bind", "errno:%d\n", errno)) + if (!ASSERT_NEQ(err, -1, "bind")) goto done; + err = getsockname(lfd, (struct sockaddr *)&sa6, &addrlen); - if (CHECK(err == -1, "getsockname", "errno:%d\n", errno)) + if (!ASSERT_NEQ(err, -1, "getsockname")) goto done; + err = listen(lfd, 1); - if (CHECK(err == -1, "listen", "errno:%d\n", errno)) + if (!ASSERT_NEQ(err, -1, "listen")) goto done; if (sk_stg_map) { err = bpf_map_update_elem(bpf_map__fd(sk_stg_map), &fd, &expected_stg, BPF_NOEXIST); - if (CHECK(err, "bpf_map_update_elem(sk_stg_map)", - "err:%d errno:%d\n", err, errno)) + if (!ASSERT_OK(err, "bpf_map_update_elem(sk_stg_map)")) goto done; } /* connect to server */ err = connect(fd, (struct sockaddr *)&sa6, addrlen); - if (CHECK(err == -1, "connect", "errno:%d\n", errno)) + if (!ASSERT_NEQ(err, -1, "connect")) goto done; if (sk_stg_map) { @@ -135,14 +135,13 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) err = bpf_map_lookup_elem(bpf_map__fd(sk_stg_map), &fd, &tmp_stg); - if (CHECK(!err || errno != ENOENT, - "bpf_map_lookup_elem(sk_stg_map)", - "err:%d errno:%d\n", err, errno)) + if (!ASSERT_ERR(err, "bpf_map_lookup_elem(sk_stg_map)") || + !ASSERT_EQ(errno, ENOENT, "bpf_map_lookup_elem(sk_stg_map)")) goto done; } err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd); - if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno)) + if (!ASSERT_OK(err, "pthread_create")) goto done; /* recv total_bytes */ @@ -156,13 +155,12 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) bytes += nr_recv; } - CHECK(bytes != total_bytes, "recv", "%zd != %u nr_recv:%zd errno:%d\n", - bytes, total_bytes, nr_recv, errno); + ASSERT_EQ(bytes, total_bytes, "recv"); WRITE_ONCE(stop, 1); pthread_join(srv_thread, &thread_ret); - CHECK(IS_ERR(thread_ret), "pthread_join", "thread_ret:%ld", - PTR_ERR(thread_ret)); + ASSERT_OK(IS_ERR(thread_ret), "thread_ret"); + done: close(lfd); close(fd); @@ -174,7 +172,7 @@ static void test_cubic(void) struct bpf_link *link; cubic_skel = bpf_cubic__open_and_load(); - if (CHECK(!cubic_skel, "bpf_cubic__open_and_load", "failed\n")) + if (!ASSERT_OK_PTR(cubic_skel, "bpf_cubic__open_and_load")) return; link = bpf_map__attach_struct_ops(cubic_skel->maps.cubic); @@ -197,7 +195,7 @@ static void test_dctcp(void) struct bpf_link *link; dctcp_skel = bpf_dctcp__open_and_load(); - if (CHECK(!dctcp_skel, "bpf_dctcp__open_and_load", "failed\n")) + if (!ASSERT_OK_PTR(dctcp_skel, "bpf_dctcp__open_and_load")) return; link = bpf_map__attach_struct_ops(dctcp_skel->maps.dctcp); @@ -207,9 +205,7 @@ static void test_dctcp(void) } do_test("bpf_dctcp", dctcp_skel->maps.sk_stg_map); - CHECK(dctcp_skel->bss->stg_result != expected_stg, - "Unexpected stg_result", "stg_result (%x) != expected_stg (%x)\n", - dctcp_skel->bss->stg_result, expected_stg); + ASSERT_EQ(dctcp_skel->bss->stg_result, expected_stg, "stg_result"); bpf_link__destroy(link); bpf_dctcp__destroy(dctcp_skel); From patchwork Tue Nov 21 00:07:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuran Pereira X-Patchwork-Id: 13462343 X-Patchwork-Delegate: bpf@iogearbox.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="RdqNrDBU" Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2023.outbound.protection.outlook.com [40.92.65.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5FF95; Mon, 20 Nov 2023 16:08:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONnCQzX4mhqXBl9w1jMM8Blf1PUZBMtHKeFutj2w/65zbQQi6i96ygQsU0QtLtyPo53RI9JkJzeabc+cbP2Q8jNu0nd7gZKYwh0X5DLd5am7kF6kFK1tNeIBVoX6AvCtQedVNhqakAMpqwi2gQIwsDYs/o4Jx8EZ/4gxyjgLQLRsOCau7tDdTgwYGNw059q3mw5YvYMWKKDnHO7KzhKmFznUhZCSRI66NEffieHWFBwUqVFf+nOlD+T54dDIxyItejVbcS5P+Wx+TCDi/KrnvUY/vBPjlj/ATtJOExz6AFx/EONr9DgwzNKHEWBKLa8nMx7iAuiimd7CsJXrkYaQxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mpgZioiHFXVOmVOt3m5Jvrrc9VUKdE04J+X25ImEGOc=; b=mLIQ4N6dYm2ky3YdfpOJImZarbb68DG9/BFPmzD6Y4sqGAIP3Jc3bEj6VxJovOwZxA8B1HwGO+bQx2jwxDGd+qckqbknYm6llDeBwE6sfln/vcmU4DSWKfWTUxvr1mSiJStTgGUol2tcuHW1JWtTzxBlJ3gZ7SL1DQ571UkeC6t/c2dOaHppJZrT6FNLm7ZO5aWXGeHSz5h8Vq3yFgScA9xE9aTCf4jvc/XYxM7CITblZuEzbTlYnOVmLGoAjkRV/8zr3W/2FlrYfXjv1rOpshPyuaU6Fh7xe22aWArfFi2FIPyeFprfu2vMngvEbBbffvJ21TN/mctPARBOAKXTGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mpgZioiHFXVOmVOt3m5Jvrrc9VUKdE04J+X25ImEGOc=; b=RdqNrDBUval7utcV7TmPI+q38QxlJvDBSi9fm2Eut7YKujK1i6UWoDs28BGOvhuDlLzeqWmLxZA7rnE9JRnLTsp01YIQXoW6lI7YIvWLXIjNeWuHwu77O2Nj36TjR6cm85jW0JMTeNoIS4mX0y8GAmsyBVVuE28FWpKGNUC1i5+1pWiJQtgxTDD3DGdGOLH0ST7peIExDUwIkfBAZomykS9QP++p0HHGDbzX6BYBWehKEzc2gTUCfZKHpDl+NWrIS7g1wTQwcBLieGZmpgk+oEmmN3wfksezDurtY5i9NvMcf4H+8NcUCX/h+cy1fViOjCOi8RozFgTfGFekxR/fDQ== Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) by AS2PR10MB7477.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:593::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 00:08:13 +0000 Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450]) by GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450%7]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 00:08:13 +0000 From: Yuran Pereira To: bpf@vger.kernel.org Cc: Yuran Pereira , andrii@kernel.org, ast@kernel.org, haoluo@google.com, john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, sdf@google.com, shuah@kernel.org, song@kernel.org, yonghong.song@linux.dev Subject: [PATCH bpf-next v3 2/4] selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bind_perm Date: Tue, 21 Nov 2023 05:37:43 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [cfuuiBYTyYKY8XKatAoyLyXoEV6aUwGc] X-ClientProxiedBy: JNXP275CA0008.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::20) To GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) X-Microsoft-Original-Message-ID: <20231121000743.421363-1-yuran.pereira@hotmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR10MB6563:EE_|AS2PR10MB7477:EE_ X-MS-Office365-Filtering-Correlation-Id: a3c6f762-e668-4fd6-2521-08dbea25f3df X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Qeiej13jVPmQodDHaJ+4NKCSLSzWgamDzeCNgF7tBZCA+wFF69Byki2CLQDO2kw/boLWe30zY/sJJxRpI7nl+2utEWH8pcp1apSbNBXRzj1YliOsE8OaAyA/kl5LSOg3NM5IEMbKr8jOZoVqjtFdudpuQyAXqRGTf5xqK9ud+BMrjzSu1uRbsZGLIt4gtdy9mLq8IB9fKXjVRw20AfNcPP8Fz3c8Qm2GXfoR3VWrXunTxcYmtXvqddsvDrGXtAOPfEtZxV5M7eR7qglB58WKG9kKeclusJQzBwhw2Nz+QV4LjApRgNLEsEamp4wGfAUSWscHzbvBaM5r4uc4QDTwiofG9eYpcOKlJvJP402DoElDLUm5FLgqhCYEtSUlN+6SOEEGGnmzY2jSe9Deuh8g5LRZNbUOjSPXESwpUs5RP1LlRbkyAONu6GPdxhUCt/O2nSZ0zXhV8HJvaXwPPDuBEnIJmhiWk8jE3gXxTlPfZbjfXksANNemf5B3RX2XDi8LpNBYfLeq6yRBSabm6CLe2ZDcR8cWukRMjG+3F9657Hm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YZbFbxx/RTqUlDkpTwoJGR8tL2ztuymD++LT1OKwxBWPeZe8WnshlFx8hbFwr/Oxi2wx/Z9uUAKo2iZEFhk6TIyqRPt5OKPATeV8555hcbqWWaLxCixf0+/JNjseUIzCnz5dM8f799s9vp3nYSeF7kGonaFdbO8f1DiCEV9BOO5FSz6JNi7HsrZObjzH04qCIbNpMI9iuxvPFtNKR1UwroVjHGAL+ZpFVJYc39uuHwApRg/GIVg3XH1lJoqaQD2Xgzpplb1GVB4PhEWgQxY4DCpRctKmNArC09+6vtJ5oi7INZl//3m1PhVkPdehotj33g= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: a3c6f762-e668-4fd6-2521-08dbea25f3df X-MS-Exchange-CrossTenant-AuthSource: GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 00:08:13.2656 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR10MB7477 X-Patchwork-Delegate: bpf@iogearbox.net bind_perm uses the `CHECK` calls even though the use of ASSERT_ series of macros is preferred in the bpf selftests. This patch replaces all `CHECK` calls for equivalent `ASSERT_` macro calls. Signed-off-by: Yuran Pereira --- tools/testing/selftests/bpf/prog_tests/bind_perm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bind_perm.c b/tools/testing/selftests/bpf/prog_tests/bind_perm.c index a1766a298bb7..f7cd129cb82b 100644 --- a/tools/testing/selftests/bpf/prog_tests/bind_perm.c +++ b/tools/testing/selftests/bpf/prog_tests/bind_perm.c @@ -9,8 +9,6 @@ #include "cap_helpers.h" #include "bind_perm.skel.h" -static int duration; - static int create_netns(void) { if (!ASSERT_OK(unshare(CLONE_NEWNET), "create netns")) @@ -27,7 +25,7 @@ void try_bind(int family, int port, int expected_errno) int fd = -1; fd = socket(family, SOCK_STREAM, 0); - if (CHECK(fd < 0, "fd", "errno %d", errno)) + if (!ASSERT_GE(fd, 0, "socket")) goto close_socket; if (family == AF_INET) { @@ -60,7 +58,7 @@ void test_bind_perm(void) return; cgroup_fd = test__join_cgroup("/bind_perm"); - if (CHECK(cgroup_fd < 0, "cg-join", "errno %d", errno)) + if (!ASSERT_GE(cgroup_fd, 0, "test__join_cgroup")) return; skel = bind_perm__open_and_load(); From patchwork Tue Nov 21 00:09:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuran Pereira X-Patchwork-Id: 13462344 X-Patchwork-Delegate: bpf@iogearbox.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="R52DQcZa" Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2072.outbound.protection.outlook.com [40.92.65.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFD597; Mon, 20 Nov 2023 16:09:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YHFA8h3tQIqOXD/Jg0NN8XSoLX1R34y0sXftg7PPrnxg9b+PlSOwH9L0m0IRK+3FrWFCPMJ3RrYzrKDvcLb7W+qLDaGDe1IGMuIWr7bmk1rA3Zaox14gdjMdoGHzlv91m4TJhZV+h85uXPCSEEgewV45T2B4kpwFIWSVNFem9tmPHbwrPhP1CZ7zVsot5e7RoFoTA9VMaTbYL696RJMIJsJIuZkFGMMMOAK7K89ADkC+ncvrdIRI/i/piqn9nAEnslbY0rJDyd58zJFv1rMm1YKbJ+eOtmnrYe7AmR1yYqVgEpOFqVXyjNIP+oChpMjUQdLoUEef16/XGu4/haiG/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=piQaToojm3qbR2rRzMqggkfCTjcB4RS+/8/vAQe8Fwo=; b=ZMosWzYzBUab5ldb8mHB6tOdCrngtHVUVq0tK3d++xScpOmSomQSeet0XR4oT5GQ92x0BK7eSKWLEVpD5bPCXHxG9O11tkpTdFbifPBdSWVpTE7TFZAazsO4oogeYHsIwTDe9mKealvow3cxvxGWKG5MRAKIiVosSKVQnkKclG2KursqvIgZ9nFPJI6YXl19MbyjpCoppXoHqZFA5P2XbinHSQCxKqQzRzGWl5qwuaZ0/i6C9Uo4QDJk8z6nc08fopNcJ7s/O/ODPwr0W+xvthLi9fQENXQuKG489rfgTUbfZUVa6mH9vq3BAbsxhq7IkYGbAJaLkYXxgEvJFXIKdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=piQaToojm3qbR2rRzMqggkfCTjcB4RS+/8/vAQe8Fwo=; b=R52DQcZaYgsZPh6hy9sRQpzlFQlAzh7rgaAd7OMKtNwYK3mSxx39hhXSq0aRV3lr+9u5CIiTRkutZRmGd4lUCOBNwr6w1af4gS+IWhBU8mPzo58mpPEaJqqyiLAVEVZ+OQMiKKu1RSf5Iqab4e1LyRE+9X4X9ZbliwZbwydG2orSb1kWhwDjNRMx3a8MCOuKxrfuXMU78v3xNYpgaCQ+fhF66wPZMSlp2ZZ6UaYjNmVp+dWwbYlOi72/D7qOYEUfOhx8QR1KcJesljMq1Z2H7O2F7kGFwTkXYZabg/PdFkWSE9FSl28KuQDvDuyVq7qr0REsTIGGrpCHAzKCCxHELg== Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) by AS2PR10MB7477.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:593::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 00:09:46 +0000 Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450]) by GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450%7]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 00:09:46 +0000 From: Yuran Pereira To: bpf@vger.kernel.org Cc: Yuran Pereira , andrii@kernel.org, ast@kernel.org, haoluo@google.com, john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, sdf@google.com, shuah@kernel.org, song@kernel.org, yonghong.song@linux.dev Subject: [PATCH bpf-next v3 3/4] selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bpf_obj_id Date: Tue, 21 Nov 2023 05:39:25 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [NajEpF/15VQGibqeRjjpOpWyx+Xkwigd] X-ClientProxiedBy: JN2P275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:3::32) To GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) X-Microsoft-Original-Message-ID: <20231121000925.421563-1-yuran.pereira@hotmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR10MB6563:EE_|AS2PR10MB7477:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f54da95-3361-4401-9020-08dbea262b4b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QyexJDEA6BA6k+s0jNs/7nMN9DGJw/l7oyk+t8JFvQYUbfqNvQ0KTJNlPn5HyCN2UGnJT4SPG+zHEA0GZhDPjVIv+qdoSAMQkHN3FM+rIR4veGFskMWLK8U++2Ez1WJFB46JO8lFOFeBxqST8lmMaJd37m1iJZ+hJ+prM0yl4/qDE6BjV2kRN+et5c8qp6mF2fFY8iBK2qtOUd0obG1YG6V/4gogQ6Jzm93RbnWbi9CqyOYzCqvIWr6XnB+Om39JZgYriA/ulITyT+JGISo50y0J2w5nhlERlEeK4qVtYLbxPpfvo0FQC0WBol3NUonlQfp2bLqCaxE/vm2/H5wn1JF00q6JV6hY4Tszf9JZo3SmDM4NU8t36umWKw5hmmvTnMkR9W92YBMo6CDLVR0a+Dw0bew53AIYJD3K3xfgwoYOMJf7qJbv2B7/FD/AD5edOyYe80HpImVCkZCdxxaFbrr3QuHr5Gr2Nd59AhZhLqONvcS4z3dCH7uom5msR0hEKwHGGkDzUqGjBLHveVdDSQi9Lp0jTuU7f1m6DmkSsvDnL94sB0eTZu3+EnPw/M+XTTUiX68Vfl73WekxNtEc7N2W2dhR+nTkdbLOOT/OrcxsnTx/bzHtD4uJ7HC0UoZ6 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: okkMx7hKCFFMcW9vv8jitpBWJlwFhsQT/iA9olDZErc7zcMJvPOQOpNoLb1rJPfWS5iTbiToHdc3ay1JnQn791Do/dLbGCBB/MvZ4zU8FYhqlaOA9TVmMeIGvSeLBySXkS2hvgAWcAtZiVXEXzARV1JWnt3giiivaBobFtiafmchWoOnl8f4Z9xtuT/MN+of+/Q4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755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 2f54da95-3361-4401-9020-08dbea262b4b X-MS-Exchange-CrossTenant-AuthSource: GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 00:09:46.4252 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR10MB7477 X-Patchwork-Delegate: bpf@iogearbox.net bpf_obj_id uses the `CHECK` calls even though the use of ASSERT_ series of macros is preferred in the bpf selftests. This patch replaces all `CHECK` calls for equivalent `ASSERT_` macro calls. Signed-off-by: Yuran Pereira --- .../selftests/bpf/prog_tests/bpf_obj_id.c | 204 +++++++----------- 1 file changed, 73 insertions(+), 131 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c index 675b90b15280..986fb8429b22 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c @@ -25,7 +25,7 @@ void serial_test_bpf_obj_id(void) */ __u32 map_ids[nr_iters + 1]; char jited_insns[128], xlated_insns[128], zeros[128], tp_name[128]; - __u32 i, next_id, info_len, nr_id_found, duration = 0; + __u32 i, next_id, info_len, nr_id_found; struct timespec real_time_ts, boot_time_ts; int err = 0; __u64 array_value; @@ -33,16 +33,16 @@ void serial_test_bpf_obj_id(void) time_t now, load_time; err = bpf_prog_get_fd_by_id(0); - CHECK(err >= 0 || errno != ENOENT, - "get-fd-by-notexist-prog-id", "err %d errno %d\n", err, errno); + ASSERT_LT(err, 0, "bpf_prog_get_fd_by_id"); + ASSERT_EQ(errno, ENOENT, "bpf_prog_get_fd_by_id"); err = bpf_map_get_fd_by_id(0); - CHECK(err >= 0 || errno != ENOENT, - "get-fd-by-notexist-map-id", "err %d errno %d\n", err, errno); + ASSERT_LT(err, 0, "bpf_map_get_fd_by_id"); + ASSERT_EQ(errno, ENOENT, "bpf_map_get_fd_by_id"); err = bpf_link_get_fd_by_id(0); - CHECK(err >= 0 || errno != ENOENT, - "get-fd-by-notexist-link-id", "err %d errno %d\n", err, errno); + ASSERT_LT(err, 0, "bpf_map_get_fd_by_id"); + ASSERT_EQ(errno, ENOENT, "bpf_map_get_fd_by_id"); /* Check bpf_map_get_info_by_fd() */ bzero(zeros, sizeof(zeros)); @@ -53,25 +53,26 @@ void serial_test_bpf_obj_id(void) /* test_obj_id.o is a dumb prog. It should never fail * to load. */ - if (CHECK_FAIL(err)) + if (!ASSERT_OK(err, "bpf_prog_test_load")) continue; /* Insert a magic value to the map */ map_fds[i] = bpf_find_map(__func__, objs[i], "test_map_id"); - if (CHECK_FAIL(map_fds[i] < 0)) + if (!ASSERT_GE(map_fds[i], 0, "bpf_find_map")) goto done; + err = bpf_map_update_elem(map_fds[i], &array_key, &array_magic_value, 0); - if (CHECK_FAIL(err)) + if (!ASSERT_OK(err, "bpf_map_update_elem")) goto done; - prog = bpf_object__find_program_by_name(objs[i], - "test_obj_id"); - if (CHECK_FAIL(!prog)) + prog = bpf_object__find_program_by_name(objs[i], "test_obj_id"); + if (!ASSERT_OK_PTR(prog, "bpf_object__find_program_by_name")) goto done; + links[i] = bpf_program__attach(prog); err = libbpf_get_error(links[i]); - if (CHECK(err, "prog_attach", "prog #%d, err %d\n", i, err)) { + if (!ASSERT_OK(err, "bpf_program__attach")) { links[i] = NULL; goto done; } @@ -81,24 +82,14 @@ void serial_test_bpf_obj_id(void) bzero(&map_infos[i], info_len); err = bpf_map_get_info_by_fd(map_fds[i], &map_infos[i], &info_len); - if (CHECK(err || - map_infos[i].type != BPF_MAP_TYPE_ARRAY || - map_infos[i].key_size != sizeof(__u32) || - map_infos[i].value_size != sizeof(__u64) || - map_infos[i].max_entries != 1 || - map_infos[i].map_flags != 0 || - info_len != sizeof(struct bpf_map_info) || - strcmp((char *)map_infos[i].name, expected_map_name), - "get-map-info(fd)", - "err %d errno %d type %d(%d) info_len %u(%zu) key_size %u value_size %u max_entries %u map_flags %X name %s(%s)\n", - err, errno, - map_infos[i].type, BPF_MAP_TYPE_ARRAY, - info_len, sizeof(struct bpf_map_info), - map_infos[i].key_size, - map_infos[i].value_size, - map_infos[i].max_entries, - map_infos[i].map_flags, - map_infos[i].name, expected_map_name)) + if (!ASSERT_OK(err, "bpf_map_get_info_by_fd") || + !ASSERT_EQ(map_infos[i].type, BPF_MAP_TYPE_ARRAY, "map_type") || + !ASSERT_EQ(map_infos[i].key_size, sizeof(__u32), "key_size") || + !ASSERT_EQ(map_infos[i].value_size, sizeof(__u64), "value_size") || + !ASSERT_EQ(map_infos[i].max_entries, 1, "max_entries") || + !ASSERT_EQ(map_infos[i].map_flags, 0, "map_flags") || + !ASSERT_EQ(info_len, sizeof(struct bpf_map_info), "map_info_len") || + !ASSERT_STREQ((char *)map_infos[i].name, expected_map_name, "map_name")) goto done; /* Check getting prog info */ @@ -112,48 +103,34 @@ void serial_test_bpf_obj_id(void) prog_infos[i].xlated_prog_len = sizeof(xlated_insns); prog_infos[i].map_ids = ptr_to_u64(map_ids + i); prog_infos[i].nr_map_ids = 2; + err = clock_gettime(CLOCK_REALTIME, &real_time_ts); - if (CHECK_FAIL(err)) + if (!ASSERT_OK(err, "clock_gettime")) goto done; + err = clock_gettime(CLOCK_BOOTTIME, &boot_time_ts); - if (CHECK_FAIL(err)) + if (!ASSERT_OK(err, "clock_gettime")) goto done; + err = bpf_prog_get_info_by_fd(prog_fds[i], &prog_infos[i], &info_len); load_time = (real_time_ts.tv_sec - boot_time_ts.tv_sec) + (prog_infos[i].load_time / nsec_per_sec); - if (CHECK(err || - prog_infos[i].type != BPF_PROG_TYPE_RAW_TRACEPOINT || - info_len != sizeof(struct bpf_prog_info) || - (env.jit_enabled && !prog_infos[i].jited_prog_len) || - (env.jit_enabled && - !memcmp(jited_insns, zeros, sizeof(zeros))) || - !prog_infos[i].xlated_prog_len || - !memcmp(xlated_insns, zeros, sizeof(zeros)) || - load_time < now - 60 || load_time > now + 60 || - prog_infos[i].created_by_uid != my_uid || - prog_infos[i].nr_map_ids != 1 || - *(int *)(long)prog_infos[i].map_ids != map_infos[i].id || - strcmp((char *)prog_infos[i].name, expected_prog_name), - "get-prog-info(fd)", - "err %d errno %d i %d type %d(%d) info_len %u(%zu) " - "jit_enabled %d jited_prog_len %u xlated_prog_len %u " - "jited_prog %d xlated_prog %d load_time %lu(%lu) " - "uid %u(%u) nr_map_ids %u(%u) map_id %u(%u) " - "name %s(%s)\n", - err, errno, i, - prog_infos[i].type, BPF_PROG_TYPE_SOCKET_FILTER, - info_len, sizeof(struct bpf_prog_info), - env.jit_enabled, - prog_infos[i].jited_prog_len, - prog_infos[i].xlated_prog_len, - !!memcmp(jited_insns, zeros, sizeof(zeros)), - !!memcmp(xlated_insns, zeros, sizeof(zeros)), - load_time, now, - prog_infos[i].created_by_uid, my_uid, - prog_infos[i].nr_map_ids, 1, - *(int *)(long)prog_infos[i].map_ids, map_infos[i].id, - prog_infos[i].name, expected_prog_name)) + + if (!ASSERT_OK(err, "bpf_prog_get_info_by_fd") || + !ASSERT_EQ(prog_infos[i].type, BPF_PROG_TYPE_RAW_TRACEPOINT, "prog_type") || + !ASSERT_EQ(info_len, sizeof(struct bpf_prog_info), "prog_info_len") || + !ASSERT_FALSE((env.jit_enabled && !prog_infos[i].jited_prog_len), "jited_prog_len") || + !ASSERT_FALSE((env.jit_enabled && !memcmp(jited_insns, zeros, sizeof(zeros))), + "jited_insns") || + !ASSERT_NEQ(prog_infos[i].xlated_prog_len, 0, "xlated_prog_len") || + !ASSERT_NEQ(memcmp(xlated_insns, zeros, sizeof(zeros)), 0, "xlated_insns") || + !ASSERT_GE(load_time, (now - 60), "load_time") || + !ASSERT_LE(load_time, (now + 60), "load_time") || + !ASSERT_EQ(prog_infos[i].created_by_uid, my_uid, "created_by_uid") || + !ASSERT_EQ(prog_infos[i].nr_map_ids, 1, "nr_map_ids") || + !ASSERT_EQ(*(int *)(long)prog_infos[i].map_ids, map_infos[i].id, "map_ids") || + !ASSERT_STREQ((char *)prog_infos[i].name, expected_prog_name, "prog_name")) goto done; /* Check getting link info */ @@ -163,25 +140,12 @@ void serial_test_bpf_obj_id(void) link_infos[i].raw_tracepoint.tp_name_len = sizeof(tp_name); err = bpf_link_get_info_by_fd(bpf_link__fd(links[i]), &link_infos[i], &info_len); - if (CHECK(err || - link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT || - link_infos[i].prog_id != prog_infos[i].id || - link_infos[i].raw_tracepoint.tp_name != ptr_to_u64(&tp_name) || - strcmp(u64_to_ptr(link_infos[i].raw_tracepoint.tp_name), - "sys_enter") || - info_len != sizeof(struct bpf_link_info), - "get-link-info(fd)", - "err %d errno %d info_len %u(%zu) type %d(%d) id %d " - "prog_id %d (%d) tp_name %s(%s)\n", - err, errno, - info_len, sizeof(struct bpf_link_info), - link_infos[i].type, BPF_LINK_TYPE_RAW_TRACEPOINT, - link_infos[i].id, - link_infos[i].prog_id, prog_infos[i].id, - (const char *)u64_to_ptr(link_infos[i].raw_tracepoint.tp_name), - "sys_enter")) + if (!ASSERT_OK(err, "bpf_link_get_info_by_fd") || + !ASSERT_EQ(link_infos[i].type, BPF_LINK_TYPE_RAW_TRACEPOINT, "link_type") || + !ASSERT_EQ(link_infos[i].prog_id, prog_infos[i].id, "prog_id") || + !ASSERT_EQ(link_infos[i].raw_tracepoint.tp_name, ptr_to_u64(&tp_name), "&tp_name") || + !ASSERT_STREQ(u64_to_ptr(link_infos[i].raw_tracepoint.tp_name), "sys_enter", "tp_name")) goto done; - } /* Check bpf_prog_get_next_id() */ @@ -190,7 +154,7 @@ void serial_test_bpf_obj_id(void) while (!bpf_prog_get_next_id(next_id, &next_id)) { struct bpf_prog_info prog_info = {}; __u32 saved_map_id; - int prog_fd; + int prog_fd, cmp_res; info_len = sizeof(prog_info); @@ -198,9 +162,7 @@ void serial_test_bpf_obj_id(void) if (prog_fd < 0 && errno == ENOENT) /* The bpf_prog is in the dead row */ continue; - if (CHECK(prog_fd < 0, "get-prog-fd(next_id)", - "prog_fd %d next_id %d errno %d\n", - prog_fd, next_id, errno)) + if (!ASSERT_GE(prog_fd, 0, "bpf_prog_get_fd_by_id")) break; for (i = 0; i < nr_iters; i++) @@ -218,9 +180,8 @@ void serial_test_bpf_obj_id(void) */ prog_info.nr_map_ids = 1; err = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &info_len); - if (CHECK(!err || errno != EFAULT, - "get-prog-fd-bad-nr-map-ids", "err %d errno %d(%d)", - err, errno, EFAULT)) + if (!ASSERT_ERR(err, "bpf_prog_get_info_by_fd") || + !ASSERT_EQ(errno, EFAULT, "bpf_prog_get_info_by_fd")) break; bzero(&prog_info, sizeof(prog_info)); info_len = sizeof(prog_info); @@ -231,27 +192,22 @@ void serial_test_bpf_obj_id(void) err = bpf_prog_get_info_by_fd(prog_fd, &prog_info, &info_len); prog_infos[i].jited_prog_insns = 0; prog_infos[i].xlated_prog_insns = 0; - CHECK(err || info_len != sizeof(struct bpf_prog_info) || - memcmp(&prog_info, &prog_infos[i], info_len) || - *(int *)(long)prog_info.map_ids != saved_map_id, - "get-prog-info(next_id->fd)", - "err %d errno %d info_len %u(%zu) memcmp %d map_id %u(%u)\n", - err, errno, info_len, sizeof(struct bpf_prog_info), - memcmp(&prog_info, &prog_infos[i], info_len), - *(int *)(long)prog_info.map_ids, saved_map_id); + cmp_res = memcmp(&prog_info, &prog_infos[i], info_len); + + ASSERT_OK(err, "bpf_prog_get_info_by_fd"); + ASSERT_EQ(info_len, sizeof(struct bpf_prog_info), "prog_info_len"); + ASSERT_OK(cmp_res, "memcmp"); + ASSERT_EQ(*(int *)(long)prog_info.map_ids, saved_map_id, "map_id"); close(prog_fd); } - CHECK(nr_id_found != nr_iters, - "check total prog id found by get_next_id", - "nr_id_found %u(%u)\n", - nr_id_found, nr_iters); + ASSERT_EQ(nr_id_found, nr_iters, "prog_nr_id_found"); /* Check bpf_map_get_next_id() */ nr_id_found = 0; next_id = 0; while (!bpf_map_get_next_id(next_id, &next_id)) { struct bpf_map_info map_info = {}; - int map_fd; + int map_fd, cmp_res; info_len = sizeof(map_info); @@ -259,9 +215,7 @@ void serial_test_bpf_obj_id(void) if (map_fd < 0 && errno == ENOENT) /* The bpf_map is in the dead row */ continue; - if (CHECK(map_fd < 0, "get-map-fd(next_id)", - "map_fd %d next_id %u errno %d\n", - map_fd, next_id, errno)) + if (!ASSERT_GE(map_fd, 0, "bpf_map_get_fd_by_id")) break; for (i = 0; i < nr_iters; i++) @@ -274,25 +228,19 @@ void serial_test_bpf_obj_id(void) nr_id_found++; err = bpf_map_lookup_elem(map_fd, &array_key, &array_value); - if (CHECK_FAIL(err)) + if (!ASSERT_OK(err, "bpf_map_lookup_elem")) goto done; err = bpf_map_get_info_by_fd(map_fd, &map_info, &info_len); - CHECK(err || info_len != sizeof(struct bpf_map_info) || - memcmp(&map_info, &map_infos[i], info_len) || - array_value != array_magic_value, - "check get-map-info(next_id->fd)", - "err %d errno %d info_len %u(%zu) memcmp %d array_value %llu(%llu)\n", - err, errno, info_len, sizeof(struct bpf_map_info), - memcmp(&map_info, &map_infos[i], info_len), - array_value, array_magic_value); + cmp_res = memcmp(&map_info, &map_infos[i], info_len); + ASSERT_OK(err, "bpf_map_get_info_by_fd"); + ASSERT_EQ(info_len, sizeof(struct bpf_map_info), "info_len"); + ASSERT_OK(cmp_res, "memcmp"); + ASSERT_EQ(array_value, array_magic_value, "array_value"); close(map_fd); } - CHECK(nr_id_found != nr_iters, - "check total map id found by get_next_id", - "nr_id_found %u(%u)\n", - nr_id_found, nr_iters); + ASSERT_EQ(nr_id_found, nr_iters, "map_nr_id_found"); /* Check bpf_link_get_next_id() */ nr_id_found = 0; @@ -308,9 +256,7 @@ void serial_test_bpf_obj_id(void) if (link_fd < 0 && errno == ENOENT) /* The bpf_link is in the dead row */ continue; - if (CHECK(link_fd < 0, "get-link-fd(next_id)", - "link_fd %d next_id %u errno %d\n", - link_fd, next_id, errno)) + if (!ASSERT_GE(link_fd, 0, "bpf_link_get_fd_by_id")) break; for (i = 0; i < nr_iters; i++) @@ -325,17 +271,13 @@ void serial_test_bpf_obj_id(void) err = bpf_link_get_info_by_fd(link_fd, &link_info, &info_len); cmp_res = memcmp(&link_info, &link_infos[i], offsetof(struct bpf_link_info, raw_tracepoint)); - CHECK(err || info_len != sizeof(link_info) || cmp_res, - "check get-link-info(next_id->fd)", - "err %d errno %d info_len %u(%zu) memcmp %d\n", - err, errno, info_len, sizeof(struct bpf_link_info), - cmp_res); + ASSERT_OK(err, "bpf_link_get_info_by_fd"); + ASSERT_EQ(info_len, sizeof(link_info), "info_len"); + ASSERT_OK(cmp_res, "memcmp"); close(link_fd); } - CHECK(nr_id_found != nr_iters, - "check total link id found by get_next_id", - "nr_id_found %u(%u)\n", nr_id_found, nr_iters); + ASSERT_EQ(nr_id_found, nr_iters, "link_nr_id_found"); done: for (i = 0; i < nr_iters; i++) { From patchwork Tue Nov 21 00:10:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuran Pereira X-Patchwork-Id: 13462346 X-Patchwork-Delegate: bpf@iogearbox.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="mmF5eUNU" Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2025.outbound.protection.outlook.com [40.92.65.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E922FAC; Mon, 20 Nov 2023 16:11:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hj3OdIg7D7wqQSg3H68xRBqHrA4YYIbSqi5JRDRKS6kuBLhemcOhwejqxMGxvfrRQnDyG/t25oiX8JiBZzqq7qYiAlww0U9DVfGuOcP11vEy1AHJYX9YHK0ljB8edFBRjbyJuY3NSZKXJsONlkEBMUyMzvtE2sK09q+vyiplB4R7wiJHhladdlccpBV46RomCCWbwDxFKhBCjv4i/bvu2N7ApFTHNcrr5HuMUMORwi2241xvw44+dSGspHllxHaugPEKf8GAFf1MzW1ghP2qnbBUFtwB1aUCv2uzfG5PUf6vIjACyN36mz2izx2vp/TcoIS2/rp1y2/SnMxOdzkfoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SEV6FSvKBUg1qgQLg6TT1AC2iHwQLooeot5R9UOQzCQ=; b=LUOMeB12b0joju/0Zp/HBcKic012Kv6OIx+9uao/BF/SrXZRHg5l0zZiYt7Z26uVmSTzmTDDMT489Y+2xMLIZFDq1Qogt7d38COCPio/Y4CjmdbCOFKHVZUygAkV8Z0ym07eKBZm71SonaY0GX59sfwrDbmOfpe7TXEGB2VlBzGFFMfOvUpP3qw0rYVrjO21h0pJSDO1ObnqVJ4dMJRR2uvKS7DR2EkiEv5M2GvAzadt3yTy16ihTOBwTyU/vLAnXoyGiCXCyotk6PqJuJqIYkvoUyK6Ku01Nb1fbsBx4D6psdwzrbZr/pxPjNg0fRbcF9caF0bfP1QR74s0MewRlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SEV6FSvKBUg1qgQLg6TT1AC2iHwQLooeot5R9UOQzCQ=; b=mmF5eUNU3EzBf04DJ46VbeCsvyeQgljRqyTaLZTgCJ/uhIa0YL+ty58On2cNASs0M0+Z2+MaVV/euiLvuAVI0dNHYhCdVAD1hI6NV7ENEy4MKcbAJnzZNTW1HOjt3CU5gF5PhfTwvEn/U1DI8pNiQx5XR5XJJrerUz/wMZJu+Ge353g8rpigf0A5ADdEVgd8TgB7V+fXYzJvPeVjs4FEBkbMLxfS9i+V+vquT/rjV/PiyJ3LaUAjIeRqeVwuXaGG/64vLTpI350NUDmX18kZ2x2NdU9/8duSk1HqEPA4MUZKuT6dYHeSgTB0CU3JC+Yzo2+aW14ZunB6VGaLPGvdGg== Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) by AS2PR10MB7477.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:593::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.27; Tue, 21 Nov 2023 00:11:50 +0000 Received: from GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450]) by GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM ([fe80::6c45:bfdf:a384:5450%7]) with mapi id 15.20.7002.028; Tue, 21 Nov 2023 00:11:50 +0000 From: Yuran Pereira To: bpf@vger.kernel.org Cc: Yuran Pereira , andrii@kernel.org, ast@kernel.org, haoluo@google.com, john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, sdf@google.com, shuah@kernel.org, song@kernel.org, yonghong.song@linux.dev Subject: [PATCH bpf-next v3 4/4] selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in vmlinux Date: Tue, 21 Nov 2023 05:40:41 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-TMN: [JDLWPmLeA0eLagYv2ue0MT27N/ICeQkd] X-ClientProxiedBy: JN2P275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:3::24) To GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:150:83::20) X-Microsoft-Original-Message-ID: <20231121001041.421657-1-yuran.pereira@hotmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR10MB6563:EE_|AS2PR10MB7477:EE_ X-MS-Office365-Filtering-Correlation-Id: 11f2328b-f843-4611-eaa8-08dbea267542 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NS24g2DnoxWFNSyLkhbSLja6G/JSLLwPte3nr4QkxhTNFrebQHHKs0xYgeDhGID/rrZHBgwNDtD7uYjK6oNyPcZE+rWa6H8GpvZ00R/66uGxTzM4VlHwFZJQxH6ejSlL+A1gFGKVPTeKT7+9BiUEhuwj1Thx1oIgBG3+EZA+jPopFiW0KtOkhUEfQ9ibT+I1klRd5NfCz0Yvud3D2VYtdFUe77/GJd/xxCdccTci06NMTzU+bommktvIw4Vo/1yGe0a41CxsiSlEl+vP1A5jPAhfS1d9XAOli3kjeO+vheOOXlnipziyq1rWmCNIiSLdRLzxX06yarli05PWKChgkUEbmZK9tSjHVT55nvwcPi0L/H3Pou5ifzxy08fUHchCx2ofMWGWCn7wRs1K3gZyrtQhUEP7tTLan9dR+0SyHSz0r7VSQDq+w0uh5ZmCkowpuhvL287C8Z7beHbtygkopZI91JPJOCzqAtwjZhaXdf1E3h6jL/wNlxRXbGDGV6pN3x3fYBYSaNaCmfxlu6NctfWtC7ifxvXQPCg1rhuen/KkBr7mM8cKQtRqgOc51AkriVEVMgOrFhtJfEo33sexxITSEAuXAlc4aXt7QpmayT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OK3v0RqmdIz6+Zh/WVP3b9jsEPgdUfjlZyhBH7fFsBwJ2Uf5N3SC6dbxX56CGkayb7Q5dU7TgDCPJRn3iR3DU7bibdmjXfpoyVf0KBUJajXxlm3LkCHACwQuDy5vHCKQE0cx//ALCwqHKERcOa2IS5QHTE9Y5hDZxIydKOHpKy3HEhwfZn5YIOOnbO6i9pnsFulEDh5tZ9v7uOz2ATGJ33JKdkPJ5Q2ogbV9rDxQGWO03SHIVc= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6b909.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 11f2328b-f843-4611-eaa8-08dbea267542 X-MS-Exchange-CrossTenant-AuthSource: GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 00:11:50.3329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR10MB7477 X-Patchwork-Delegate: bpf@iogearbox.net vmlinux.c uses the `CHECK` calls even though the use of ASSERT_ series of macros is preferred in the bpf selftests. This patch replaces all `CHECK` calls for equivalent `ASSERT_` macro calls. Signed-off-by: Yuran Pereira --- tools/testing/selftests/bpf/prog_tests/vmlinux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/vmlinux.c b/tools/testing/selftests/bpf/prog_tests/vmlinux.c index 72310cfc6474..6fb2217d940b 100644 --- a/tools/testing/selftests/bpf/prog_tests/vmlinux.c +++ b/tools/testing/selftests/bpf/prog_tests/vmlinux.c @@ -16,27 +16,27 @@ static void nsleep() void test_vmlinux(void) { - int duration = 0, err; + int err; struct test_vmlinux* skel; struct test_vmlinux__bss *bss; skel = test_vmlinux__open_and_load(); - if (CHECK(!skel, "skel_open", "failed to open skeleton\n")) + if (!ASSERT_OK_PTR(skel, "test_vmlinux__open_and_load")) return; bss = skel->bss; err = test_vmlinux__attach(skel); - if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err)) + if (!ASSERT_OK(err, "test_vmlinux__attach")) goto cleanup; /* trigger everything */ nsleep(); - CHECK(!bss->tp_called, "tp", "not called\n"); - CHECK(!bss->raw_tp_called, "raw_tp", "not called\n"); - CHECK(!bss->tp_btf_called, "tp_btf", "not called\n"); - CHECK(!bss->kprobe_called, "kprobe", "not called\n"); - CHECK(!bss->fentry_called, "fentry", "not called\n"); + ASSERT_TRUE(bss->tp_called, "tp"); + ASSERT_TRUE(bss->raw_tp_called, "raw_tp"); + ASSERT_TRUE(bss->tp_btf_called, "tp_btf"); + ASSERT_TRUE(bss->kprobe_called, "kprobe"); + ASSERT_TRUE(bss->fentry_called, "fentry"); cleanup: test_vmlinux__destroy(skel);