]> granicus.if.org Git - strace/commitdiff
tests: use sprintrc in tests/fchmod.c
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Sep 2016 00:19:20 +0000 (00:19 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Sep 2016 00:23:10 +0000 (00:23 +0000)
* tests/fchmod.c (main): Use sprintrc.  Add more fchmod decoding tests.
* tests/fchmod.test: Update the value specified for strace -a parameter.

tests/fchmod.c
tests/fchmod.test

index 5888561216d921f5f0caf1cc12d854da4a6ce358..932d083012a06482f0b996368071f02f1f870532 100644 (file)
@@ -1,5 +1,8 @@
 /*
+ * Check decoding of fchmod syscall.
+ *
  * Copyright (c) 2016 Fabien Siron <fabien.siron@epita.fr>
+ * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "tests.h"
 #include <asm/unistd.h>
 
-#if defined __NR_fchmod
+#ifdef __NR_fchmod
 
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <unistd.h>
+# include <fcntl.h>
+# include <sys/stat.h>
+# include <stdio.h>
+# include <unistd.h>
 
 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;
index 32ad456cf5d73512e4eb1efef1f9210c46f01045..4cb1263295b7a8200165a79d9dc8f4de82405bf8 100755 (executable)
@@ -3,4 +3,4 @@
 # Check fchmod syscall decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a16
+run_strace_match_diff -a15