1
0
mirror of git://git.sv.gnu.org/sed synced 2025-04-19 13:42:15 +03:00
sed/testsuite/regex-max-int.sh
Jim Meyering b4d01a9c91 maint: ensure that new "make syntax-check"-run sc_codespell passes
* cfg.mk (codespell_ignore_words_list): Ignore false-positives.
(exclude_file_name_regexp--sc_codespell): Skip some file names.
* sed/debug.c: Fix typo(s).
* sed/mbcs.c: Likewise.
* sed/sed.c: Likewise.
* testsuite/badenc.sh: Likewise.
* testsuite/compile-errors.sh: Likewise.
* testsuite/distrib.inp: Likewise.
* testsuite/distrib.sh: Likewise.
* testsuite/execute-tests.sh: Likewise.
* testsuite/mb-bad-delim.sh: Likewise.
* testsuite/mb-charclass-non-utf8.sh: Likewise.
* testsuite/regex-max-int.sh: Likewise.
* testsuite/subst-options.sh: Likewise.
* testsuite/test-mbrtowc.c: Likewise.
* testsuite/utf8-ru.sh: Likewise.
2025-03-29 11:11:20 -07:00

49 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# Test regex on input buffers larger than 2GB
# Copyright (C) 2018-2025 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
very_expensive_
print_ver_ sed
# Create a file larger than 2GB and containing a single line
# (resulting in a regex match against the entire file)
#
# This is a "very expensive" test, we can assume it is only run by
# developers or advanced users, and we can assume truncate(1) exists.
#
# On most modern file-systems, the file will be sparse and would not
# consume 2GB of physical storage.
truncate -s 1G input || framework_failure_
printf aaaa >> input || framework_failure_
truncate -s +1G input || framework_failure_
printf 'a\n' >> input || framework_failure_
# The expected error message
cat <<\EOF > exp-err1 || framework_failure_
sed: regex input buffer length larger than INT_MAX
EOF
# Before sed-4.5, this was silently a no-op: would not perform the substitution
# but would not indicate any error either (https://bugs.gnu.org/30520).
# Exit code 4 is "panic".
returns_ 4 sed 's/a/b/g' input >/dev/null 2>err1 || fail=1
compare_ exp-err1 err1 || fail=1
Exit $fail