*** empty log message ***
[coreutils.git] / tests / misc / split-fail
blob93cf8d6f016ad40351c195e496920d053a89991a
1 #!/bin/sh
2 # split must fail when given length/count of zero.
4 if test "$VERBOSE" = yes; then
5 set -x
6 split --version
7 fi
9 . $srcdir/../lang-default
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 touch in || framework_failure=1
21 if test $framework_failure = 1; then
22 echo "$0: failure in testing framework" 1>&2
23 (exit 1); exit 1
26 fail=0
28 split -a 0 in 2> /dev/null || fail=1
29 split -b 0 in 2> /dev/null && fail=1
30 split -C 0 in 2> /dev/null && fail=1
31 split -l 0 in 2> /dev/null && fail=1
33 # Make sure that the obsolete -N notation still works
34 _POSIX2_VERSION=199209 split -1 in 2> /dev/null || fail=1
36 # Then make sure that -0 evokes a failure.
37 _POSIX2_VERSION=199209 split -0 in 2> /dev/null && fail=1
39 # Ensure that split --lines=N and --bytes=N work for N=2^32.
40 _4gb=4294967296
41 split --lines=$_4gb in || fail=1
42 split --bytes=$_4gb in || fail=1
44 # Currently (coreutils-5.0.1) split --line-bytes=M fails
45 # with `invalid number of bytes' for M=2^32 or larger. Actually,
46 # the limit is SIZE_MAX, which is 2^32 on 32-bit systems.
47 # On 64-bit systems, there's no problem with a count of 2^32,
48 # So disable this test in order to avoid the `failure' on 64-bit systems.
49 #split --line-bytes=$_4gb 2> /dev/null in && fail=1
51 # Make sure that a huge obsolete option evokes the right failure.
52 env -u _POSIX2_VERSION split -99999999999999999991 2> out && fail=1
53 cat <<\EOF > exp
54 split: line count option -99999999999999999991... is too large
55 EOF
56 cmp out exp || fail=1
57 test $fail = 1 && diff out exp 2> /dev/null
60 (exit $fail); exit $fail