[PATCH 2/4] tests: add unlinkat.test

Fei Jie feij.fnst at cn.fujitsu.com
Wed Apr 6 06:18:49 UTC 2016


* tests/unlinkat.c: New file.
* tests/unlinkat.test: New test.
* tests/.gitignore: Add unlinkat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add unlinkat.test.
---
 tests/.gitignore    |  1 +
 tests/Makefile.am   |  2 ++
 tests/unlinkat.c    | 28 ++++++++++++++++++++++++++++
 tests/unlinkat.test |  6 ++++++
 4 files changed, 37 insertions(+)
 create mode 100644 tests/unlinkat.c
 create mode 100755 tests/unlinkat.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 85a3491..9ebab08 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -160,6 +160,7 @@ umount2
 umovestr
 umovestr2
 uname
+unlinkat
 unix-pair-send-recv
 userfaultfd
 utime
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e03b619..651ebb0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -209,6 +209,7 @@ check_PROGRAMS = \
 	umovestr \
 	umovestr2 \
 	uname \
+	unlinkat \
 	unix-pair-send-recv \
 	userfaultfd \
 	utime \
@@ -396,6 +397,7 @@ DECODER_TESTS = \
 	umovestr.test \
 	umovestr2.test \
 	uname.test \
+	unlinkat.test \
 	userfaultfd.test \
 	utime.test \
 	utimensat.test \
diff --git a/tests/unlinkat.c b/tests/unlinkat.c
new file mode 100644
index 0000000..bf59c0e
--- /dev/null
+++ b/tests/unlinkat.c
@@ -0,0 +1,28 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_unlinkat
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	static const char sample[] = "unlinkat_sample";
+	const long int fd = (long int) 0xdeadbeefffffffff;
+	int rc = syscall(__NR_unlinkat, fd, sample, 0);
+	printf("unlinkat(%d, \"%s\", 0) = %d %s (%m)\n",
+	       (int) fd, sample, rc,
+	       errno == ENOSYS ? "ENOSYS" : "EBADF");
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_unlinkat")
+
+#endif
diff --git a/tests/unlinkat.test b/tests/unlinkat.test
new file mode 100755
index 0000000..864261f
--- /dev/null
+++ b/tests/unlinkat.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check unlinkat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a35
-- 
1.8.3.1







More information about the Strace-devel mailing list