2 # test -C, --lines-bytes
4 # Copyright (C) 2013-2024 Free Software Foundation, Inc.
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.
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.
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/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 # Ensure memory is not allocated up front
24 vm
=$
(get_min_ulimit_v_
split -C 'K' /dev
/null
) && {
25 (ulimit -v $vm && split -C 'G' /dev
/null
) || fail
=1
29 # Ensure correct operation with various split and buffer size combinations
34 printf '%s' "$lines" |
tr '~' '\n' > in || framework_failure_
36 cat <<\EOF
> splits_exp
50 seq 0 9 |
tr -d '\n' > no_eol_in
52 cat <<\EOF
> no_eol_splits_exp
66 for b
in $
(seq 10); do
69 for s
in $
(seq 11); do
71 split ---io=$b -C$s in || fail
=1
72 cat x
* > out || framework_failure_
73 compare
in out || fail
=1
74 stat
-c %s x
* |
paste -s -d ' ' >> splits
77 split ---io=$b -C$s no_eol_in || fail
=1
78 cat x
* > out || framework_failure_
80 compare no_eol_in out || fail
=1
81 stat
-c %s x
* |
paste -s -d ' ' >> no_eol_splits
83 compare splits_exp splits || fail
=1
84 compare no_eol_splits_exp no_eol_splits || fail
=1
87 # Test hold buffer management with --lines-bytes.
88 # The following triggers (with ASAN) a heap overflow issue
89 # between coreutils 9.2 and 9.4 inclusive.
90 printf '%131070s\n' '' >expaa || framework_failure_
91 printf 'x\n' >expab || framework_failure_
92 printf '%131071s\n' '' >expac || framework_failure_
93 cat expaa expab expac
>bigin || framework_failure_
94 split -C 131072 ---io=131072 bigin || fail
=1
95 compare expaa xaa || fail
=1
96 compare expab xab || fail
=1
97 compare expac xac || fail
=1