]> granicus.if.org Git - strace/commitdiff
tests: add creat.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Fri, 25 Mar 2016 09:47:14 +0000 (17:47 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 25 Mar 2016 09:47:14 +0000 (09:47 +0000)
* tests/creat.c: New file.
* tests/creat.test: New test.
* tests/.gitignore: Add creat.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add creat.test.

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

index 3cc5ca5563e0c6c9b71088aad56c10ffeee8c77b..215976176b51bcfb1038a72c3f5e6bf8f9ea8aa8 100644 (file)
@@ -20,6 +20,7 @@ clock_nanosleep
 clock_xettime
 copy_file_range
 count-f
+creat
 dup
 dup2
 dup3
index f8e4aaf16ddb159c18462afb28c2a084fae4a806..9e4400965ccc3a568cd3d9d56c5bd0b8e570b485 100644 (file)
@@ -71,6 +71,7 @@ check_PROGRAMS = \
        clock_xettime \
        copy_file_range \
        count-f \
+       creat \
        dup \
        dup2 \
        dup3 \
@@ -243,6 +244,7 @@ DECODER_TESTS = \
        clock_nanosleep.test \
        clock_xettime.test \
        copy_file_range.test \
+       creat.test \
        dup.test \
        dup2.test \
        dup3.test \
diff --git a/tests/creat.c b/tests/creat.c
new file mode 100644 (file)
index 0000000..d922dd7
--- /dev/null
@@ -0,0 +1,29 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_creat
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/stat.h>
+# include <unistd.h>
+
+# define TMP_FILE "creat"
+
+int
+main(void)
+{
+       int rc = syscall(__NR_creat, TMP_FILE, S_IRUSR);
+       printf("creat(\"%s\", %#o) = %d %s (%m)\n",
+              TMP_FILE, S_IRUSR, rc,
+              errno == ENOSYS ? "ENOSYS" : "ETXTBSY");
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_creat")
+
+#endif
diff --git a/tests/creat.test b/tests/creat.test
new file mode 100755 (executable)
index 0000000..a692e19
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check creat syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -ecreat -a21 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"