4 # Copyright (C) 2001, 2002, 2003, 2004, 2005 2006 Free Software
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 if test "$VERBOSE" = yes; then
27 . $srcdir/../lang-default
31 trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
32 trap '(exit $?); exit' 1 2 13 15
35 mkdir $tmp || framework_failure=1
36 cd $tmp || framework_failure=1
38 if test $framework_failure = 1; then
39 echo "$0: failure in testing framework" 1>&2
45 # csplit could get a failed assertion to 2.0.17
46 (echo a; echo; echo) > in
47 csplit in '/^$/' 2 > out || fail=1
54 test $fail = 1 && diff out exp 2> /dev/null
57 # Ensure that xx02 contains just two newlines.
58 # This would fail due to reading from freed buffer with coreutils-5.0.91.
62 test $fail = 1 && diff out exp 2> /dev/null
65 # csplit would infloop
67 csplit in '/a/-1' '{*}' > out || fail=1
73 test $fail = 1 && diff out exp 2> /dev/null
76 # `echo |csplit - 1 1' used to abort.
78 csplit in 1 1 > out 2> err || fail=1
85 test $fail = 1 && diff out exp 2> /dev/null
87 csplit: warning: line number `1' is the same as preceding line number
89 cmp err experr || fail=1
90 test $fail = 1 && diff err experr 2> /dev/null
91 rm -f in out exp err experr
93 # make sure `csplit FILE 0' fails.
95 csplit in 0 > out 2> err && fail=1
96 csplit in 2 1 > out 2>> err && fail=1
97 csplit in 3 3 > out 2>> err && fail=1
99 csplit: 0: line number must be greater than zero
100 csplit: line number `1' is smaller than preceding line number, 2
101 csplit: warning: line number `3' is the same as preceding line number
102 csplit: `3': line number out of range
104 cmp err experr || fail=1
105 test $fail = 1 && diff err experr 2> /dev/null
107 # Ensure that lines longer than the initial buffer length don't cause
108 # trouble (e.g. reading from freed memory, resulting in corrupt output).
109 # This test failed at least in coreutils-5.2.1 and 5.3.0, and was fixed
111 rm -f in out exp err experr xx??
112 printf 'x%8199s\nx\n%8199s\nx\n' x x > in
113 csplit in '/x\{1\}/' '{*}' > /dev/null || fail=1
114 cat xx?? | cmp - in || fail=1
116 (exit $fail); exit $fail