File: big-hole

package info (click to toggle)
grep 3.11-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 16,392 kB
  • sloc: ansic: 95,031; sh: 12,720; perl: 606; makefile: 386; awk: 71; sed: 16
file content (30 lines) | stat: -rwxr-xr-x 1,025 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# Check that grep --binary-file=without-match quickly skips files with holes.

. "${srcdir=.}/init.sh"; path_prepend_ ../src

expensive_
require_perl_

# Skip this test if there is no usable SEEK_HOLE support,
# as is the case with linux-3.5.0 on ext4 and tmpfs file systems.
$PERL -e '$f=*STDERR; sysseek($f,2**22,0); syswrite($f,"a");' \
      -e 'exit ("0 but true" ne sysseek($f,0,4))' 2> seek-hole-test \
  || skip_ "this system/FS lacks SEEK_HOLE support"

# Try to make this test not THAT expensive, on typical hosts.
virtual_memory_KiB=10240
if echo x | (ulimit -v $virtual_memory_KiB && grep x) >/dev/null 2>&1; then
  ulimit -v $virtual_memory_KiB
fi

# Create a file that starts with at least a buffer's worth of text,
# but has a big hole later.
(${AWK-awk} 'BEGIN{ for (i=0;i<1000;i++) printf "%080d\n", 0 }' < /dev/null
  echo x | dd bs=1024k seek=8000000
) >8T-or-so || skip_ 'cannot create big sparse file'

grep --binary-file=without-match x 8T-or-so >/dev/null
test $? -eq 1 || fail=1

Exit $fail