Debian Codegraph @

tests/long-line-vs-2GiB-read

raw
1 #!/bin/sh
2 # Ensure that grep can handle lines 2GiB long.
3 # Before grep-2.16, a line of length 2^31 or greater would provoke
4 # an "Invalid argument" (EINVAL) failure from the read syscall on
5 # systems like OS/X 10.8.5.
6
7 . "${srcdir=.}/init.sh"; path_prepend_ ../src
8
9 # Searching 2GiB takes a while.
10 expensive_
11
12 echo big > exp || framework_failure_
13
14 MiB=1048576
15 dd bs=$MiB seek=2048 of=big < /dev/null || framework_failure_
16 echo x >> big || framework_failure_
17 grep -l x big > out 2> err || fail=1
18
19 # Not everyone has 2GB of memory free.
20 grep '^grep: memory exhausted$' err && skip_ 'memory exhausted'
21
22 compare exp out || fail=1
23 compare /dev/null err || fail=1
24
25 Exit $fail