summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/ls/Makefile.am2
-rwxr-xr-xtests/ls/color-dtype-dir25
-rwxr-xr-xtests/ls/dangle24
-rwxr-xr-xtests/ls/dired22
-rwxr-xr-xtests/ls/file-type29
-rwxr-xr-xtests/ls/follow-slink36
-rwxr-xr-xtests/ls/infloop23
-rwxr-xr-xtests/ls/inode19
-rwxr-xr-xtests/ls/m-option24
-rwxr-xr-xtests/ls/nameless-uid22
-rwxr-xr-xtests/ls/no-arg29
-rwxr-xr-xtests/ls/recursive28
-rwxr-xr-xtests/ls/rt-129
-rwxr-xr-xtests/ls/stat-dtype38
-rwxr-xr-xtests/ls/stat-failed29
-rwxr-xr-xtests/ls/stat-free-symlinks25
-rwxr-xr-xtests/ls/stat-vs-dirent18
-rwxr-xr-xtests/ls/symlink-slash22
-rwxr-xr-xtests/ls/x-option24
19 files changed, 106 insertions, 362 deletions
diff --git a/tests/ls/Makefile.am b/tests/ls/Makefile.am
index b2aca8b5a..9ef4afa9c 100644
--- a/tests/ls/Makefile.am
+++ b/tests/ls/Makefile.am
@@ -33,3 +33,5 @@ TESTS_ENVIRONMENT = \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PERL="$(PERL)" \
PROG=ls
+
+include $(top_srcdir)/tests/check.mk
diff --git a/tests/ls/color-dtype-dir b/tests/ls/color-dtype-dir
index 38b1e38ed..7a25c06d3 100755
--- a/tests/ls/color-dtype-dir
+++ b/tests/ls/color-dtype-dir
@@ -24,28 +24,14 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
# Don't let a different umask perturb the results.
umask 22
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir d other-writable sticky || framework_failure=1
-chmod o+w other-writable || framework_failure=1
-chmod o+t sticky || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir d other-writable sticky || framework_failure
+chmod o+w other-writable || framework_failure
+chmod o+t sticky || framework_failure
fail=0
@@ -62,7 +48,6 @@ cat <<\EOF > exp || fail=1
^[[m
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/dangle b/tests/ls/dangle
index 950cd4fd6..bd3633fab 100755
--- a/tests/ls/dangle
+++ b/tests/ls/dangle
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure ls properly handles dangling symlinks vs. ls's -L, -H, options.
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,22 +21,11 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-ln -s no-such-file dangle || framework_failure=1
-mkdir -p dir/sub || framework_failure=1
-ln -s dir slink-to-dir || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+ln -s no-such-file dangle || framework_failure
+mkdir -p dir/sub || framework_failure
+ln -s dir slink-to-dir || framework_failure
fail=0
@@ -59,7 +48,6 @@ sub
sub
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/dired b/tests/ls/dired
index 0889c973b..45cbdfcc7 100755
--- a/tests/ls/dired
+++ b/tests/ls/dired
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure --dired option works
-# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001-2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,22 +21,9 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-tmp=dired.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir dir || framework_failure=1
-
-if test $framework_failure = 1; then
- echo 'failure in testing framework' 1>&2
- (exit 1); exit 1
-fi
+mkdir dir || framework_failure
fail=0
@@ -48,7 +35,6 @@ cat <<EOF > exp
//DIRED-OPTIONS// --quoting-style=literal
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/file-type b/tests/ls/file-type
index b9286c207..533bec89c 100755
--- a/tests/ls/file-type
+++ b/tests/ls/file-type
@@ -1,7 +1,7 @@
#!/bin/sh
# contrast ls -F, ls -p, and ls --indicator-style=file-type
-# Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2005-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,17 +21,9 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
mkdir sub
cd sub
mkdir dir
@@ -48,11 +40,6 @@ mkfifo fifo
cd ..
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
-
fail=0
ls -F sub > out || fail=1
@@ -72,17 +59,13 @@ ls --indicator-style=file-type sub > out2 || fail=1
sed 's/[@|]$//' exp2 > exp3
ls -p sub > out3 || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
-cmp out2 exp2 || fail=1
-test $fail = 1 && diff out2 exp2 2> /dev/null
+compare out2 exp2 || fail=1
-cmp out3 exp3 || fail=1
-test $fail = 1 && diff out3 exp3 2> /dev/null
+compare out3 exp3 || fail=1
ls --color=auto -F sub > out || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/follow-slink b/tests/ls/follow-slink
index 2165c62e6..a7efadb17 100755
--- a/tests/ls/follow-slink
+++ b/tests/ls/follow-slink
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure ls -L always follows symlinks
-# Copyright (C) 2000, 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,30 +21,18 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-pwd=`pwd`
-tmp=follow-sl.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
# Isolate output files from directory being listed
-mkdir dir dir/sub dir1 || framework_failure=1
-cd dir || framework_failure=1
-ln -s link link || framework_failure=1
-ln -s ../../dir1 sub/link-to-dir || framework_failure=1
+mkdir dir dir/sub dir1 || framework_failure
+cd dir || framework_failure
+ln -s link link || framework_failure
+ln -s ../../dir1 sub/link-to-dir || framework_failure
# Make sure the symlink was created.
# `ln -s link link' succeeds, but creates no file on
# systems running some DJGPP-2.03 libc.
-ls -F link > /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
- echo 'failure in testing framework'
- (exit 1); exit 1
-fi
+ls -F link > /dev/null || framework_failure
fail=0
@@ -72,13 +60,7 @@ link-to-dir/
sub/link-to-dir:
EOF
-cmp out-L exp-L || {
- fail=1
- diff out-L exp-L
-}
-cmp out-FLR-sub exp-FLR-sub || {
- fail=1
- diff out-FLR-sub exp-FLR-sub
-}
+compare out-L exp-L || fail=1
+compare out-FLR-sub exp-FLR-sub || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/infloop b/tests/ls/infloop
index 209fd350c..cc93372c7 100755
--- a/tests/ls/infloop
+++ b/tests/ls/infloop
@@ -2,7 +2,7 @@
# show that the following no longer makes ls infloop
# mkdir loop; cd loop; ln -s ../loop sub; ls -RL
-# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001-2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,22 +23,10 @@ if test "$VERBOSE" = yes; then
fi
. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-tmp=infloop.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir loop || framework_failure=1
-ln -s ../loop loop/sub || framework_failure=1
-
-if test $framework_failure = 1; then
- echo 'failure in testing framework' 1>&2
- (exit 1); exit 1
-fi
+mkdir loop || framework_failure
+ln -s ../loop loop/sub || framework_failure
fail=0
@@ -54,6 +42,7 @@ sub
loop/sub/sub:
EOF
-cmp out bad 2>/dev/null && fail=1
+# Make sure we don't get the "bad" output.
+compare out bad > /dev/null 2>&1 && fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/inode b/tests/ls/inode
index c920dccd6..08ee5e1f7 100755
--- a/tests/ls/inode
+++ b/tests/ls/inode
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure that ls -i works properly on symlinks.
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,21 +21,10 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-touch f || framework_failure=1
-ln -s f slink || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch f || framework_failure
+ln -s f slink || framework_failure
fail=0
diff --git a/tests/ls/m-option b/tests/ls/m-option
index 6f7738741..db6e53393 100755
--- a/tests/ls/m-option
+++ b/tests/ls/m-option
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise the -m option
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,23 +21,10 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-seq 2000 > b || framework_failure=1
-touch a || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+seq 2000 > b || framework_failure
+touch a || framework_failure
fail=0
@@ -53,7 +40,6 @@ b
0 a, 12 b
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/nameless-uid b/tests/ls/nameless-uid
index 09e2b8176..7512c187d 100755
--- a/tests/ls/nameless-uid
+++ b/tests/ls/nameless-uid
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that ls -l works on files with nameless uid and/or gid
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,9 +21,9 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
$PERL -e 1 > /dev/null 2>&1 || {
echo 1>&2 "$0: configure didn't find a usable version of Perl," \
@@ -38,22 +38,8 @@ if test x$nameless_uid = x; then
(exit 77); exit 77
fi
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f || framework_failure=1
-chown $nameless_uid f || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch f || framework_failure
+chown $nameless_uid f || framework_failure
fail=0
diff --git a/tests/ls/no-arg b/tests/ls/no-arg
index 13f72b494..00b4d92b8 100755
--- a/tests/ls/no-arg
+++ b/tests/ls/no-arg
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure ls and `ls -R' do the right thing when invoked with no arguments.
-# Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,36 +21,24 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-pwd=`pwd`
-tmp=no-args.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir -p dir/subdir || framework_failure=1
-touch dir/subdir/file2 || framework_failure=1
-ln -s f symlink || framework_failure=1
+mkdir -p dir/subdir || framework_failure
+touch dir/subdir/file2 || framework_failure
+ln -s f symlink || framework_failure
-cat > exp <<\EOF || framework_failure=1
+cat > exp <<\EOF || framework_failure
dir
exp
out
symlink
EOF
-if test $framework_failure = 1; then
- echo 'failure in testing framework'
- (exit 1); exit 1
-fi
-
fail=0
ls -1 > out || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
cat > exp <<\EOF
.:
@@ -68,7 +56,6 @@ EOF
ls -R1 > out || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/recursive b/tests/ls/recursive
index 6e4cedd88..8aff3ed7e 100755
--- a/tests/ls/recursive
+++ b/tests/ls/recursive
@@ -2,7 +2,7 @@
# 4.1.1 and 4.1.2 had a bug whereby some recursive listings
# didn't include a blank line between per-directory groups of files.
-# Copyright (C) 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,24 +22,10 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-tmp=recursive.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir x y a b c a/1 a/2 a/3 || framework_failure=1
-touch f a/1/I a/1/II || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir x y a b c a/1 a/2 a/3 || framework_failure
+touch f a/1/I a/1/II || framework_failure
fail=0
@@ -64,8 +50,7 @@ b:
c:
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
rm -rf out exp
ls -R1 x y f > out || fail=1
@@ -77,7 +62,6 @@ x:
y:
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/rt-1 b/tests/ls/rt-1
index bf1ed955e..dce7c852d 100755
--- a/tests/ls/rt-1
+++ b/tests/ls/rt-1
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure name is used as secondary key when sorting on mtime or ctime.
-# Copyright (C) 1998, 2001, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2001-2002, 2004, 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. $srcdir/../envvar-check
. $srcdir/../lang-default
if test "$VERBOSE" = yes; then
@@ -25,25 +24,13 @@ if test "$VERBOSE" = yes; then
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
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
date=1998-01-15
-touch -d "$date" c || framework_failure=1
-touch -d "$date" a || framework_failure=1
-touch -d "$date" b || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch -d "$date" c || framework_failure
+touch -d "$date" a || framework_failure
+touch -d "$date" b || framework_failure
fail=0
@@ -53,8 +40,7 @@ a
b
c
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
rm -rf out exp
ls -1rt a b c > out || fail=1
@@ -63,7 +49,6 @@ c
b
a
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/stat-dtype b/tests/ls/stat-dtype
index 3c8a681f5..c5ea4f567 100755
--- a/tests/ls/stat-dtype
+++ b/tests/ls/stat-dtype
@@ -3,7 +3,7 @@
# Also check for the dtype-related (and fs-type dependent) bug
# in coreutils-6.0 that made ls -CF columns misaligned.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,39 +26,25 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
# Skip this test unless "." is on a file system with useful d_type info.
# FIXME: This uses "ls -p" to decide whether to test "ls" with other options,
# but if ls's d_type code is buggy then "ls -p" might be buggy too.
-mkdir -p c/d || framework_failure=1
-chmod a-x c || framework_failure=1
+mkdir -p c/d || framework_failure
+chmod a-x c || framework_failure
if test "X`ls -p c 2>&1`" != Xd/; then
echo "$0: '.' is not on a suitable file system for this test" 1>&2
echo "$0: skipping this test" 1>&2
(exit 77); exit 77
fi
-mkdir d || framework_failure=1
-ln -s / d/s || framework_failure=1
-chmod 600 d || framework_failure=1
+mkdir d || framework_failure
+ln -s / d/s || framework_failure
+chmod 600 d || framework_failure
-mkdir -p e/a2345 e/b || framework_failure=1
-chmod 600 e || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir -p e/a2345 e/b || framework_failure
+chmod 600 e || framework_failure
fail=0
@@ -67,8 +53,7 @@ cat <<\EOF > exp || fail=1
s@
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
rm -f out exp
# Check for the ls -CF misaligned-columns bug:
@@ -78,7 +63,6 @@ ls -CF e > out || fail=1
# rather than the appropriate TAB.
printf 'a2345/\tb/\n' > exp || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/stat-failed b/tests/ls/stat-failed
index 342fc2a80..02c3bf19c 100755
--- a/tests/ls/stat-failed
+++ b/tests/ls/stat-failed
@@ -2,7 +2,7 @@
# Verify that ls works properly when it fails to stat a file that is
# not mentioned on the command line.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,26 +22,13 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir d || framework_failure=1
-ln -s / d/s || framework_failure=1
-chmod 600 d || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir d || framework_failure
+ln -s / d/s || framework_failure
+chmod 600 d || framework_failure
fail=0
@@ -53,8 +40,7 @@ total 0
?????????? ? ? ? s
EOF
-sed 's/^l/?/' out | cmp - exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+sed 's/^l/?/' out | compare - exp || fail=1
# Ensure that the offsets in --dired output are accurate.
rm -f out exp
@@ -67,7 +53,6 @@ cat <<\EOF > exp || fail=1
//DIRED-OPTIONS// --quoting-style=literal
EOF
-sed 's/^ l/ ?/' out | cmp - exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+sed 's/^ l/ ?/' out | compare - exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/stat-free-symlinks b/tests/ls/stat-free-symlinks
index 1d654822b..7c0fce927 100755
--- a/tests/ls/stat-free-symlinks
+++ b/tests/ls/stat-free-symlinks
@@ -21,26 +21,12 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../strace
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch x || framework_failure=1
-chmod a+x x || framework_failure=1
-ln -s x link-to-x || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+touch x || framework_failure
+chmod a+x x || framework_failure
+ln -s x link-to-x || framework_failure
fail=0
@@ -64,7 +50,6 @@ test -s err && fail=1
printf '\033[m'
} > exp || fail=1
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail
diff --git a/tests/ls/stat-vs-dirent b/tests/ls/stat-vs-dirent
index 80ffc5a4c..c326bc9fa 100755
--- a/tests/ls/stat-vs-dirent
+++ b/tests/ls/stat-vs-dirent
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that d_ino (from ls -di) and st_ino (from stat --format=%i) match.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,21 +21,7 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
fail=0
diff --git a/tests/ls/symlink-slash b/tests/ls/symlink-slash
index 23566e35d..8deba0511 100755
--- a/tests/ls/symlink-slash
+++ b/tests/ls/symlink-slash
@@ -1,7 +1,7 @@
#!/bin/sh
# Do dereference a symlink arg if its name is written with a trailing slash.
-# Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2004, 2007 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -21,22 +21,11 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
-tmp=t-ls.$$
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir dir || framework_failure=1
-ln -s dir symlink || framework_failure=1
-
-if test $framework_failure = 1; then
- echo 'failure in testing framework'
- exit 1
-fi
+mkdir dir || framework_failure
+ln -s dir symlink || framework_failure
fail=0
set `ls -l symlink/`
@@ -44,7 +33,4 @@ set `ls -l symlink/`
# Prior to fileutils-4.0k, the following would have output `... symlink -> dir'.
test "$*" = 'total 0' && : || fail=1
-cd ..
-rm -rf $tmp
-
exit $fail
diff --git a/tests/ls/x-option b/tests/ls/x-option
index a0c41c24d..4fb27047c 100755
--- a/tests/ls/x-option
+++ b/tests/ls/x-option
@@ -21,25 +21,12 @@ if test "$VERBOSE" = yes; then
ls --version
fi
-. $srcdir/../envvar-check
. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir subdir || framework_failure=1
-touch subdir/b || framework_failure=1
-touch subdir/a || framework_failure=1
-
-if test $framework_failure = 1; then
- echo "$0: failure in testing framework" 1>&2
- (exit 1); exit 1
-fi
+mkdir subdir || framework_failure
+touch subdir/b || framework_failure
+touch subdir/a || framework_failure
fail=0
@@ -51,7 +38,6 @@ a b
b a
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
(exit $fail); exit $fail