diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:21:29 +0000 |
commit | 29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch) | |
tree | 63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/grep/tests/big-match | |
parent | Initial commit. (diff) | |
download | kbuild-upstream/1%0.1.9998svn3589+dfsg.tar.xz kbuild-upstream/1%0.1.9998svn3589+dfsg.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/big-match')
-rwxr-xr-x | src/grep/tests/big-match | 36 |
1 files changed, 36 insertions, 0 deletions
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 |