From: Dmitry V. Levin Date: Tue, 20 Sep 2016 00:19:20 +0000 (+0000) Subject: tests: use sprintrc in tests/fchmod.c X-Git-Tag: v4.14~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9bfa4e4066924966809d67c88ecbca0bf5424c7;p=strace tests: use sprintrc in tests/fchmod.c * tests/fchmod.c (main): Use sprintrc. Add more fchmod decoding tests. * tests/fchmod.test: Update the value specified for strace -a parameter. --- diff --git a/tests/fchmod.c b/tests/fchmod.c index 58885612..932d0830 100644 --- a/tests/fchmod.c +++ b/tests/fchmod.c @@ -1,5 +1,8 @@ /* + * Check decoding of fchmod syscall. + * * Copyright (c) 2016 Fabien Siron + * Copyright (c) 2016 Dmitry V. Levin * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,12 +31,12 @@ #include "tests.h" #include -#if defined __NR_fchmod +#ifdef __NR_fchmod -#include -#include -#include -#include +# include +# include +# include +# include int main(void) @@ -41,22 +44,22 @@ main(void) static const char fname[] = "fchmod_test_file"; int fd = open(fname, O_CREAT|O_RDONLY, 0400); - - if (fd == -1) + if (fd < 0) perror_msg_and_fail("open"); - if (unlink(fname) == -1) + if (unlink(fname)) perror_msg_and_fail("unlink"); - if (syscall(__NR_fchmod, fd, 0600) == 0) { - close(fd); + long rc = syscall(__NR_fchmod, fd, 0600); + printf("fchmod(%d, 0600) = %s\n", fd, sprintrc(rc)); + + close(fd); - printf("fchmod(%d, 0600) = 0\n", fd); + rc = syscall(__NR_fchmod, fd, 051); + printf("fchmod(%d, 051) = %s\n", fd, sprintrc(rc)); - if (syscall(__NR_fchmod, fd, 0600) != -1) - perror_msg_and_fail("fchmod"); - } - printf("fchmod(%d, 0600) = -1 %s (%m)\n", fd, errno2name()); + rc = syscall(__NR_fchmod, fd, 004); + printf("fchmod(%d, 004) = %s\n", fd, sprintrc(rc)); puts("+++ exited with 0 +++"); return 0; diff --git a/tests/fchmod.test b/tests/fchmod.test index 32ad456c..4cb12632 100755 --- a/tests/fchmod.test +++ b/tests/fchmod.test @@ -3,4 +3,4 @@ # Check fchmod syscall decoding. . "${srcdir=.}/init.sh" -run_strace_match_diff -a16 +run_strace_match_diff -a15