Dmitry V. Levin | 318b0dd | 2013-05-02 00:44:57 +0000 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Check how ftruncate, lseek and stat family syscalls are traced. |
| 4 | |
| 5 | . "${srcdir=.}/init.sh" |
| 6 | |
| 7 | check_strace |
| 8 | check_prog dd |
| 9 | check_prog find |
| 10 | check_prog grep |
| 11 | check_prog rm |
| 12 | check_prog timeout |
| 13 | |
| 14 | umask 022 |
| 15 | truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample' |
| 16 | $truncate_cmd > check.log 2>&1 || |
| 17 | { cat check.log; framework_skip_ 'failed to create a large sparse file'; } |
| 18 | rm -f sample |
| 19 | |
| 20 | timeout -s 9 $check_timeout \ |
| 21 | $STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> check.log && |
| 22 | LC_ALL=C grep -x 'ftruncate\(64\)\?(1, 46118400000) \+= 0' check.log > /dev/null || |
| 23 | { cat check.log; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; } |
| 24 | |
| 25 | LC_ALL=C grep -x 'lseek(1, 46118400000, SEEK_CUR) \+= 46118400000\|_llseek(1, 46118400000, \[46118400000\], SEEK_CUR) \+= 0' check.log > /dev/null || |
| 26 | { cat check.log; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; } |
| 27 | |
| 28 | timeout -s 9 $check_timeout \ |
| 29 | $STRACE -efile find -L sample > /dev/null 2> check.log && |
| 30 | LC_ALL=C grep -x 'stat\(64\)\?("sample", {st_mode=S_IFREG|0644, st_size=46118400000, \.\.\.}) \+= 0' check.log > /dev/null || |
| 31 | { cat check.log; fail_ 'strace -efile failed to trace stat/stat64 properly'; } |
| 32 | |
| 33 | timeout -s 9 $check_timeout \ |
| 34 | $STRACE -efile find sample > /dev/null 2> check.log && |
| 35 | LC_ALL=C grep '^[[:alnum:]_]*stat[[:alnum:]_]*([^()"]*"sample", {st_mode=S_IFREG|0644, st_size=46118400000, \.\.\.}' check.log > /dev/null || |
| 36 | { cat check.log; fail_ 'strace -efile failed to trace newfstatat/fstatat64 properly'; } |
| 37 | |
| 38 | exit 0 |