shred: fix pattern selection for certain iteration counts
[coreutils.git] / tests / split / suffix-auto-length.sh
blob6ef221a1686d2a448ed5aab3fc68f8cff893e849
1 #!/bin/sh
2 # Test the suffix auto width functionality
4 # Copyright (C) 2012-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
23 # ensure auto widening is off when start number specified
24 truncate -s12 file.in || framework_failure_
25 returns_ 1 split file.in -b1 --numeric=89 || fail=1
26 test "$(ls -1 x* | wc -l)" = 11 || fail=1
27 rm -f x*
29 # ensure auto widening works when no start num specified
30 truncate -s91 file.in || framework_failure_
31 for prefix in 'x' 'xx' ''; do
32 for add_suffix in '.txt' ''; do
33 split file.in "$prefix" -b1 --numeric --additional-suffix="$add_suffix" \
34 || fail=1
35 test "$(ls -1 $prefix*[0-9]*$add_suffix | wc -l)" = 91 || fail=1
36 test -e "${prefix}89$add_suffix" || fail=1
37 test -e "${prefix}9000$add_suffix" || fail=1
38 rm -f $prefix*[0-9]*$add_suffix
39 done
40 done
42 # ensure auto width with --number and start num < number of files
43 # That's the single run use case which is valid to adjust suffix len
44 truncate -s100 file.in || framework_failure_
45 split --numeric-suffixes=1 --number=r/100 file.in || fail=1
46 rm -f x*
48 # ensure no auto width with --number and start num >= number of files
49 # That's the multi run use case which is invalid to adjust suffix len
50 # as that would result in an incorrect order for the total output file set
51 returns_ 1 split --numeric-suffixes=100 --number=r/100 file.in || fail=1
53 Exit $fail