[PATCH] tests: add openat.test

Dmitry V. Levin ldv at altlinux.org
Wed Mar 23 15:50:02 UTC 2016


On Wed, Mar 23, 2016 at 04:52:13PM +0200, Katerina Koukiou wrote:
[...]
> +#if defined __NR_openat

Please check for AT_FDCWD as well.

> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <errno.h>

Please indent includes.

> +int
> +main(void)
> +{
> +	int dir_fd;
> +	int fd;
> +	static const char fname[] = "openat_test_file";
> +
> +	dir_fd = AT_FDCWD;
> +	fd = syscall(__NR_openat, dir_fd, fname, O_RDONLY|O_CREAT, 0400);
> +	if (fd < 0)
> +		perror_msg_and_fail("openat");

What about ENOSYS?
Shouldn't it exit with perror_msg_and_skip in that case?

> +	else
> +		printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400) = %d"
> +			"\n", fname, fd);
> +	close(fd);
> +
> +	if (unlink(fname) == -1)
> +		perror_msg_and_fail("unlink");
> +
> +	fd = syscall(__NR_openat, dir_fd, fname, O_RDONLY);
> +	if (fd < 0)
> +		printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d ENOENT (%m)\n",
> +			fname, fd);
> +	else
> +		perror_msg_and_fail("openat");
> +
> +	puts("+++ exited with 0 +++");
> +	return 0;
> +}
> +
> +#else
> +
> +SKIP_MAIN_UNDEFINED("__NR_openat")
> +
> +#endif
> diff --git a/tests/openat.test b/tests/openat.test
> new file mode 100755
> index 0000000..759afd3
> --- /dev/null
> +++ b/tests/openat.test
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# Check openat syscall .

The trailing period is not connected to the sentence.

> +. "${srcdir=.}/init.sh"
> +
> +run_prog > /dev/null
> +OUT="$LOG.out"
> +run_strace -a28 -eopenat $args > "$OUT"

Is -a28 needed in this test?


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160323/ba0569b9/attachment.bin>


More information about the Strace-devel mailing list