From 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:21:29 +0200 Subject: Adding upstream version 1:0.1.9998svn3589+dfsg. Signed-off-by: Daniel Baumann --- src/grep/tests/big-match | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 src/grep/tests/big-match (limited to 'src/grep/tests/big-match') diff --git a/src/grep/tests/big-match b/src/grep/tests/big-match new file mode 100755 index 0000000..0da9731 --- /dev/null +++ b/src/grep/tests/big-match @@ -0,0 +1,36 @@ +#!/bin/sh +# Check that grep doesn't mishandle long matching lines. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src +expensive_ + +# Create a one-line file containing slightly more than 2 GiB. +echo x | dd bs=1024k seek=2048 >2G-plus-2 || framework_failure_ + +skip_diagnostic= + +# These two patterns catch different kinds of +# failures due to internal integer overflows. +# However, the second one, '^.*x\(\)\1', provokes +# so much memory consumption via regexec.c that it renders +# some systems unusable. +for pattern in '^.*'; do + diagnostic=$(LC_ALL=C grep -a "$pattern" 2G-plus-2 2>&1 >/dev/null) + status=$? + + case $status,$diagnostic in + 0,*) ;; + 2,*': line too long for re_search') + skip_diagnostic='regular expression library cannot handle the test' ;; + 137,''|2,*': memory exhausted') + # The 137/no-diagnostic arises when the kernel OOM-kills grep. + skip_diagnostic='not enough main memory to run the test' ;; + *) fail=1 ;; + esac +done + +case $fail,$skip_diagnostic in +0,?*) skip_ "$skip_diagnostic" ;; +esac + +Exit $fail -- cgit v1.2.3