From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7903264630 for ; Wed, 21 May 2025 11:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747827564; cv=none; b=MgeMqtms2p5CH5y7GDd2adXRQ5DYsMrTeD9WxDlhMVvT4Nyn36oABVx4HRM9EshC0stAQC5SK63Vxi/Wnm5xiuNENF52qs/72vT4NPk9koYt4xz/mcYjB8zM6DSfRL5rlSP4RIytb/YJo8xdmH5NkpC3Ypzs8WCl932eE0d+dRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747827564; c=relaxed/simple; bh=ZCZ2aJ1b5eMSWudl4vKU4ptaYuhCrY9+6o62fv7wrhA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=F5LTEMNOmQmH6ON+6NaLY+eTRF89h6xo1Fby5zwgmvIEGfjQcAiI9I8uTYYCxRmWqRxtrNbct/ZUCOWmwdp+jApfGtel6udVe1MAR9Kq8Rdhnt03JvGFnU5UPdsG4ewGowmw9bbwi6YCD6sseD2BCSGve1kJI+RMzhryuCaaZdE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y/k8K0zo; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y/k8K0zo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827560; 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=G9KOOfsW+8OgloJMhG+itfRoJTQZ8+HhBWqoWSniyY4=; b=Y/k8K0zojUj3/O6y6E4b3/5+3BM8KlhWtr90uzo3jmrC/uH4bwP3u4tGCVN1jylsa3lV7+ i1/oEvVljewc+aRAGdjcZcT52WGMK2oHw5sAjUYlHnSROFJNkjBWbiS5Fo6YS5/S6Fh+Jx brX5okNx9aggBLljcWfjV8J2vT7QLcU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-7IU8SWDuOZ6IZolszohdzg-1; Wed, 21 May 2025 07:39:19 -0400 X-MC-Unique: 7IU8SWDuOZ6IZolszohdzg-1 X-Mimecast-MFC-AGG-ID: 7IU8SWDuOZ6IZolszohdzg_1747827558 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3a362dcc86fso2049298f8f.0 for ; Wed, 21 May 2025 04:39:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747827558; x=1748432358; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G9KOOfsW+8OgloJMhG+itfRoJTQZ8+HhBWqoWSniyY4=; b=Y1C+BupL8gKBqFJ2x8MzWQVHD6RO/ZJC04vjqqZJmMRPtLUZBMvtMOg/jaGPG/z4RL KcCWCaL1EjlrS6fzXKqg7V+nTE+RFxoR/DUKg65+BUZ9QCFAq7EcOw0PVsN9SU95/bSR lkTquwSg9Z2Z31MYMMZlZ11EPuSpJuOHnnz4sXevKYWKezCHP/gda6SW+1bLqE/wjsnZ w045CNKjvefduEUsXsUetWtCL/e44eByiVQRyjfgBH2EQ2qiCcT19YqI9K8cv6SAO6UM bz2yqTKWtXvS7v3ZzOEe+KNtxMaQXPeAXcW3mzIlZ0UxmkeCB8PwgrqbQ9ihZLgB9Ppl oMcQ== X-Forwarded-Encrypted: i=1; AJvYcCWTdhOJ00BrSINJ5U1ztBVXcKcX3ExAJPpkRKpP6DH+dv7UPX2eKUSTiF9ZPexxkmkEDBVfH5LCxdw=@vger.kernel.org X-Gm-Message-State: AOJu0YyjwAW4omyGrl7tVOv76Vk8LTwtOV4dFy5zSYrP/OTK1qZDUcQi /f1PMkW2kRL6KbwogVxRt9mg3CK2uvFfIKFYQ/GpR+3RcW9U4Ulyi7rVdH9GiW22+zbW2v2++08 CWTbXEEuCRI2mQ9NnwPHxVysYq9Fzz/m5JRyZUcEFa/qF3udMCy143WTxWcOQ0g== X-Gm-Gg: ASbGncsPAlNKy8rbrgj0Gh/gnRi6Ns2lp7pHOILrhSTBXihjp2/3m45CVPqcaSwpP9/ cB72wafjNjdMUy+DKen7bJd5IWtXbGZrW8t0dONvdYPSqWDws8nADAh6W3D+ILu9Q0fJT1acfLn HR/vU7HKeoVZlzfGFrgcAcRbGlDUIx0pt3ZoYo9crP0MyL/TA71OYQxIo0ALGRhXI4WFyTaTGc5 nDGbxqf1F+gYDYw+n0yqzOHLix0vlcKhS/ZFbO+skr9zLLURwQoAmT2OBu1DB0y9JmYHeHYzJ1Q O1AUWtEKYspK/jL77ZeAUPfFwXQkwxM9ejSrKSxMqSY= X-Received: by 2002:a05:6000:2dc6:b0:3a3:779d:5f42 with SMTP id ffacd0b85a97d-3a3779d5f61mr6318195f8f.3.1747827557906; Wed, 21 May 2025 04:39:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxQsTXZ+Ts2cIK3EuR4b/M12UVesyDgK3ufrotSRgReR+EMMzUPKugbn4ggPlauNfM02nRYw== X-Received: by 2002:a05:6000:2dc6:b0:3a3:779d:5f42 with SMTP id ffacd0b85a97d-3a3779d5f61mr6318166f8f.3.1747827557508; Wed, 21 May 2025 04:39:17 -0700 (PDT) Received: from [172.16.17.1] (pd9ed5a70.dip0.t-ipconnect.de. [217.237.90.112]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca4d224sm20072118f8f.12.2025.05.21.04.39.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 May 2025 04:39:17 -0700 (PDT) Message-ID: <96837efb-63ac-4191-8e2a-4785672c8d7a@redhat.com> Date: Wed, 21 May 2025 13:39:15 +0200 Precedence: bulk X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] selftests: can: Import tst-filter from can-tests To: Vincent Mailhol Cc: socketcan@hartkopp.net, mkl@pengutronix.de, shuah@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, dcaratti@redhat.com, fstornio@redhat.com References: Content-Language: en-US From: Felix Maurer In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Vincent, On 14.05.25 11:47, Vincent Mailhol wrote: > Hi Felix, > > On Sat. 10 May 2025 at 00:07, Felix Maurer wrote: >> Tests for the can subsystem have been in the can-tests repository[1] so >> far. Start moving the tests to kernel selftests by importing the current >> tst-filter test. The test is now named test_raw_filter and is substantially >> updated to be more aligned with the kernel selftests, follow the coding >> style, and simplify the validation of received CAN frames. We also include >> documentation of the test design. The test verifies that the single filters >> on raw CAN sockets work as expected. >> >> We intend to import more tests from can-tests and add additional test cases >> in the future. The goal of moving the CAN selftests into the tree is to >> align the tests more closely with the kernel, improve testing of CAN in >> general, and to simplify running the tests automatically in the various >> kernel CI systems. >> >> [1]: https://github.com/linux-can/can-tests >> >> Signed-off-by: Felix Maurer > > Thanks again. > > I left a set of nitpicks, I expect to give my reviewed-by tag on the > next version. Thank you for your feedback. I'll post a new version with the changes included soon. [...] >> +FIXTURE_SETUP(can_filters) >> +{ >> + struct sockaddr_can addr; >> + struct ifreq ifr; >> + int recv_own_msgs = 1; >> + int s, ret; >> + >> + s = socket(PF_CAN, SOCK_RAW, CAN_RAW); >> + ASSERT_LT(0, s) > > 0 is a valid fd (OK it is used for the stout, so your code will work, > but the comparison still looks unnatural). > > What about: > > ASSERT_NE(s, -1) > > or: > > ASSERT_GE(s, 0) > > ? > > (same comment for the other ASSERT_LE) I was a bit hesitant to change the order of expected and seen value for the the assertions because it's documented as ASSERT_*(expected, seen). But it seems to be common in the selftest to not follow this order where assertions are used for error checking and failure message doesn't explicitly say what was expected/seen. I'll take a look at the error checking in the whole file where the more familiar form is with reversed arguments. Thanks, Felix