cf0a922674df15504978b1f4e7ea62d9c4470499
[platform/upstream/coreutils.git] / tests / touch / no-rights
1 #!/bin/sh
2 # Make sure touch can update the times on a file that is neither
3 # readable nor writable.
4
5 if test "$VERBOSE" = yes; then
6   set -x
7   touch --version
8 fi
9
10 DEFAULT_SLEEP_SECONDS=2
11 SLEEP_SECONDS=${SLEEP_SECONDS=$DEFAULT_SLEEP_SECONDS}
12
13 t1=no-rw1
14 t2=no-rw2
15 rm -rf $t1 $t2
16 : > $t1
17
18 # Make sure $t2 is two seconds newer than $t1.
19 echo sleeping for $SLEEP_SECONDS seconds...
20 sleep $SLEEP_SECONDS
21 : > $t2
22 fail=0
23
24 set x `ls -t $t1 $t2`
25 test "$*" = "x $t2 $t1" || fail=1
26
27 chmod 0 $t1
28 touch -d tomorrow -c $t1 || fail=1
29
30 set x `ls -t $t1 $t2`
31 test "$*" = "x $t1 $t2" || fail=1
32
33 # Also test the combination of --no-create and -a.
34 touch -a --no-create $t1 || fail=1
35
36 rm -f $t1 $t2
37
38 exit $fail