tests: add mknod.test

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

1
tests/.gitignore vendored
View File

@ -65,6 +65,7 @@ lstat64
membarrier
memfd_create
mincore
mknod
mlock2
mmap
mmap64

View File

@ -114,6 +114,7 @@ check_PROGRAMS = \
membarrier \
memfd_create \
mincore \
mknod \
mlock2 \
mmap \
mmap64 \
@ -282,6 +283,7 @@ DECODER_TESTS = \
membarrier.test \
memfd_create.test \
mincore.test \
mknod.test \
mlock2.test \
mmap.test \
mmap64.test \

29
tests/mknod.c Normal file
View File

@ -0,0 +1,29 @@
#include "tests.h"
#include <sys/syscall.h>
#ifdef __NR_mknod
# include <errno.h>
# include <stdio.h>
# include <sys/stat.h>
# include <unistd.h>
# define TMP_FILE "mknod"
int
main(void)
{
int rc = syscall(__NR_mknod, TMP_FILE, S_IFREG|0600, 0);
printf("mknod(\"%s\", S_IFREG|0600) = %d %s (%m)\n",
TMP_FILE, rc,
errno == ENOSYS ? "ENOSYS" : "EEXIST");
puts("+++ exited with 0 +++");
return 0;
}
#else
SKIP_MAIN_UNDEFINED("__NR_mknod")
#endif

11
tests/mknod.test Executable file
View File

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