Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / misc / tac-continue
1 #!/bin/sh
2 # Ensure that tac processes all command line arguments, even
3 # when it encounters an error with say the first one.
4 # With coreutils-5.2.1 and earlier, this test would fail.
5
6 # Copyright (C) 2004, 2006 Free Software Foundation, Inc.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
22
23 if test "$VERBOSE" = yes; then
24   set -x
25   tac --version
26 fi
27
28 . $srcdir/../lang-default
29
30 # See if the envvar is defined.
31 if test x = "x$FULL_PARTITION_TMPDIR"; then
32   echo "$0: FULL_PARTITION_TMPDIR not defined; skipping this test" 1>&2
33   (exit 77); exit 77
34 fi
35
36 if ! test -d "$FULL_PARTITION_TMPDIR"; then
37   echo "$0: $FULL_PARTITION_TMPDIR:" \
38     "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2
39   (exit 1); exit 1
40 fi
41
42 pwd=`pwd`
43 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
44 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
45 trap '(exit $?); exit $?' 1 2 13 15
46
47 framework_failure=0
48 mkdir -p $tmp || framework_failure=1
49 cd $tmp || framework_failure=1
50
51 fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$"
52 t0="$t0 $fp_tmp"
53 # Make sure we can create an empty file there (i.e. no shortage of inodes).
54 if ! touch $fp_tmp; then
55   echo "$0: $fp_tmp: cannot create empty file" 1>&2
56   (exit 1); exit 1
57 fi
58
59 # Make sure that we fail when trying to create a file large enough
60 # to consume a non-inode block.
61 if seq 1000 > $fp_tmp 2>/dev/null; then
62   echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2
63   (exit 1); exit 1
64 fi
65
66 seq 5 > in
67
68 if test $framework_failure = 1; then
69   echo "$0: failure in testing framework" 1>&2
70   (exit 1); exit 1
71 fi
72
73 fail=0
74
75 # Give tac a fifo command line argument.
76 # This makes it try to create a temporary file in $TMPDIR.
77 mkfifo fifo
78 seq 1000 > fifo &
79 TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1
80
81 cat <<\EOF > exp || fail=1
82 5
83 4
84 3
85 2
86 1
87 EOF
88
89 cmp out exp || fail=1
90 test $fail = 1 && diff out exp 2> /dev/null
91
92 (exit $fail); exit $fail