[PATCH] tests: add chmod.test
Dmitry V. Levin
ldv at altlinux.org
Sun Mar 6 23:52:17 UTC 2016
On Sun, Mar 06, 2016 at 08:49:46AM +0000, Anchit Jain wrote:
> From: Anchit Jain <anchitjain1234 at gmail.com>
>
> * tests/chmod.c: New file.
> * tests/chmod.test: New test.
> * tests/.gitignore: Add chmod.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add chmod.test.
This is 5th edition of the patch, and it's close to the final version.
There is a tradition to include iteration count in emails,
see --reroll-count option of git-format-patch(1).
> +int
> +main(void)
> +{
> + static const char fname[] = "chmod_test_file";
> +
> + if (open(fname, O_CREAT|O_RDONLY, 0400) == -1)
> + perror_msg_and_fail("open");
> +
> + int enosys_flag = 0;
> + if (syscall(__NR_chmod, fname, 0600) != 0){
> +
Please add a space before the brace, but don't add an empty line after
the brace.
You don't really need a separate flag, the return code is enough.
For example,
int rc = syscall(__NR_chmod, fname, 0600);
if (rc == 0) {
[handle success]
} else {
[handle error]
}
[unlink]
if (rc == 0) {
[more tests]
}
> + }
> + else
Please place "else" on the same line with the brace, like in my example.
--
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/20160307/c7726c75/attachment.bin>
More information about the Strace-devel
mailing list