[PATCH 10/11] tests: Add test for decoding fallocate syscall

Eugene Syromyatnikov evgsyr at gmail.com
Wed Sep 21 21:21:50 UTC 2016


* tests/.gitignore: Add fallocate.
* tests/Makefile.am (check_PROGRAMS): Likewise.
  (DECODER_TESTS): Add fallocate.test.
* fallocate.c: New file.
* fallocate.test: Likewise.
---
 configure.ac         |    1 +
 tests/.gitignore     |    1 +
 tests/Makefile.am    |    2 ++
 tests/fallocate.c    |   38 ++++++++++++++++++++++++++++++++++++++
 tests/fallocate.test |    6 ++++++
 5 files changed, 48 insertions(+)
 create mode 100644 tests/fallocate.c
 create mode 100755 tests/fallocate.test

diff --git a/configure.ac b/configure.ac
index 5c924e7..404dfb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -281,6 +281,7 @@ AC_TYPE_UID_T
 
 AC_CHECK_FUNCS(m4_normalize([
 	accept4
+	fallocate
 	fanotify_mark
 	fopen64
 	fork
diff --git a/tests/.gitignore b/tests/.gitignore
index bdb2d9a..c3665c2 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -44,6 +44,7 @@ execve-v
 execveat
 execveat-v
 faccessat
+fallocate
 fanotify_mark
 fchdir
 fchmod
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ac579c7..4fdc877 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -103,6 +103,7 @@ check_PROGRAMS = \
 	execveat \
 	execveat-v \
 	faccessat \
+	fallocate \
 	fanotify_mark \
 	fchdir \
 	fchmod \
@@ -442,6 +443,7 @@ DECODER_TESTS = \
 	execveat-v.test \
 	execveat.test \
 	faccessat.test \
+	fallocate.test \
 	fanotify_mark.test \
 	fchdir.test \
 	fchmod.test \
diff --git a/tests/fallocate.c b/tests/fallocate.c
new file mode 100644
index 0000000..563f2ec
--- /dev/null
+++ b/tests/fallocate.c
@@ -0,0 +1,38 @@
+#include "tests.h"
+
+#include <asm/unistd.h>
+
+#if defined(__NR_fallocate) && defined(HAVE_FALLOCATE) && HAVE_FALLOCATE
+
+# include <fcntl.h>
+# include <stdio.h>
+
+# include "xlat.h"
+# include "xlat/falloc_flags.h"
+
+int
+main(void)
+{
+	static const int bogus_fd = 0xbeefface;
+	static const int bogus_mode = 0xdeadca75;
+	static const off_t bogus_offset = (off_t) 0xbadc0dedda7a1057LLU;
+	static const off_t bogus_len = (off_t) 0xbadfaceca7b0d1e5LLU;
+
+	long rc;
+
+	rc = fallocate(bogus_fd, bogus_mode, bogus_offset, bogus_len);
+	printf("fallocate(%d, ", bogus_fd);
+	printflags(falloc_flags, (unsigned) bogus_mode, "FALLOC_FL_???");
+	printf(", %lld, %lld) = %s\n",
+		(long long) bogus_offset, (long long) bogus_len, sprintrc(rc));
+
+	puts("+++ exited with 0 +++");
+
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_fallocate && HAVE_FALLOCATE");
+
+#endif
diff --git a/tests/fallocate.test b/tests/fallocate.test
new file mode 100755
index 0000000..405187e
--- /dev/null
+++ b/tests/fallocate.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check getcwd syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a18
-- 
1.7.10.4





More information about the Strace-devel mailing list