Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / misc / split-fail
1 #!/bin/sh
2 # split must fail when given length/count of zero.
3
4 # Copyright (C) 2003, 2004, 2005, 2006 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 2 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, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21 if test "$VERBOSE" = yes; then
22   set -x
23   split --version
24 fi
25
26 . $srcdir/../lang-default
27
28 pwd=`pwd`
29 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
30 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
31 trap '(exit $?); exit $?' 1 2 13 15
32
33 framework_failure=0
34 mkdir -p $tmp || framework_failure=1
35 cd $tmp || framework_failure=1
36 touch in || framework_failure=1
37
38 if test $framework_failure = 1; then
39   echo "$0: failure in testing framework" 1>&2
40   (exit 1); exit 1
41 fi
42
43 fail=0
44
45 split -a 0 in 2> /dev/null || fail=1
46 split -b 0 in 2> /dev/null && fail=1
47 split -C 0 in 2> /dev/null && fail=1
48 split -l 0 in 2> /dev/null && fail=1
49
50 # Make sure that the obsolete -N notation still works
51 split -1 in 2> /dev/null || fail=1
52
53 # Then make sure that -0 evokes a failure.
54 split -0 in 2> /dev/null && fail=1
55
56 # Ensure that split --lines=N and --bytes=N work for N=2^32,
57 # assuming our host supports integers that wide.
58 if _4gb=`expr 4294967296 + 0 2>/dev/null`; then
59   split --lines=$_4gb in || fail=1
60   split --bytes=$_4gb in || fail=1
61 fi
62
63 # Currently (coreutils-5.0.1) split --line-bytes=M fails
64 # with `invalid number of bytes' for M=2^32 or larger.  Actually,
65 # the limit is SIZE_MAX, which is 2^32 on 32-bit systems.
66 # On 64-bit systems, there's no problem with a count of 2^32,
67 # So disable this test in order to avoid the `failure' on 64-bit systems.
68 #split --line-bytes=$_4gb 2> /dev/null in && fail=1
69
70 # Make sure that a huge obsolete option evokes the right failure.
71 split -99999999999999999991 2> out && fail=1
72
73 # On losing systems (x86 Solaris 5.9 c89), we get a message like this:
74 #   split: line count option -9999999999... is too large
75 # while on most, we get this:
76 #   split: line count option -99999999999999999991... is too large
77 # so map them both to -99*.
78 sed 's/99[19]*/99*/' out > out-t
79 mv -f out-t out
80
81 cat <<\EOF > exp
82 split: line count option -99*... is too large
83 EOF
84 cmp out exp || fail=1
85 test $fail = 1 && diff out exp 2> /dev/null
86
87
88 (exit $fail); exit $fail