summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-11-27 10:22:28 +0000
committerJim Meyering <jim@meyering.net>2001-11-27 10:22:28 +0000
commite91b426d5abca2fb701e1c4930deaf706ca3ef48 (patch)
treec2960e3c2b30859c8c64cce333878dc72057b898
parentf05548e77b5d29e248c1cc54938302ffd0a2c5e4 (diff)
downloadcoreutils-e91b426d5abca2fb701e1c4930deaf706ca3ef48.tar.xz
Compare all lines of output.
Update code to use `trap' and more up to date infrastructure.
-rwxr-xr-xtests/ls/rt-170
1 files changed, 36 insertions, 34 deletions
diff --git a/tests/ls/rt-1 b/tests/ls/rt-1
index fc91655cd..d485a67aa 100755
--- a/tests/ls/rt-1
+++ b/tests/ls/rt-1
@@ -1,52 +1,54 @@
#!/bin/sh
# Make sure name is used as secondary key when sorting on mtime or ctime.
-: ${LS=ls}
-: ${TOUCH=touch}
+. $srcdir/../envvar-check
+. $srcdir/../lang-default
if test "$VERBOSE" = yes; then
set -x
- $LS --version
+ ls --version
+ touch --version
fi
+pwd=`pwd`
tmp=t-ls.$$
+trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
+trap '(exit $?); exit' 1 2 13 15
-# 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
+framework_failure=0
+mkdir $tmp || framework_failure=1
+cd $tmp || framework_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
+touch -d "$date" c || framework_failure=1
+touch -d "$date" a || framework_failure=1
+touch -d "$date" b || framework_failure=1
-if test $test_failure = 1; then
- echo 'failure in testing framework'
- exit 1
+if test $framework_failure = 1; then
+ echo '$0: failure in testing framework' 1>&2
+ (exit 1); exit
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
+ls -1t a b c > out || fail=1
+cat <<EOF > exp
+a
+b
+c
+EOF
+cmp out exp || fail=1
+test $fail = 1 && diff -u out exp 2> /dev/null
+
+rm -rf out exp
+ls -1rt a b c > out || fail=1
+cat <<EOF > exp
+c
+b
+a
+EOF
+cmp out exp || fail=1
+test $fail = 1 && diff -u out exp 2> /dev/null
+
+(exit $fail); exit