shred: fix pattern selection for certain iteration counts
[coreutils.git] / tests / split / line-bytes.sh
blob6e2f1376538620a5c89f168df24ea9c8c0847416
1 #!/bin/sh
2 # test -C, --lines-bytes
4 # Copyright (C) 2013-2015 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 <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ split
21 require_ulimit_v_
24 # Ensure memory is not allocated up front
25 (ulimit -v 20000; split -C 'G' /dev/null) || fail=1
28 # Ensure correct operation with various split and buffer size combinations
30 lines=\
31 1~2222~3~4
33 printf '%s' "$lines" | tr '~' '\n' > in || framework_failure_
35 cat <<\EOF > splits_exp
36 1 1 1 1 1 1 1 1 1 1
37 2 2 2 1 2 1
38 2 3 2 2 1
39 2 4 3 1
40 2 5 3
41 2 5 3
42 7 3
43 7 3
44 9 1
45 9 1
47 EOF
49 seq 0 9 | tr -d '\n' > no_eol_in
51 cat <<\EOF > no_eol_splits_exp
52 1 1 1 1 1 1 1 1 1 1
53 2 2 2 2 2
54 3 3 3 1
55 4 4 2
56 5 5
57 6 4
58 7 3
59 8 2
60 9 1
63 EOF
65 for b in $(seq 10); do
66 > splits
67 > no_eol_splits
68 for s in $(seq 11); do
69 rm x??
70 split ---io=$b -C$s in || fail=1
71 cat x* > out || framework_failure_
72 compare in out || fail=1
73 stat -c %s x* | paste -s -d ' ' >> splits
75 rm x??
76 split ---io=$b -C$s no_eol_in || fail=1
77 cat x* > out || framework_failure_
78 cat xaa
79 compare no_eol_in out || fail=1
80 stat -c %s x* | paste -s -d ' ' >> no_eol_splits
81 done
82 compare splits_exp splits || fail=1
83 compare no_eol_splits_exp no_eol_splits || fail=1
84 done
86 Exit $fail