dircolors: add screen-256color-bce to TERM list
[coreutils/ericb.git] / tests / touch / empty-file
blob9c11990dcc0cace35b86a8eb0552b4fba4542606
1 #!/bin/sh
2 # Make sure touch can set the mtime on an empty file.
4 # Copyright (C) 1998, 1999, 2000, 2005-2008 Free Software Foundation, Inc.
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 3 of the License, or
9 # (at your option) any later version.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # Volker Borchert reported that touch 3.16r (and presumably all before that)
21 # fails to work on SunOS 4.1.3 with `most of the recommended patches' when
22 # the empty file is on an NFS-mounted 4.2 volume.
24 if test "$VERBOSE" = yes; then
25 set -x
26 touch --version
29 . $srcdir/test-lib.sh
31 DEFAULT_SLEEP_SECONDS=2
32 SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
34 fail=0
36 # FIXME: find writable directories on other partitions
37 # and run the test in those directories, too.
39 : ${TOUCH_DIR_LIST=.}
42 for d in $TOUCH_DIR_LIST; do
43 rm -rf $d/a $d/b $d/c
44 > $d/a || framework_failure
45 test -f $d/a || framework_failure
46 > $d/b || framework_failure
47 test -f $d/b || framework_failure
48 > $d/c || framework_failure
49 test -f $d/c || framework_failure
50 done
52 echo sleeping for $SLEEP_SECONDS seconds...
53 sleep $SLEEP_SECONDS
54 for d in $TOUCH_DIR_LIST; do
55 touch $d/a || fail=1
56 set x `ls -t $d/a $d/b`
57 test "$*" = "x $d/a $d/b" || fail=1
58 done
60 echo sleeping for $SLEEP_SECONDS seconds...
61 sleep $SLEEP_SECONDS
62 for d in $TOUCH_DIR_LIST; do
63 touch $d/b
64 set x `ls -t $d/a $d/b`
65 test "$*" = "x $d/b $d/a" || fail=1
67 if touch - 1< $d/c 2> /dev/null; then
68 set x `ls -t $d/a $d/c`
69 test "$*" = "x $d/c $d/a" || fail=1
72 rm -rf $d/a $d/b $d/c
73 done
75 if test $fail != 0; then
76 cat 1>&2 <<EOF
77 *** This test has just failed. That can happen when the test is run in an
78 *** NFS-mounted directory on a system whose clock is not well synchronized
79 *** with that of the NFS server. If you think that is the reason, set the
80 *** environment variable SLEEP_SECONDS to some number of seconds larger than
81 *** the default of $DEFAULT_SLEEP_SECONDS and rerun the test.
82 EOF
85 Exit $fail