Home | History | Annotate | Download | only in tests
      1 #!/bin/sh
      2 
      3 # Check how ftruncate, lseek and stat family syscalls are traced.
      4 
      5 . "${srcdir=.}/init.sh"
      6 
      7 check_prog dd
      8 check_prog find
      9 check_prog grep
     10 check_prog rm
     11 
     12 umask 022
     13 truncate_cmd='dd seek=46118400000 obs=1 count=0 if=/dev/null of=sample'
     14 $truncate_cmd > $LOG 2>&1 ||
     15 	{ cat $LOG; framework_skip_ 'failed to create a large sparse file'; }
     16 rm -f sample
     17 
     18 $STRACE -edesc $truncate_cmd 2>&1 > /dev/null 2> $LOG &&
     19 LC_ALL=C grep -E -x 'ftruncate(64)?\(1, 46118400000\) += 0' $LOG > /dev/null ||
     20 	{ cat $LOG; fail_ 'strace -edesc failed to trace ftruncate/ftruncate64 properly'; }
     21 
     22 LC_ALL=C grep -E -x 'lseek\(1, 46118400000, SEEK_CUR\) += 46118400000|_llseek\(1, 46118400000, \[46118400000\], SEEK_CUR\) += 0' $LOG > /dev/null ||
     23 	{ cat $LOG; fail_ 'strace -edesc failed to trace lseek/_llseek properly'; }
     24 
     25 $STRACE -efile find -L sample > /dev/null 2> $LOG &&
     26 LC_ALL=C grep -E -x 'stat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, 0\) += 0' $LOG > /dev/null ||
     27 	{ cat $LOG; fail_ 'strace -efile failed to trace stat/stat64 properly'; }
     28 
     29 $STRACE -efile find sample > /dev/null 2> $LOG &&
     30 LC_ALL=C grep -E -x 'lstat(64)?\("sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}\) += 0|(new)?fstatat(64)?\(AT_FDCWD, "sample", \{st_mode=S_IFREG\|0644, st_size=46118400000, \.\.\.\}, AT_SYMLINK_NOFOLLOW\) += 0' $LOG > /dev/null ||
     31 	{ cat $LOG; fail_ 'strace -efile failed to trace fstatat/fstatat64 properly'; }
     32 
     33 rm -f sample
     34 
     35 exit 0
     36