tests: add faccessat.test

* tests/faccessat.c: New file.
* tests/faccessat.test: New test.
* tests/.gitignore: Add faccessat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add faccessat.test.
This commit is contained in:
Fei Jie 2016-03-25 17:47:15 +08:00 committed by Dmitry V. Levin
parent 8346e63e43
commit e2975b61b3
4 changed files with 43 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -30,6 +30,7 @@ execve
execve-v
execveat
execveat-v
faccessat
fanotify_mark
fchmod
fcntl

View File

@ -81,6 +81,7 @@ check_PROGRAMS = \
execve-v \
execveat \
execveat-v \
faccessat \
fanotify_mark \
fchmod \
fcntl \
@ -254,6 +255,7 @@ DECODER_TESTS = \
execve-v.test \
execveat.test \
execveat-v.test \
faccessat.test \
fanotify_mark.test \
fchmod.test \
fcntl.test \

29
tests/faccessat.c Normal file
View File

@ -0,0 +1,29 @@
#include "tests.h"
#include <sys/syscall.h>
#ifdef __NR_faccessat
# include <errno.h>
# include <stdio.h>
# include <unistd.h>
# define TMP_FILE "faccessat_tmpfile"
int
main(void)
{
const long int fd = (long int) 0xdeadbeefffffffff;
int rc = syscall(__NR_faccessat, fd, TMP_FILE, F_OK);
printf("faccessat(%d, \"%s\", F_OK) = %d %s (%m)\n",
(int) fd, TMP_FILE, rc,
errno == ENOSYS ? "ENOSYS" : "EBADF");
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_faccessat")
#endif

11
tests/faccessat.test Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# Check faccessat syscall decoding.
. "${srcdir=.}/init.sh"
run_prog > /dev/null
OUT="$LOG.out"
run_strace -efaccessat $args > "$OUT"
match_diff "$LOG" "$OUT"
rm -f "$OUT"