summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/long-line-vs-2GiB-read
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
commit29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch)
tree63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/grep/tests/long-line-vs-2GiB-read
parentInitial commit. (diff)
downloadkbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.tar.xz
kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.zip
Adding upstream version 1:0.1.9998svn3589+dfsg.upstream/1%0.1.9998svn3589+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/grep/tests/long-line-vs-2GiB-read')
-rwxr-xr-xsrc/grep/tests/long-line-vs-2GiB-read25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/grep/tests/long-line-vs-2GiB-read b/src/grep/tests/long-line-vs-2GiB-read
new file mode 100755
index 0000000..29d29ec
--- /dev/null
+++ b/src/grep/tests/long-line-vs-2GiB-read
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Ensure that grep can handle lines 2GiB long.
+# Before grep-2.16, a line of length 2^31 or greater would provoke
+# an "Invalid argument" (EINVAL) failure from the read syscall on
+# systems like OS/X 10.8.5.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+# Searching 2GiB takes a while.
+expensive_
+
+echo big > exp || framework_failure_
+
+MiB=1048576
+dd bs=$MiB seek=2048 of=big < /dev/null || framework_failure_
+echo x >> big || framework_failure_
+grep -l x big > out 2> err || fail=1
+
+# Not everyone has 2GB of memory free.
+grep '^grep: memory exhausted$' err && skip_ 'memory exhausted'
+
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+Exit $fail