fd9e120ab33d72cea327dc76a3acd3f0663f8bb8
[platform/upstream/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 if test "$VERBOSE" = yes; then
7   set -x
8   tac --version
9 fi
10
11 . $srcdir/../lang-default
12
13 # See if the envvar is defined.
14 if test x = "x$FULL_PARTITION_TMPDIR"; then
15   echo "$0: FULL_PARTITION_TMPDIR not defined; skipping this test" 1>&2
16   (exit 77); exit 77
17 fi
18
19 if ! test -d "$FULL_PARTITION_TMPDIR"; then
20   echo "$0: $FULL_PARTITION_TMPDIR:" \
21     "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2
22   (exit 1); exit 1
23 fi
24
25 pwd=`pwd`
26 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
27 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
28 trap '(exit $?); exit $?' 1 2 13 15
29
30 framework_failure=0
31 mkdir -p $tmp || framework_failure=1
32 cd $tmp || framework_failure=1
33
34 fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$"
35 t0="$t0 $fp_tmp"
36 # Make sure we can create an empty file there (i.e. no shortage of inodes).
37 if ! touch $fp_tmp; then
38   echo "$0: $fp_tmp: cannot create empty file" 1>&2
39   (exit 1); exit 1
40 fi
41
42 # Make sure that we fail when trying to create a file large enough
43 # to consume a non-inode block.
44 if seq 1000 > $fp_tmp 2>/dev/null; then
45   echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2
46   (exit 1); exit 1
47 fi
48
49 seq 5 > in
50
51 if test $framework_failure = 1; then
52   echo "$0: failure in testing framework" 1>&2
53   (exit 1); exit 1
54 fi
55
56 fail=0
57
58 # Give tac a fifo command line argument.
59 # This makes it try to create a temporary file in $TMPDIR.
60 mkfifo fifo
61 seq 1000 > fifo &
62 TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1
63
64 cat <<\EOF > exp || fail=1
65 5
66 4
67 3
68 2
69 1
70 EOF
71
72 cmp out exp || fail=1
73 test $fail = 1 && diff out exp 2> /dev/null
74
75 (exit $fail); exit $fail