From e91b426d5abca2fb701e1c4930deaf706ca3ef48 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 27 Nov 2001 10:22:28 +0000 Subject: Compare all lines of output. Update code to use `trap' and more up to date infrastructure. --- tests/ls/rt-1 | 70 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'tests') 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 < 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 < exp +c +b +a +EOF +cmp out exp || fail=1 +test $fail = 1 && diff -u out exp 2> /dev/null + +(exit $fail); exit -- cgit v1.2.3-54-g00ecf