Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / ls / rt-1
1 #!/bin/sh
2 # Make sure name is used as secondary key when sorting on mtime or ctime.
3
4 # Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc.
5
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 2 of the License, or
9 # (at your option) any later version.
10
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.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21 . $srcdir/../envvar-check
22 . $srcdir/../lang-default
23
24 if test "$VERBOSE" = yes; then
25   set -x
26   ls --version
27   touch --version
28 fi
29
30 pwd=`pwd`
31 tmp=t-ls.$$
32 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
33 trap '(exit $?); exit' 1 2 13 15
34
35 framework_failure=0
36 mkdir $tmp || framework_failure=1
37 cd $tmp || framework_failure=1
38
39 date=1998-01-15
40
41 touch -d "$date" c || framework_failure=1
42 touch -d "$date" a || framework_failure=1
43 touch -d "$date" b || framework_failure=1
44
45 if test $framework_failure = 1; then
46   echo "$0: failure in testing framework" 1>&2
47   (exit 1); exit 1
48 fi
49
50 fail=0
51
52 ls -1t a b c > out || fail=1
53 cat <<EOF > exp
54 a
55 b
56 c
57 EOF
58 cmp out exp || fail=1
59 test $fail = 1 && diff out exp 2> /dev/null
60
61 rm -rf out exp
62 ls -1rt a b c > out || fail=1
63 cat <<EOF > exp
64 c
65 b
66 a
67 EOF
68 cmp out exp || fail=1
69 test $fail = 1 && diff out exp 2> /dev/null
70
71 (exit $fail); exit $fail