[PATCH] tests: add chmod.test

Dmitry V. Levin ldv at altlinux.org
Sat Mar 5 23:16:15 UTC 2016


On Sat, Mar 05, 2016 at 07:04:13PM +0000, Anchit Jain wrote:
[...]
> +	if (syscall(__NR_chmod, fname, 0600) != 0){
> +
> +		if (errno == ENOSYS){
> +			printf("chmod(\"%s\", 0600) = -1 ENOSYS (%m)\n", fname);
> +
> +			puts("+++ exited with 0 +++");
> +			return 0;
> +		}
> +
> +		perror_msg_and_fail("chmod");
> +	}
> +
> +	printf("chmod(\"%s\", 0600) = 0\n", fname);
> +
> +	if (unlink(fname) == -1)
> +		perror_msg_and_fail("unlink");
> +
> +	if (syscall(__NR_chmod, fname, 0600) != -1)
> +		perror_msg_and_fail("chmod");
> +	printf("chmod(\"%s\", 0600) = -1 ENOENT (%m)\n", fname);
> +
> +	puts("+++ exited with 0 +++");
> +	return 0;

This implementation might leak the temporary file.
Also, please try to avoid unnecessary code duplication.


-- 
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/20160306/9fca472f/attachment.bin>


More information about the Strace-devel mailing list