[LTP] [PATCH v2] accept03/tst_fd: Harden parallel runs against
Cyril Hrubis
chrubis@suse.cz
Thu Nov 5 11:33:51 CET 2026
Hi!
> commit fa68043e5948ff1b8cb2c647d309ccf4808e23d7
> Author: Petr Vorel <pvorel@suse.cz>
> Date: 2026-11-04 18:34:06 +0100
>
> tst_fd: Add check for missing .needs_tmpdir
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
> diff --git lib/tst_fd.c lib/tst_fd.c
> index 6538a098c7..05e1bbe8b0 100644
> --- lib/tst_fd.c
> +++ lib/tst_fd.c
> @@ -22,6 +22,8 @@
> #include "lapi/bpf.h"
> #include "lapi/fsmount.h"
>
> +#include "tso_tmpdir.h"
> +
> #include "tst_fd.h"
>
> struct tst_fd_desc {
> @@ -30,8 +32,17 @@ struct tst_fd_desc {
> const char *desc;
> };
>
> +static void require_tmpdir(struct tst_fd *fd)
> +{
> + if (!tst_tmpdir_created()) {
> + tst_brk(TBROK, "%s fd requires .needs_tmpdir = 1",
> + tst_fd_desc(fd));
> + }
> +}
> +
> static void open_file(struct tst_fd *fd)
> {
> + require_tmpdir(fd);
> fd->fd = SAFE_OPEN("fd_file", O_RDWR | O_CREAT, 0666);
> SAFE_UNLINK("fd_file");
> }
> @@ -40,6 +51,7 @@ static void open_path(struct tst_fd *fd)
> {
> int tfd;
>
> + require_tmpdir(fd);
> tfd = SAFE_CREAT("fd_file", 0666);
> SAFE_CLOSE(tfd);
>
> @@ -50,6 +62,7 @@ static void open_path(struct tst_fd *fd)
>
> static void open_dir(struct tst_fd *fd)
> {
> + require_tmpdir(fd);
> SAFE_MKDIR("fd_dir", 0700);
> fd->fd = SAFE_OPEN("fd_dir", O_DIRECTORY);
> SAFE_RMDIR("fd_dir");
This approach looks good to me.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list