[LTP] [PATCH 2/2] syscalls/io_pgetevents

Jan Stancek jstancek@redhat.com
Thu Jan 23 15:17:46 CET 2020


Hi,

----- Original Message -----
> +#ifdef HAVE_LIBAIO
> +#include <libaio.h>
> +
> +#ifndef HAVE_IO_SETUP
> +int io_setup(int nr, io_context_t *ctxp)
> +{
> +	return syscall(__NR_io_setup, nr, ctxp);
> +}
> +#endif /* HAVE_IO_SETUP */
> +
> +#ifndef HAVE_IO_DESTROY
> +int io_destroy(io_context_t ctx)
> +{
> +	return syscall(__NR_io_destroy, ctx);
> +}
> +#endif /* HAVE_IO_DESTROY */
> +
> +#ifndef HAVE_IO_SUBMIT
> +int io_submit(io_context_t ctx, long nr, struct iocb **iocbpp)
> +{
> +	return syscall(__NR_io_submit, ctx, nr, iocbpp);

Can functions above also use ltp_syscall?

<snip>

> +#ifdef HAVE_LIBAIO
> +
> +static int fd = -1;
> +
> +static void cleanup(void)
> +{
> +	SAFE_CLOSE(fd);

I'd move this to run(). It may get skipped on tst_brk(), but kernel will take
care of closing it. But if you run testcase in loop (-i) it won't run out
of file descriptors.

<snip>

> +#ifdef HAVE_LIBAIO
> +
> +static int fd = -1;
> +
> +static void cleanup(void)
> +{
> +	SAFE_CLOSE(fd);

same here

> +}
> +
> +static void run(void)
> +{
> +	struct io_event events[1];
> +	struct iocb cb, *cbs[1];
> +	io_context_t ctx = 0;
> +	sigset_t sigmask;
> +	char data[4096];
> +	int ret;
> +
> +	sigemptyset(&sigmask);
> +
> +	fd = SAFE_OPEN("io_pgetevents_file", O_RDWR | O_CREAT);
> +
> +	ret = io_setup(1, &ctx);
> +	if (ret < 0)
> +		tst_brk(TBROK | TERRNO, "io_setup() failed");
> +
> +	io_prep_pwrite(&cb, fd, data, 4096, 0);
> +
> +	cbs[0] = &cb;
> +
> +	ret = io_submit(ctx, 1, cbs);
> +	if (ret != 1)
> +		tst_brk(TBROK | TERRNO, "io_submit() failed");
> +
> +	/* Invalid Max event count */
> +	ret = io_pgetevents(ctx, 1, 0, events, NULL, &sigmask);
> +
> +	/* Invalid events*/
> +	if (ret != 1)
> +		ret = io_pgetevents(ctx, 1, 1, NULL, NULL, &sigmask);
> +
> +	if (io_destroy(ctx) < 0)
> +		tst_brk(TBROK | TERRNO, "io_destroy() failed");
> +
> +	/* Invalid ctx */
> +	if (ret != 1)
> +		ret = io_pgetevents(ctx, 1, 1, events, NULL, &sigmask);
> +
> +	if (ret != 1)
> +		tst_res(TPASS, "io_pgetevents() failed as expected");

If this reports FAIL, will we know what test actually failed?

Can you make this more verbose? I mean have each test report PASS/FAIL,
not just a one line summary after all tests.

> +	else
> +		tst_brk(TBROK| TERRNO, "io_pgetevents() passed unexpectedly");

TFAIL | TERRNO seems more fitting, since io_pgetevents is subject of the test.

Regards,
Jan



More information about the ltp mailing list