Re: [LTP] [PATCH 2/2] syscalls: Add test for splicing to /dev/zero and /dev/null

Cyril Hrubis
2024-04-11T10:37:24Z

Hi!
> > +#define _GNU_SOURCE
> > +#include "tst_test.h"
> > +
> > +static const char *test_devices[] = {
> checkpatch.pl suggests:
> static const char * const test_devices[] = {

Will fix and push.

> > + "/dev/null",
> > + "/dev/zero",
> > +};
> > +
> > +static void verify_splice(unsigned int n)
> > +{
> > + char buf[1024];
> > + char dev_fd;
> > + int pipefd[2];
> > +
> > + memset(buf, 0xff, sizeof(buf));
> > +
> > + tst_res(TINFO, "Testing %s", test_devices[n]);
> > +
> > + dev_fd = SAFE_OPEN(test_devices[n], O_WRONLY);
> > +
> > + SAFE_PIPE(pipefd);
> > + SAFE_WRITE(1, pipefd[1], buf, sizeof(buf));
> I wonder if write() fails, we don't get SAFE_CLOSE() calls, right?

We do not care here since these are just pipes, the test will fail with
TBROK and kernel will destroy the pipes once the process exits.

We have to close real files in test temporary directory, because if we
do not do so, tst_rmdir() may fail on nfs. E.g. if you create a file on
nfs, open it and unlink it, the directory is not empty as one would
expect and cannot be removed.

--
Cyril Hrubis
chrubis@suse.cz