From 0ebe67b780dce145308725472d40fbffbe152d00 Mon Sep 17 00:00:00 2001 From: Fei Jie Date: Fri, 25 Mar 2016 17:47:13 +0800 Subject: [PATCH] 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. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/mknod.c | 29 +++++++++++++++++++++++++++++ tests/mknod.test | 11 +++++++++++ 4 files changed, 43 insertions(+) create mode 100644 tests/mknod.c create mode 100755 tests/mknod.test diff --git a/tests/.gitignore b/tests/.gitignore index 60b642f4..3cc5ca55 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -65,6 +65,7 @@ lstat64 membarrier memfd_create mincore +mknod mlock2 mmap mmap64 diff --git a/tests/Makefile.am b/tests/Makefile.am index 06b38545..f8e4aaf1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/mknod.c b/tests/mknod.c new file mode 100644 index 00000000..7e80582e --- /dev/null +++ b/tests/mknod.c @@ -0,0 +1,29 @@ +#include "tests.h" +#include + +#ifdef __NR_mknod + +# include +# include +# include +# include + +# 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 diff --git a/tests/mknod.test b/tests/mknod.test new file mode 100755 index 00000000..a7803531 --- /dev/null +++ b/tests/mknod.test @@ -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"