[PATCH 2/3] tests: add rename.test

Fei Jie feij.fnst at cn.fujitsu.com
Fri Feb 26 09:41:38 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index e79d317..a5d586d 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -81,6 +81,7 @@ readlink
 readlinkat
 readv
 recvmsg
+rename
 restart_syscall
 rt_sigpending
 rt_sigprocmask
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d924b9a..4603c92 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -129,6 +129,7 @@ check_PROGRAMS = \
 	readlinkat \
 	readv \
 	recvmsg \
+	rename \
 	restart_syscall \
 	rt_sigpending \
 	rt_sigprocmask \
@@ -287,6 +288,7 @@ TESTS = \
 	readlinkat.test \
 	readv.test \
 	recvmsg.test \
+	rename.test \
 	rt_sigpending.test \
 	rt_sigprocmask.test \
 	rt_sigqueueinfo.test \
diff --git a/tests/rename.c b/tests/rename.c
new file mode 100644
index 0000000..126d985
--- /dev/null
+++ b/tests/rename.c
@@ -0,0 +1,27 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_rename
+
+# include <stdio.h>
+# include <unistd.h>
+
+# define OLD_FILE "rename_old"
+# define NEW_FILE "rename_new"
+
+int
+main(void)
+{
+	int rc = syscall(__NR_rename, OLD_FILE, NEW_FILE);
+	printf("rename(\"%s\", \"%s\") = %d ENOENT (%m)\n",
+	       OLD_FILE, NEW_FILE, rc);
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_rename")
+
+#endif
diff --git a/tests/rename.test b/tests/rename.test
new file mode 100755
index 0000000..6d87950
--- /dev/null
+++ b/tests/rename.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check rename syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -erename -a35 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list