source: trunk/src/sed/testsuite/regex-max-int.sh

Last change on this file was 3613, checked in by bird, 10 months ago

src/sed: Merged in changes between 4.1.5 and 4.9 from the vendor branch. (svn merge /vendor/sed/4.1.5 /vendor/sed/current .)

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/bin/sh
2# Test regex on input buffers larger than 2GB
3
4# Copyright (C) 2018-2022 Free Software Foundation, Inc.
5
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <https://www.gnu.org/licenses/>.
18. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
19very_expensive_
20print_ver_ sed
21
22# Create a file larger than 2GB and containing a single line
23# (resulting in a regex match against the entire file)
24#
25# This is a "very expensive" test, we can assume it is only run by
26# developers or advanced users, and we can assume truncate(1) exists.
27#
28# On most modern file-systems, the file will be sparse and would not
29# consume 2GB of physical storage.
30
31truncate -s 1G input || framework_failure_
32printf aaaa >> input || framework_failure_
33truncate -s +1G input || framework_failure_
34printf 'a\n' >> input || framework_failure_
35
36# The expected error message
37cat <<\EOF > exp-err1 || framework_failure_
38sed: regex input buffer length larger than INT_MAX
39EOF
40
41
42# Before sed-4.5, this was silently a no-op: would not perform the subsitution
43# but would not indicate any error either (https://bugs.gnu.org/30520).
44# Exit code 4 is "panic".
45returns_ 4 sed 's/a/b/g' input >/dev/null 2>err1 || fail=1
46compare_ exp-err1 err1 || fail=1
47
48Exit $fail
Note: See TracBrowser for help on using the repository browser.