Blame tests/big-hole

Packit 709fb3
#!/bin/sh
Packit 709fb3
# Check that grep --binary-file=without-match quickly skips files with holes.
Packit 709fb3
Packit 709fb3
. "${srcdir=.}/init.sh"; path_prepend_ ../src
Packit 709fb3
Packit 709fb3
expensive_
Packit 709fb3
Packit 709fb3
# Skip this test if there is no usable SEEK_HOLE support,
Packit 709fb3
# as is the case with linux-3.5.0 on ext4 and tmpfs file systems.
Packit 709fb3
$PERL -e '$f=*STDERR; sysseek($f,2**22,0); syswrite($f,"a");' \
Packit 709fb3
      -e 'exit ("0 but true" ne sysseek($f,0,4))' 2> seek-hole-test \
Packit 709fb3
  || skip_ "this system/FS lacks SEEK_HOLE support"
Packit 709fb3
Packit 709fb3
# Try to make this test not THAT expensive, on typical hosts.
Packit 709fb3
virtual_memory_KiB=10240
Packit 709fb3
if echo x | (ulimit -v $virtual_memory_KiB && grep x) >/dev/null 2>&1; then
Packit 709fb3
  ulimit -v $virtual_memory_KiB
Packit 709fb3
fi
Packit 709fb3
Packit 709fb3
# Create a file that starts with at least a buffer's worth of text,
Packit 709fb3
# but has a big hole later.
Packit 709fb3
(${AWK-awk} 'BEGIN{ for (i=0;i<1000;i++) printf "%080d\n", 0 }' < /dev/null
Packit 709fb3
  echo x | dd bs=1024k seek=8000000
Packit 709fb3
) >8T-or-so || skip_ 'cannot create big sparse file'
Packit 709fb3
Packit 709fb3
grep --binary-file=without-match x 8T-or-so >/dev/null
Packit 709fb3
test $? -eq 1 || fail=1
Packit 709fb3
Packit 709fb3
Exit $fail