summaryrefslogtreecommitdiff
path: root/tests/ls/rt-1
blob: fc91655cd444fbf2c818df20951d887ab71ae303 (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
#!/bin/sh
# Make sure name is used as secondary key when sorting on mtime or ctime.

: ${LS=ls}
: ${TOUCH=touch}

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

tmp=t-ls.$$

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

case $TOUCH in
  /*) ;;
  */*) TOUCH=../$TOUCH
esac

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

date=1998-01-15

$TOUCH -d "$date" c || test_failure=1
$TOUCH -d "$date" a || test_failure=1
$TOUCH -d "$date" b || test_failure=1

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

fail=0

set `$LS -t a b c`
test "$*" = 'a b c' && : || fail=1

set `$LS -rt a b c`
test "$*" = 'c b a' && : || fail=1

cd ..
rm -rf $tmp

exit $fail