tests: add chroot.test

* 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.
This commit is contained in:
Fei Jie 2016-03-31 16:06:52 +08:00 committed by Dmitry V. Levin
parent 4c4ab0fe82
commit d82b0d8ceb
4 changed files with 46 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -16,6 +16,7 @@ attach-p-cmd-p
bpf
caps
chmod
chroot
clock_nanosleep
clock_xettime
copy_file_range

View 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 \

37
tests/chroot.c Normal file
View File

@ -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

6
tests/chroot.test Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Check chroot syscall decoding.
. "${srcdir=.}/init.sh"
run_strace_match_diff -a24