[RFC PATCH 1/5] landlock/selftests: add a missing close(srv_fd) call
Mickaël Salaün
mic at digikod.net
Mon Jan 12 16:04:36 UTC 2026
On Sat, Jan 10, 2026 at 11:37:20AM +0100, Günther Noack wrote:
> On Fri, Jan 09, 2026 at 11:49:48AM +0100, Mickaël Salaün wrote:
> > On Fri, Jan 09, 2026 at 11:41:30AM +0100, Mickaël Salaün wrote:
> > > Good, I'll pick that in my -next branch.
> > >
> > > Nit: The prefix should be "selftests/landlock"
> > >
> > > On Thu, Jan 01, 2026 at 02:40:58PM +0100, Günther Noack wrote:
> > > > Signed-off-by: Günther Noack <gnoack3000 at gmail.com>
> > > > ---
> > > > tools/testing/selftests/landlock/fs_test.c | 1 +
> > > > 1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
> > > > index 37a5a3df712ec..16503f2e6a481 100644
> > > > --- a/tools/testing/selftests/landlock/fs_test.c
> > > > +++ b/tools/testing/selftests/landlock/fs_test.c
> > > > @@ -4400,6 +4400,7 @@ TEST_F_FORK(layout1, named_unix_domain_socket_ioctl)
> > > > EXPECT_EQ(0, test_fionread_ioctl(cli_fd));
> > > >
> > > > ASSERT_EQ(0, close(cli_fd));
> > > > + ASSERT_EQ(0, close(srv_fd));
> >
> > I'll also replace these ASSERT_EQ() with EXPECT_EQ().
>
> Fair enough. I would normally prefer ASSERT here, because that would
> be more symmetric with the corresponding setup steps, but it feels not
> worth bikeshedding over this.
My thinking is that a close() call will not have any impact on the
tests, and it's worth cleaning things as much as possible, but an error
should not happen anyway.
As you said a few years ago (or as I remember it), we should use EXPECT
as much as possible, especially when checks don't impact following
checks. At least, that's how I see things now. ;)
>
> The selftests, both Landlock and others, are inconsistent in how they
> use ASSERT and EXPECT, especially for close().
Indeed. I try to make sure the new Landlock tests use EXPECT for
close() though. It's difficult to explain when to use ASSERT or EXPECT,
especially because they are used everywhere, and we may not even
agree...
> I wish we had an
> easier way to do state teardown in the selftests without having to tie
> it to a FIXTURE()...
>
> –Günther
>
More information about the Linux-security-module-archive
mailing list