From: Dmitry V. Levin Date: Tue, 20 Sep 2016 00:19:20 +0000 (+0000) Subject: tests: use sprintrc in tests/fchmodat.c X-Git-Tag: v4.14~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48ba1de86929e711f14e6b66a036fcd5fc406762;p=strace tests: use sprintrc in tests/fchmodat.c * tests/fchmodat.c (main): Use sprintrc. Add more fchmodat decoding tests. --- diff --git a/tests/fchmodat.c b/tests/fchmodat.c index b49830dc..c52a1cab 100644 --- a/tests/fchmodat.c +++ b/tests/fchmodat.c @@ -33,6 +33,7 @@ #ifdef __NR_fchmodat # include +# include # include # include @@ -41,21 +42,23 @@ main(void) { static const char sample[] = "fchmodat_sample"; - if (open(sample, O_RDONLY | O_CREAT, 0400) == -1) + if (open(sample, O_RDONLY | O_CREAT, 0400) < 0) perror_msg_and_fail("open"); - if (syscall(__NR_fchmodat, -100, sample, 0600) == 0) { - printf("fchmodat(AT_FDCWD, \"%s\", 0600) = 0\n", sample); + long rc = syscall(__NR_fchmodat, -100, sample, 0600); + printf("fchmodat(AT_FDCWD, \"%s\", 0600) = %s\n", + sample, sprintrc(rc)); - if (unlink(sample)) - perror_msg_and_fail("unlink"); + if (unlink(sample)) + perror_msg_and_fail("unlink"); - if (syscall(__NR_fchmodat, -100, sample, 0600) != -1) - perror_msg_and_fail("fchmodat"); - } + rc = syscall(__NR_fchmodat, -100, sample, 051); + printf("fchmodat(AT_FDCWD, \"%s\", 051) = %s\n", + sample, sprintrc(rc)); - printf("fchmodat(AT_FDCWD, \"%s\", 0600) = -1 %s (%m)\n", - sample, errno2name()); + rc = syscall(__NR_fchmodat, -100, sample, 004); + printf("fchmodat(AT_FDCWD, \"%s\", 004) = %s\n", + sample, sprintrc(rc)); puts("+++ exited with 0 +++"); return 0;