summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2013-05-02 00:44:57 +0000
committerDmitry V. Levin <ldv@altlinux.org>2013-05-02 00:44:57 +0000
commit318b0dde768e0b2360082c50b286e003f914a49f (patch)
tree6798406e6d213f78653299ed87788e62fb8ad589 /tests
parent0eeda2cdaac422a1510be642571771d22c5349d6 (diff)
downloadstrace-318b0dde768e0b2360082c50b286e003f914a49f.tar.gz
strace-318b0dde768e0b2360082c50b286e003f914a49f.tar.bz2
strace-318b0dde768e0b2360082c50b286e003f914a49f.tar.xz
tests: add basic test for ftruncate, lseek and stat family syscalls
* tests/stat: New test. * tests/Makefile.am (TESTS): Add stat.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/stat38
2 files changed, 39 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b7776b7..aaf103a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
# Automake input for strace tests.
-TESTS = ptrace_setoptions strace-f qual_syscall
+TESTS = ptrace_setoptions strace-f qual_syscall stat
EXTRA_DIST = init.sh $(TESTS)
diff --git a/tests/stat b/tests/stat
new file mode 100755
index 0000000..d2abed0
--- /dev/null
+++ b/tests/stat
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Check how ftruncate, lseek and stat family syscalls are traced.
+
+. "${srcdir=.}/init.sh"
+
+check_strace
+check_prog dd
+check_prog find
+check_prog grep
+check_prog rm
+check_prog timeout
+
+umask 022
+truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
+$truncate_cmd > check.log 2>&1 ||
+ { cat check.log; framework_skip_ 'failed to create a large sparse file'; }
+rm -f sample
+
+timeout -s 9 $check_timeout \
+$STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> check.log &&
+LC_ALL=C grep -x 'ftruncate\(64\)\?(1, 46118400000) \+= 0' check.log > /dev/null ||
+ { cat check.log; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
+
+LC_ALL=C grep -x 'lseek(1, 46118400000, SEEK_CUR) \+= 46118400000\|_llseek(1, 46118400000, \[46118400000\], SEEK_CUR) \+= 0' check.log > /dev/null ||
+ { cat check.log; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
+
+timeout -s 9 $check_timeout \
+$STRACE -efile find -L sample > /dev/null 2> check.log &&
+LC_ALL=C grep -x 'stat\(64\)\?("sample", {st_mode=S_IFREG|0644, st_size=46118400000, \.\.\.}) \+= 0' check.log > /dev/null ||
+ { cat check.log; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
+
+timeout -s 9 $check_timeout \
+$STRACE -efile find sample > /dev/null 2> check.log &&
+LC_ALL=C grep '^[[:alnum:]_]*stat[[:alnum:]_]*([^()"]*"sample", {st_mode=S_IFREG|0644, st_size=46118400000, \.\.\.}' check.log > /dev/null ||
+ { cat check.log; fail_ 'strace -efile failed to trace newfstatat/fstatat64 properly'; }
+
+exit 0