1#!/bin/sh 2# test -C, --lines-bytes 3 4# Copyright (C) 2013-2023 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 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ split 21 22vm=$(get_min_ulimit_v_ split -C 'K' /dev/null) \ 23 || skip_ "this shell lacks ulimit support" 24 25# Ensure memory is not allocated up front 26(ulimit -v $vm && split -C 'G' /dev/null) || fail=1 27 28 29# Ensure correct operation with various split and buffer size combinations 30 31lines=\ 321~2222~3~4 33 34printf '%s' "$lines" | tr '~' '\n' > in || framework_failure_ 35 36cat <<\EOF > splits_exp 371 1 1 1 1 1 1 1 1 1 382 2 2 1 2 1 392 3 2 2 1 402 4 3 1 412 5 3 422 5 3 437 3 447 3 459 1 469 1 4710 48EOF 49 50seq 0 9 | tr -d '\n' > no_eol_in 51 52cat <<\EOF > no_eol_splits_exp 531 1 1 1 1 1 1 1 1 1 542 2 2 2 2 553 3 3 1 564 4 2 575 5 586 4 597 3 608 2 619 1 6210 6310 64EOF 65 66for b in $(seq 10); do 67 > splits 68 > no_eol_splits 69 for s in $(seq 11); do 70 rm x?? 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 75 76 rm x?? 77 split ---io=$b -C$s no_eol_in || fail=1 78 cat x* > out || framework_failure_ 79 cat xaa 80 compare no_eol_in out || fail=1 81 stat -c %s x* | paste -s -d ' ' >> no_eol_splits 82 done 83 compare splits_exp splits || fail=1 84 compare no_eol_splits_exp no_eol_splits || fail=1 85done 86 87Exit $fail 88