summaryrefslogtreecommitdiff
path: root/tests/ls/time-1
blob: a5594ae262e5d67fc465b9994254e5ba052bb2e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
# Test some of ls's sorting options.

: ${LS=ls}
test=time-1

if test "$VERBOSE" = yes; then
  set -x
  $LS --version
fi

tmp=t-ls.$$

# We're going to LS from a subdir.  Prepend ../ if $LS is not an
# absolute file name.
case $LS in
  /*) ;;
  *) LS=../$LS
esac

test_failure=0
mkdir $tmp || test_failure=1
cd $tmp || test_failure=1

: > a || test_failure=1
sleep 1
: > b || test_failure=1
: > c || test_failure=1
sleep 1
cat a || test_failure=1

mv c d || test_failure=1

if test $test_failure = 1; then
  echo 'failure in testing framework'
  exit 1
fi

fail=0

# A was accessed more recently.
set `$LS -u a b`
test "$*" = 'a b' && : || fail=1

# B was modified more recently.
set `$LS -t a b`
test "$*" = 'b a' && : || fail=1

# D has newer ctime.
set `$LS -c a d`
test "$*" = 'd a' && : || fail=1

cd ..
rm -rf $tmp

exit $fail