]> granicus.if.org Git - strace/commitdiff
tests: check decoding of renameat2 syscall
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 26 Apr 2016 16:11:48 +0000 (16:11 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 26 Apr 2016 16:30:43 +0000 (16:30 +0000)
* tests/renameat2.c: New file.
* tests/renameat2.test: New test.
* tests/.gitignore: Add renameat2.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add renameat2.test.

tests/.gitignore
tests/Makefile.am
tests/renameat2.c [new file with mode: 0644]
tests/renameat2.test [new file with mode: 0755]

index c7db886e94464eea3658f6eff86a3398f0c3c8c5..9195b5b74ec7c638f2bbfe23c56fb2613c651f1a 100644 (file)
@@ -149,6 +149,7 @@ reboot
 recvmsg
 rename
 renameat
+renameat2
 restart_syscall
 rmdir
 rt_sigpending
index 25092e904fb8a41341cde622cc79744523403f26..a418b03f909bffedcb892f3c5b2d9d4b56615aa4 100644 (file)
@@ -200,7 +200,8 @@ check_PROGRAMS = \
        reboot \
        recvmsg \
        rename \
-       renameat\
+       renameat \
+       renameat2 \
        restart_syscall \
        rmdir \
        rt_sigpending \
@@ -463,6 +464,7 @@ DECODER_TESTS = \
        recvmsg.test \
        rename.test \
        renameat.test \
+       renameat2.test \
        rmdir.test \
        rt_sigpending.test \
        rt_sigprocmask.test \
diff --git a/tests/renameat2.c b/tests/renameat2.c
new file mode 100644 (file)
index 0000000..28a1b5b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Check decoding of renameat2 syscall.
+ *
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_renameat2
+
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       static const char oldpath[] = "renameat2_oldpath";
+       static const char newpath[] = "renameat2_newpath";
+       const unsigned long olddirfd =
+               (unsigned long) 0xfacefeedffffffff;
+       const unsigned long newdirfd =
+               (unsigned long) 0xfacefeed00000000 | -100U;
+
+       long rc = syscall(__NR_renameat2,
+                         olddirfd, oldpath, newdirfd, newpath, 1);
+       printf("renameat2(%d, \"%s\", AT_FDCWD, \"%s\", RENAME_NOREPLACE)"
+              " = %ld %s (%m)\n",
+              (int) olddirfd, oldpath, newpath, rc, errno2name());
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_renameat2")
+
+#endif
diff --git a/tests/renameat2.test b/tests/renameat2.test
new file mode 100755 (executable)
index 0000000..4c176bb
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check renameat2 syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff