From: Felix Maurer <fmaurer@redhat.com>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
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
Subject: Re: [PATCH v2] selftests: can: Import tst-filter from can-tests
Date: Wed, 21 May 2025 13:39:15 +0200 [thread overview]
Message-ID: <96837efb-63ac-4191-8e2a-4785672c8d7a@redhat.com> (raw)
In-Reply-To: <CAMZ6RqKmPD+BZkVC1C-vn7hcAVdQr8Qhd6PW8bASZiQkD6MV-A@mail.gmail.com>
Hi Vincent,
On 14.05.25 11:47, Vincent Mailhol wrote:
> Hi Felix,
>
> On Sat. 10 May 2025 at 00:07, Felix Maurer <fmaurer@redhat.com> 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 <fmaurer@redhat.com>
>
> 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
prev parent reply other threads:[~2025-05-21 11:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 15:06 [PATCH v2] selftests: can: Import tst-filter from can-tests Felix Maurer
2025-05-14 9:47 ` Vincent Mailhol
2025-05-21 11:39 ` Felix Maurer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=96837efb-63ac-4191-8e2a-4785672c8d7a@redhat.com \
--to=fmaurer@redhat.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=edumazet@google.com \
--cc=fstornio@redhat.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=socketcan@hartkopp.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox