Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2448002rdb; Mon, 20 Nov 2023 11:01:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGflufCpcCjQ5dlq7+lV7nzQkCjSaPx9NRROeqsnhF46Cvr6AzIZGDCNCXnlZKePZ/f0w/d X-Received: by 2002:a05:6808:b:b0:3ae:156f:d319 with SMTP id u11-20020a056808000b00b003ae156fd319mr7632048oic.45.1700506871138; Mon, 20 Nov 2023 11:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700506871; cv=none; d=google.com; s=arc-20160816; b=v/EohtnmqnWswBq4UYnpYk5GdgKRBx4aDEwBILuED+H+iIwa+Mf4gSrrUhOHbKFKpz PYInL482w99BFSWtI7EbVQhxqXurKFs3wy2/nj3f2C8ByJca+QIJKW7gz3aiMYbrSYFl EM6kNvxt8JCIS480HaSl8mOlAva3Hb9d735h10fRVQWMFPFn0f4RrSLJLgTFrhCO1c8h xPWnzyuyiJZZ1Ht29vcmIVVkbqNxJIa/QaeKrTVUqbYKX0qAoSl82vW6aymN9hqQoehG q6fjopwTRihI7E+NKgMt3vKnS8NrdoPb2N7sqlL8nkG1AOGZmynoyYzm9dnO3S09jrBV cC7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=jfwHLBU/eMYU2BU5PuQp1CafAYg938BQTjSvVXHWz4g=; fh=VJFCDp4qv0D0jhFJN0gl68EkFCzNf4zZSVhWYlEmBU8=; b=bLyFAvQhwpMpvoaUEcviAcbTC4s+g848my5vbgvUXaPQP/CXUP1poQbTPoXBo+dZGp cTyuSfEkWK1TIiY/NSw1Jf+LPM043Cz+E/TOCdQAtoN2vK43eQTNvzJgs7M2u9ZUQZy8 NKdWCRRQMeTTXJFnSuiuTO+cVLk5J3FqdGW8z5u49QqbLx5MeB654HmJKH8DushLBXQS 01E7QLoj+/Pn52uo5WTxOt7k8/4gPCdXqIHI5utzJsJutgmPhkwvd5ZXmcXhHn4Uq7Qf m2UwGKlWZ0Y5Z2nkUtiALd1BeXYTNVJgQAEwn37zyC3bTyHRDmk24decUxhjjvo8mA8Q b3yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LXLgLVWq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id m6-20020a0568080f0600b003b57623e88csi3126298oiw.18.2023.11.20.11.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 11:01:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LXLgLVWq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4DF97808D211; Mon, 20 Nov 2023 11:00:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbjKTTAc (ORCPT + 99 others); Mon, 20 Nov 2023 14:00:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjKTTAa (ORCPT ); Mon, 20 Nov 2023 14:00:30 -0500 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [IPv6:2001:41d0:203:375::aa]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B32100; Mon, 20 Nov 2023 11:00:26 -0800 (PST) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700506824; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jfwHLBU/eMYU2BU5PuQp1CafAYg938BQTjSvVXHWz4g=; b=LXLgLVWq5d+Vt3kcSsr/102ISqSrsb2lZKMQtSIc6oXuNTEevMqOjFf0A2S5Qa8E8ymmfl HtJX1uvCKr4/QI3sG4lwRY4oyVYmmHNEcjYuuiuSfBUoSyEO60ybTCWPO0RZ6nC4JG7p9E aGJElRS3bcHtUTeQQE1jKb8w/N/R/UA= Date: Mon, 20 Nov 2023 11:00:17 -0800 MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v2 1/4] selftests/bpf: Replaces the usage of CHECK calls for ASSERTs in bpf_tcp_ca Content-Language: en-GB To: Yuran Pereira Cc: bpf@vger.kernel.org, andrii@kernel.org, andrii.nakryiko@gmail.com, mykolal@fb.com, ast@kernel.org, martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <14c7dea0-242c-4b47-929c-7cbd1d7e202a@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 11:00:43 -0800 (PST) On 11/20/23 12:15 PM, Yuran Pereira wrote: > Hello Yonghong, > On Mon, Nov 20, 2023 at 07:22:59AM -0800, Yonghong Song wrote: >>> - if (CHECK(!err || errno != ENOENT, >>> - "bpf_map_lookup_elem(sk_stg_map)", >>> - "err:%d errno:%d\n", err, errno)) >>> + if (!ASSERT_NEQ(err, 0, "bpf_map_lookup_elem(sk_stg_map)") || >> !ASSERT_ERR(err, "bpf_map_lookup_elem(sk_stg_map)") >> might be simpler than !ASSERT_NEQ(..). >> > Sure, that makes sense. I'll change it in v3. >>> - pthread_join(srv_thread, &thread_ret); >>> - CHECK(IS_ERR(thread_ret), "pthread_join", "thread_ret:%ld", >>> - PTR_ERR(thread_ret)); >>> + err = pthread_join(srv_thread, &thread_ret); >>> + ASSERT_OK(err, "pthread_join"); >> The above is not equivalent to the original code. >> The original didn't check pthread_join() return as it >> is very very unlikely to fail. And check 'thread_ret' >> is still needed. >> > Yes that is true, but the v1 [1] broke the tests because the > ASSERT_OK_PTR(thread_ret, "pthread_join") kept failing, even > though all the asserts within the `server()` function itself > passed. > > Also, isn't asserting `thread_ret` technically checking the > `server()` function instead of `pthread_join`? So should we > have two asserts here? One for `server` and one for `pthread_join` > or is it not necessary? > i.e: > ``` > ASSERT_OK_PTR(thread_ret, "server"); > ASSERT_OK(err, "pthread_join"); > ``` As I mentioned, checking return value of pthread_join() is not critical as in general pthread_join() not fail. The test is not to test pthread_join() and if pthread_join() fails it would be an even bigger problem affecting many other tests. > > Upon taking a second look, I now think that the reason why > `ASSERT_OK_PTR(thread_ret, "pthread_join");` failed in v1 might > have been because it calls `libbpf_get_error` which returns > `-errno` when the pointer is `NULL`. > > Since `server`'s return value is not a bpf address, which > `ASSERT_OK_PTR` expects it to be, do you that think we should > explicitly set `errno = 0` prior to returning NULL on server? > That way that assert would pass even when the pointer is NULL > (which is the case when `server` returns successfuly). Let us just do   ASSERT_OK(IS_ERR(thread_ret), "thread_ret") > > [1] - https://lore.kernel.org/lkml/GV1PR10MB6563A0BE91080E6E8EC2651DE8B0A@GV1PR10MB6563.EURPRD10.PROD.OUTLOOK.COM/ > > As always, thank you for your feedback. > > Yuran Pereira >