public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Jinseok Kim <always.starving0@gmail.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] close: add test for double close EBADF
Date: Thu, 9 Apr 2026 10:15:46 +0200	[thread overview]
Message-ID: <20260409081546.GB96667@pevik> (raw)
In-Reply-To: <20260406133134.17238-2-always.starving0@gmail.com>

> Verify that calling close() on an already closed file descriptor fails
> with EBADF.

> The existing close tests cover:
> - close01: successful close on valid file descriptors
> - close02: invalid file descriptor (-1)

> This test adds coverage for a common state transition case where a
> previously valid file descriptor becomes invalid after close().

IMHO it'd make sense to add this errno check to close02.c (using .tcnt).

...
> --- /dev/null
> +++ b/testcases/kernel/syscalls/close/close03.c
> @@ -0,0 +1,26 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2026 Jinseok Kim <always.starving0@gmail.com>
> + */
> +
> +/*\
> + * Verify that calling close() twice on the same fd returns EBADF on

Please instead of close() use:
:manpage:`close(2)`

That will provide link to man page
https://man7.org/linux/man-pages/man2/close.2.html

in our test catalog:
https://linux-test-project.readthedocs.io/en/latest/users/test_catalog.html

Kind regards,
Petr

> + * the second call.
> + */
> +
> +#include <errno.h>
> +#include <fcntl.h>
> +#include "tst_test.h"
> +
> +static void run(void)
> +{
> +	int fd = SAFE_OPEN("close03", O_CREAT, 0600);
> +
> +	TST_EXP_PASS(close(fd));
> +	TST_EXP_FAIL(close(fd), EBADF);
> +}
> +
> +static struct tst_test test = {
> +	.needs_tmpdir = 1,
> +	.test_all = run,
> +};

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-04-09  8:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-06 13:30 [LTP] [PATCH 1/2] close: remove unused headers and fix minor style issues Jinseok Kim
2026-04-06 13:31 ` [LTP] [PATCH 2/2] close: add test for double close EBADF Jinseok Kim
2026-04-09  8:15   ` Petr Vorel [this message]
2026-04-09  8:08 ` [LTP] [PATCH 1/2] close: remove unused headers and fix minor style issues Petr Vorel

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=20260409081546.GB96667@pevik \
    --to=pvorel@suse.cz \
    --cc=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /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