[PATCH 4/4] tests: add renameat.test

Fei Jie feij.fnst at cn.fujitsu.com
Fri Mar 25 09:47:16 UTC 2016


* tests/renameat.c: New file.
* tests/renameat.test: New test.
* tests/.gitignore: Add renameat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add renameat.test.
---
 tests/.gitignore    |  1 +
 tests/Makefile.am   |  2 ++
 tests/renameat.c    | 31 +++++++++++++++++++++++++++++++
 tests/renameat.test | 11 +++++++++++
 4 files changed, 45 insertions(+)
 create mode 100644 tests/renameat.c
 create mode 100755 tests/renameat.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 8892c06..2798a2c 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -94,6 +94,7 @@ readlinkat
 readv
 recvmsg
 rename
+renameat
 restart_syscall
 rt_sigpending
 rt_sigprocmask
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 02a858b..951508d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -143,6 +143,7 @@ check_PROGRAMS = \
 	readv \
 	recvmsg \
 	rename \
+	renameat\
 	restart_syscall \
 	rt_sigpending \
 	rt_sigprocmask \
@@ -310,6 +311,7 @@ DECODER_TESTS = \
 	readv.test \
 	recvmsg.test \
 	rename.test \
+	renameat.test \
 	rt_sigpending.test \
 	rt_sigprocmask.test \
 	rt_sigqueueinfo.test \
diff --git a/tests/renameat.c b/tests/renameat.c
new file mode 100644
index 0000000..f17e9b0
--- /dev/null
+++ b/tests/renameat.c
@@ -0,0 +1,31 @@
+#include "tests.h"
+#include <errno.h>
+#include <sys/syscall.h>
+
+#ifdef __NR_renameat
+
+# include <stdio.h>
+# include <unistd.h>
+
+# define OLD_FILE "renameat_old"
+# define NEW_FILE "renameat_new"
+
+int
+main(void)
+{
+	const long int fd_old = (long int) 0xdeadbeefffffffff;
+	const long int fd_new = (long int) 0xdeadbeeffffffffe;
+	int rc = syscall(__NR_renameat, fd_old, OLD_FILE, fd_new, NEW_FILE);
+	printf("renameat(%d, \"%s\", %d, \"%s\") = %d %s (%m)\n",
+	       (int) fd_old, OLD_FILE, (int) fd_new, NEW_FILE, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_renameat")
+
+#endif
diff --git a/tests/renameat.test b/tests/renameat.test
new file mode 100755
index 0000000..728b18d
--- /dev/null
+++ b/tests/renameat.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check rename syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -erenameat $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list