[PATCH 1/3] tests: add lchown.test
Fei Jie
feij.fnst at cn.fujitsu.com
Tue Apr 12 06:57:45 UTC 2016
* tests/lchown.c: New file.
* tests/lchown.test: New test.
* tests/.gitignore: Add lchown.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add lchown.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/lchown.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
tests/lchown.test | 6 ++++++
4 files changed, 58 insertions(+)
create mode 100644 tests/lchown.c
create mode 100755 tests/lchown.test
diff --git a/tests/.gitignore b/tests/.gitignore
index 6aae5de..35db0da 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -67,6 +67,7 @@ ipc_sem
ipc_shm
ksysent
ksysent.h
+lchown
libtests.a
linkat
llseek
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2a4feb0..c3138eb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -117,6 +117,7 @@ check_PROGRAMS = \
ipc_sem \
ipc_shm \
ksysent \
+ lchown \
linkat \
llseek \
lseek \
@@ -321,6 +322,7 @@ DECODER_TESTS = \
ipc_msgbuf.test \
ipc_sem.test \
ipc_shm.test \
+ lchown.test \
linkat.test \
llseek.test \
lseek.test \
diff --git a/tests/lchown.c b/tests/lchown.c
new file mode 100644
index 0000000..f39797c
--- /dev/null
+++ b/tests/lchown.c
@@ -0,0 +1,49 @@
+#include "tests.h"
+#include <sys/syscall.h>
+#include <fcntl.h>
+
+#ifdef __NR_lchown
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+ static const char sample[] = "lchown_sample";
+ uid_t uid = geteuid();
+ uid_t gid = getegid();
+
+ if (open(sample, O_RDONLY | O_CREAT, 0400) == -1)
+ perror_msg_and_fail("open");
+
+ if (syscall(__NR_lchown, sample, uid, gid) == 0) {
+ printf("lchown(\"%s\", %d, %d) = 0\n",
+ sample, uid, gid);
+
+ if(unlink(sample))
+ perror_msg_and_fail("unlink");
+
+ if(syscall(__NR_lchown, sample, -1, -1) != -1)
+ perror_msg_and_fail("lchonw");
+
+ printf("lchown(\"%s\", -1, -1) = -1 ENOENT (%m)\n",
+ sample);
+ } else {
+ if (errno != ENOSYS)
+ perror_msg_and_fail("lchown");
+
+ printf("lchown(\"%s\", %d, %d) = -1 ENOSYS (%m)\n",
+ sample, uid, gid);
+ }
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_lchown")
+
+#endif
diff --git a/tests/lchown.test b/tests/lchown.test
new file mode 100755
index 0000000..ceeaa85
--- /dev/null
+++ b/tests/lchown.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check lchown syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a30
--
1.8.3.1
More information about the Strace-devel
mailing list