[PATCH] tests: add openat.test

Dmitry V. Levin ldv at altlinux.org
Thu Mar 24 20:50:33 UTC 2016


On Thu, Mar 24, 2016 at 01:51:39PM +0200, Katerina Koukiou wrote:
> * tests/openat.c: New file.
> * tests/openat.test: New test.
> * tests/.gitignore: Add openat.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add openat.test.

Looks OK, see comments about minor style issues below.

> @@ -299,6 +300,7 @@ TESTS = \
>  	net.test \
>  	newfstatat.test \
>  	oldselect.test \
> +	openat.test \
>  	pc.test \
>  	personality.test \
>  	pipe.test \

Sorry but I've changed this part of Makefile.am yesterday, please rebase.

> +int
> +main(void)
> +{
> +	int fd;
> +	static const char fname[] = "openat_test_file";

Swap these two definitions?

> +	fd = syscall(__NR_openat, -100, fname, O_RDONLY|O_CREAT, 0400);
> +	if (fd == -1) {
> +		if (errno == ENOSYS) {
> +			printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT,"
> +			        " 0400) = -1 ENOSYS (%m)\n", fname);

When breaking long lines, we usually indent not with one tabstop but under
the object being wrapped, e.g.

			printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
			       ", 0400) = -1 ENOSYS (%m)\n", fname);

As you can see, my personal preference is to break before comma,
but I don't insist.

> +		} else {
> +			perror_msg_and_fail("openat");
> +		}
> +	} 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");
> +	}
> +
> +	if (fd != -1) {

Looks like this is continuation of the previous branch.

[...]
> +match_diff "$LOG" "$OUT"
> +rm -f "$OUT"
> +
> +exit 0

This "exit 0" is not really needed.  I used to add them myself,
but they are not needed in new files anyway.


-- 
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/20160324/e4814232/attachment.bin>


More information about the Strace-devel mailing list