]> granicus.if.org Git - strace/commitdiff
tests: add chroot.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Thu, 31 Mar 2016 08:06:52 +0000 (16:06 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 1 Apr 2016 23:34:33 +0000 (23:34 +0000)
* tests/chroot.c: New file.
* tests/chroot.test: New test.
* tests/.gitignore: Add chroot.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add chroot.test.

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

index 9ab1aaed7f882627ef6bc46daf10fbd86241a9ba..7e222741afbfcca19b166e4894ba2af5d65be92d 100644 (file)
@@ -16,6 +16,7 @@ attach-p-cmd-p
 bpf
 caps
 chmod
+chroot
 clock_nanosleep
 clock_xettime
 copy_file_range
index da9727133e289072a33e2757d04a0037688084cf..5dc7ad09e5861e303cd9b2448d948aa1c50ee92a 100644 (file)
@@ -67,6 +67,7 @@ check_PROGRAMS = \
        bpf \
        caps \
        chmod \
+       chroot \
        clock_nanosleep \
        clock_xettime \
        copy_file_range \
@@ -255,6 +256,7 @@ DECODER_TESTS = \
        bpf.test \
        caps.test \
        chmod.test \
+       chroot.test \
        clock_nanosleep.test \
        clock_xettime.test \
        copy_file_range.test \
diff --git a/tests/chroot.c b/tests/chroot.c
new file mode 100644 (file)
index 0000000..fb12a31
--- /dev/null
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_chroot
+
+# include <errno.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       static const char sample[] = "chroot.sample";
+       int rc = syscall(__NR_chroot ,sample);
+       const char *errno_text;
+       switch (errno) {
+               case ENOSYS:
+                       errno_text = "ENOSYS";
+                       break;
+               case EPERM:
+                       errno_text = "EPERM";
+                       break;
+               default:
+                       errno_text = "ENOENT";
+       }
+       printf("chroot(\"%s\") = %d %s (%m)\n",
+              sample, rc, errno_text);
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_chroot")
+
+#endif
diff --git a/tests/chroot.test b/tests/chroot.test
new file mode 100755 (executable)
index 0000000..3b384f5
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check chroot syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a24