Convert tests/mv, too.
authorJim Meyering <jim@meyering.net>
Thu, 6 Sep 2007 21:05:16 +0000 (23:05 +0200)
committerJim Meyering <jim@meyering.net>
Sat, 15 Sep 2007 06:40:38 +0000 (08:40 +0200)
* tests/other-fs-tmpdir: Before, all callers would exit 77 upon failure to
find the required dir.  Now, exit 77 in this script so callers don't have to.
Adjust callers.

39 files changed:
tests/mv/Makefile.am
tests/mv/acl
tests/mv/atomic
tests/mv/backup-dir
tests/mv/backup-is-src
tests/mv/childproof
tests/mv/diag
tests/mv/dir-file
tests/mv/dir2dir
tests/mv/dup-source
tests/mv/force
tests/mv/hard-2
tests/mv/hard-3
tests/mv/hard-4
tests/mv/hard-link-1
tests/mv/hard-verbose
tests/mv/i-2
tests/mv/i-3
tests/mv/i-4
tests/mv/i-5
tests/mv/i-link-no
tests/mv/into-self
tests/mv/into-self-2
tests/mv/into-self-3
tests/mv/into-self-4
tests/mv/leak-fd
tests/mv/mv-special-1
tests/mv/no-target-dir
tests/mv/part-fail
tests/mv/part-hardlink
tests/mv/part-rename
tests/mv/part-symlink
tests/mv/partition-perm
tests/mv/perm-1
tests/mv/reply-no
tests/mv/to-symlink
tests/mv/trailing-slash
tests/mv/update
tests/other-fs-tmpdir

index 9e0b2b8..d043c8b 100644 (file)
@@ -46,3 +46,5 @@ TESTS_ENVIRONMENT = \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
   CONFIG_HEADER=$(CONFIG_HEADER) \
   PROG=mv
+
+include $(top_srcdir)/tests/check.mk
index f82abda..0fd1fb3 100755 (executable)
@@ -2,7 +2,7 @@
 # move files/directories across file system boundaries
 # and make sure acls are preserved
 
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -18,9 +18,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . $srcdir/../acl
-. $srcdir/../other-fs-tmpdir
-# Make sure we get English translations.
-. $srcdir/../lang-default
 
 # Skip this test if cp was built without ACL support:
 grep '^#define USE_ACL 0' $CONFIG_HEADER > /dev/null && \
@@ -36,29 +33,14 @@ if test "$VERBOSE" = yes; then
   setfacl --version
 fi
 
-if test -z "$other_partition_tmpdir"; 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
-
-t0="$t0 $other_partition_tmpdir"
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
-touch file || framework_failure=1
+touch file || framework_failure
 t1=$other_partition_tmpdir/t1
-touch $t1 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+touch $t1 || framework_failure
 
 skip=no
 # Ensure that setfacl and getfacl work on this file system.
@@ -76,28 +58,23 @@ test $skip != no &&
 
 # move the access acl of a file
 mv file $other_partition_tmpdir || fail=1
-acl2=`cd $other_partition_tmpdir && getfacl file` || framework_failure=1
+acl2=`cd $other_partition_tmpdir && getfacl file` || framework_failure
 test "$acl1" = "$acl2" || fail=1
 
 # move the access acl of a directory
-mkdir dir || framework_failure=1
-setfacl -m user:bin:rw dir || framework_failure=1
-acl1=`getfacl dir` || framework_failure=1
+mkdir dir || framework_failure
+setfacl -m user:bin:rw dir || framework_failure
+acl1=`getfacl dir` || framework_failure
 mv dir $other_partition_tmpdir || fail=1
-acl2=`cd $other_partition_tmpdir && getfacl dir` || framework_failure=1
+acl2=`cd $other_partition_tmpdir && getfacl dir` || framework_failure
 test "$acl1" = "$acl2" || fail=1
 
 # move the default acl of a directory
-mkdir dir2 || framework_failure=1
-setfacl -d -m user:bin:rw dir2 || framework_failure=1
-acl1=`getfacl dir2` || framework_failure=1
+mkdir dir2 || framework_failure
+setfacl -d -m user:bin:rw dir2 || framework_failure
+acl1=`getfacl dir2` || framework_failure
 mv dir2 $other_partition_tmpdir || fail=1
-acl2=`cd $other_partition_tmpdir && getfacl dir2` || framework_failure=1
+acl2=`cd $other_partition_tmpdir && getfacl dir2` || framework_failure
 test "$acl1" = "$acl2" || fail=1
 
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
-
 exit $fail
index cf4dea4..ef30398 100755 (executable)
@@ -22,15 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../strace
-
-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
 
 # Before the fix, mv would unnecessarily unlink the destination symlink:
 #   $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2; strace -qe unlink /bin/mv -T s1 s2
@@ -40,13 +32,8 @@ cd $tmp || framework_failure=1
 #   $ rm -rf s[12]; ln -s / s1; ln -s /tmp s2; strace -qe unlink ./mv -T s1 s2
 #   $
 
-ln -s t1 s1 || framework_failure=1
-ln -s t2 s2 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+ln -s t1 s1 || framework_failure
+ln -s t2 s2 || framework_failure
 
 fail=0
 
index 8b80bd2..2880cbd 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure "mv --verbose --backup" works the same for dirs and non-dirs.
 
-# 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,25 +21,11 @@ if test "$VERBOSE" = yes; then
   mv --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 A B || framework_failure=1
-touch X Y || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir A B || framework_failure
+touch X Y || framework_failure
 
 fail=0
 
@@ -49,7 +35,6 @@ cat <<\EOF > exp || fail=1
 `A' -> `B' (backup: `B.~1~')
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 8e9bba0..f8be007 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Force mv to use the copying code.
 
-# Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc.
+# Copyright (C) 1998, 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,28 +21,17 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-
-if test -z "$other_partition_tmpdir"; then
-  exit 77
-fi
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 a="$other_partition_tmpdir/a"
 a2="$other_partition_tmpdir/a~"
 
-framework_failure=0
-rm -f $a $a2 || framework_failure=1
-echo a > $a || framework_failure=1
-echo a2 > $a2 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
-# Make sure we get English translations.
-. $srcdir/../lang-default
+rm -f $a $a2 || framework_failure
+echo a > $a || framework_failure
+echo a2 > $a2 || framework_failure
 
 # This mv command should exit nonzero.
 mv --b=simple $a2 $a > out 2>&1 && fail=1
@@ -57,8 +46,6 @@ cat > exp <<\EOF
 XXX: backing up `YYY' would destroy source;  `ZZZ' not moved
 EOF
 
-cmp out2 exp || fail=1
-
-rm -fr out out2 exp $a $a2 $other_partition_tmpdir
+compare out2 exp || fail=1
 
 exit $fail
index e35afb6..6d93974 100755 (executable)
@@ -25,26 +25,13 @@ if test "$VERBOSE" = yes; then
   ln --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=childproof.$$
-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 a b c || framework_failure=1
-echo a > a/f || framework_failure=1
-echo b > b/f || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+mkdir a b c || framework_failure
+echo a > a/f || framework_failure
+echo b > b/f || framework_failure
 
 fail=0
 
index d611b91..d7e70f3 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # make sure we get proper diagnostics: e.g., with --target-dir=d but no args
 
-# Copyright (C) 2000, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 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,24 +23,11 @@ fi
 
 # Make sure we get English translations.
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=diag-$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-touch f1 || framework_failure=1
-touch f2 || framework_failure=1
-touch d || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+touch f1 || framework_failure
+touch f2 || framework_failure
+touch d || framework_failure
 
 # These mv commands should all exit nonzero.
 
@@ -62,7 +49,7 @@ mv: target `f1' is not a directory
 mv: target `f2' is not a directory
 EOF
 
-cmp out exp || fail=1
+compare out exp || fail=1
 
 (exit $fail)
 exit $fail
index e9f00eb..61b7dea 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # mv must fail when src and dest are mismatched directory/non-directory.
 
-# Copyright (C) 2000, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 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,20 +21,10 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-tmp=mv-mismatch-$$
-pwd=`pwd`
-trap 'cd "$pwd" && rm -rf $tmp' 0 1 2 3 15
+. $srcdir/../test-lib.sh
 
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp
-mkdir -p dir/file || framework_failure=1
-> file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir -p dir/file || framework_failure
+> file || framework_failure
 
 fail=0
 
index a98e107..41b4c63 100755 (executable)
@@ -2,7 +2,7 @@
 # Ensure that mv prints the right diagnostic for a dir->dir move
 # where the destination directory is not empty.
 
-# 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,11 @@ if test "$VERBOSE" = yes; then
   mv --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 -p a/t b/t || framework_failure=1
-touch a/t/f || framework_failure=1
-
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p a/t b/t || framework_failure
+touch a/t/f || framework_failure
 
 fail=0
 
@@ -58,7 +43,6 @@ cat <<\EOF > exp || fail=1
 mv: cannot move `b/t' to `a/t': Directory not empty
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 28287e9..a851ba8 100755 (executable)
@@ -4,7 +4,7 @@
 # made this fail:  cp a a d/
 # Ensure that mv fails with a similar command.
 
-# 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
@@ -25,23 +25,9 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
-pwd=`pwd`
-tmp=dup-src.$$
-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
-
-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
 
@@ -66,8 +52,7 @@ $i: warning: source file \`a' specified more than once
 $i: warning: source file \`a' specified more than once
 $i: will not overwrite just-created \`d/a' with \`a'
 EOF
-  cmp out exp || fail=1
-  test $fail = 1 && diff out exp 2> /dev/null
+  compare out exp || fail=1
 done
 
 for i in mv; do
@@ -81,8 +66,7 @@ for i in mv; do
 $i: cannot stat \`a': No such file or directory
 $i: cannot stat \`a': No such file or directory
 EOF
-  cmp out exp || fail=1
-  test $fail = 1 && diff out exp 2> /dev/null
+  compare out exp || fail=1
 done
 
 (exit $fail); exit $fail
index 905f4c0..bc2603e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # move a file onto itself
 
-# Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2002, 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,14 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+
 ff=mvforce
 ff2=mvforce2
 
-framework_failure=0
-rm -f $ff $ff2 || framework_failure=1
-echo force-contents > $ff || framework_failure=1
-ln $ff $ff2 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
-# Make sure we get English translations.
-. $srcdir/../lang-default
+echo force-contents > $ff || framework_failure
+ln $ff $ff2 || framework_failure
 
 # This mv command should exit nonzero.
 mv $ff $ff > out 2>&1 && fail=1
@@ -44,13 +37,11 @@ cat > exp <<EOF
 mv: \`$ff' and \`$ff' are the same file
 EOF
 
-cmp out exp || fail=1
+compare out exp || fail=1
 test `cat $ff` = force-contents || fail=1
 
 # This should succeed, even though the source and destination
 # device and inodes are the same.
 mv $ff $ff2 || fail=1
 
-rm -fr out exp $ff $ff2
-
 exit $fail
index eb79377..62467e6 100755 (executable)
@@ -2,7 +2,7 @@
 # Ensure that moving hard-linked arguments onto existing destinations works.
 # Likewise when using cp --preserve=link.
 
-# 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
@@ -23,27 +23,14 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 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 dst || framework_failure=1
-(cd dst && touch a b c) || framework_failure=1
-touch a || framework_failure=1
-ln a b || framework_failure=1
-ln a c || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir dst || framework_failure
+(cd dst && touch a b c) || framework_failure
+touch a || framework_failure
+ln a b || framework_failure
+ln a c || framework_failure
 
 fail=0
 
index f8a4805..cb02422 100755 (executable)
@@ -2,7 +2,7 @@
 # Ensure that using `cp --preserve=link' to copy hard-linked arguments
 # onto existing destinations works, even when one of the link operations fails.
 
-# Copyright (C) 2003, 20062007 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
@@ -35,28 +35,15 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 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 -p x dst/x || framework_failure=1
-touch dst/x/b || framework_failure=1
+mkdir -p x dst/x || framework_failure
+touch dst/x/b || framework_failure
 chmod a-w dst/x
-touch a || framework_failure=1
-ln a x/b || framework_failure=1
-ln a c || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch a || framework_failure
+ln a x/b || framework_failure
+ln a c || framework_failure
 
 fail=0
 
index f4c343f..924c002 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ensure that mv removes a in this case: touch a; ln a b; mv a b
 
-# Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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,23 +21,9 @@ if test "$VERBOSE" = yes; then
   mv --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
-touch a || framework_failure=1
-ln a b || 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
+touch a || framework_failure
+ln a b || framework_failure
 
 fail=0
 
index aaa21a0..558cfac 100755 (executable)
@@ -2,7 +2,7 @@
 # move a directory containing hard-linked files and
 # make sure the links are preserved
 
-# Copyright (C) 1998, 1999, 2000, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 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,34 +22,16 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-# Make sure we get English translations.
 . $srcdir/../lang-default
-
-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 -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 dir=hlink
 
-framework_failure=0
-mkdir $dir || framework_failure=1
-> $dir/a || framework_failure=1
-ln $dir/a $dir/b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+mkdir $dir || framework_failure
+> $dir/a || framework_failure
+ln $dir/a $dir/b || framework_failure
 
 mv $dir $other_partition_tmpdir || fail=1
 
@@ -61,6 +43,4 @@ a=`sed -n 's/ a$//p' out`
 b=`sed -n 's/ b$//p' out`
 test "$a" = "$b" || fail=1
 
-rm -fr out $dir $other_partition_tmpdir
-
 exit $fail
index 0faa7df..13ca23f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ensure that mv's --verbose options works even in this unusual case
 
-# 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,25 +21,11 @@ if test "$VERBOSE" = yes; then
   mv --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
-
-touch x || framework_failure=1
-ln x y || 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
+ln x y || framework_failure
 
 fail=0
 
@@ -48,7 +34,6 @@ cat <<\EOF > exp || fail=1
 removed `x'
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 9dc1e0e..6c654c9 100755 (executable)
@@ -2,7 +2,7 @@
 # Test both cp and mv for their behavior with -if and -fi
 # The standards (POSIX and SuS) dictate annoyingly inconsistent behavior.
 
-# Copyright (C) 2000, 2001, 20062007 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 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,32 +23,18 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 
 # Make sure we get English translations.
 . $srcdir/../lang-default
 
 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
-
-pwd=`pwd`
-tmp=cp-mv-if-$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
 
 for i in a b c d e f g h; do
-  echo $i > $i || framework_failure=1
+  echo $i > $i || framework_failure
 done
-chmod 0 b d f h || framework_failure=1
-echo y > y || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+chmod 0 b d f h || framework_failure
+echo y > y || framework_failure
 
 fail=0
 mv -if a b || fail=1
@@ -65,11 +51,11 @@ esac
 
 test -f e || fail=1
 test -f f || fail=1
-cmp e f || fail=1
+compare e f || fail=1
 
 cp -fi g h < y > out 2>&1 || fail=1
 test -f g || fail=1
 test -f h || fail=1
-cmp g h || fail=1
+compare g h || fail=1
 
 exit $fail
index 3d60752..8a75de7 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure that `mv file unwritable-file' prompts the user
 # and that `mv -f file unwritable-file' doesn't.
 
-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 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,25 +22,12 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=mv-i.$$
-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
-touch f g h i || framework_failure=1
-chmod 0 g i || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+touch f g h i || framework_failure
+chmod 0 g i || framework_failure
 
 fail=0
 
index 2bd6816..288c428 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # make sure `mv -i a b' does its job with a positive response
 
-# Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 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,28 +21,13 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-
-pwd=`pwd`
-tmp=mv-i4-$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
+. $srcdir/../test-lib.sh
 
 for i in a b; do
-  echo $i > $i || framework_failure=1
+  echo $i > $i || framework_failure
 done
-echo y > y || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+echo y > y || framework_failure
 
 fail=0
 mv -i a b < y >/dev/null 2>&1 || fail=1
index 31d5ae7..e62d08c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure `mv -i dir file' prompts before failing.
 
-# 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,25 +21,11 @@ if test "$VERBOSE" = yes; then
   mv --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 a || framework_failure=1
-touch b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir a || framework_failure
+touch b || framework_failure
 
 fail=0
 
index 4232065..bb6fa44 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Show that mv doesn't preserve links to files the user has declined to move.
 
-# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 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,28 +21,15 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=i-link-no.$$
-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 a b || framework_failure=1
-echo foo > a/foo || framework_failure=1
-ln a/foo a/bar || framework_failure=1
-echo FUBAR > b/FUBAR || framework_failure=1
-ln b/FUBAR b/bar || framework_failure=1
-chmod a-w b/bar || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir a b || framework_failure
+echo foo > a/foo || framework_failure
+ln a/foo a/bar || framework_failure
+echo FUBAR > b/FUBAR || framework_failure
+ln b/FUBAR b/bar || framework_failure
+chmod a-w b/bar || framework_failure
 
 fail=0
 
@@ -54,11 +41,8 @@ cat <<EOF > exp_err
 mv: the --reply option is deprecated; use -i or -f instead
 EOF
 
-cmp err exp_err || fail=1
-test $fail = 1 && diff err exp_err 2> /dev/null
-
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare err exp_err || fail=1
+compare out exp || fail=1
 
 case "`cat b/foo`" in
   foo) ;;
index 46f26ce..7c2636e 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Demonstrate how mv fails when it tries to move a directory into itself.
 
-# Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 2002, 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,25 +21,18 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+
 dir=toself-dir
 file=toself-file
 
-test_failure=0
-
-rm -rf $dir $file || test_failure=1
-mkdir -p $dir/a/b || test_failure=1
-touch $file || test_failure=1
-
-if test $test_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+rm -rf $dir $file || framework_failure
+mkdir -p $dir/a/b || framework_failure
+touch $file || framework_failure
 
 fail=0
 
-# Make sure we get English translations.
-. $srcdir/../lang-default
-
 # This mv command should fail.
 mv $dir $file $dir > out 2>&1 && fail=1
 
@@ -53,7 +46,7 @@ cat > exp <<\EOF
 XXX: cannot move `SRC' to a subdirectory of itself, `DEST'
 EOF
 
-cmp out2 exp || fail=1
+compare out2 exp || fail=1
 
 # Make sure the file is gone.
 test -f $file && fail=1
@@ -62,6 +55,5 @@ test -d $dir || fail=1
 test -d $dir/$dir && fail=1
 # Make sure the file has been moved to the right place.
 test -f $dir/$file || fail=1
-rm -rf $dir $file out out2 exp
 
 exit $fail
index 961d470..3e92c64 100755 (executable)
@@ -3,7 +3,7 @@
 # Consider the case where SRC and DEST are on different
 # partitions and DEST is a symlink to SRC.
 
-# Copyright (C) 1998, 1999, 200 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 200, 007 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,33 +23,18 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-
-if test -z "$other_partition_tmpdir"; then
-  exit 77
-fi
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 file="$other_partition_tmpdir/file"
 symlink=symlink
 
 fail=0
 
-trap 'rm -fr out out2 exp $file $symlink $other_partition_tmpdir; exit $fail' \
-  0 1 2 3 15
-
-framework_failure=0
-rm -f $file $symlink || framework_failure=1
-echo whatever > $file || framework_failure=1
-ln -s $file $symlink || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
-# Make sure we get English translations.
-. $srcdir/../lang-default
+echo whatever > $file || framework_failure
+ln -s $file $symlink || framework_failure
 
 # This mv command should exit nonzero.
 mv $symlink $file > out 2>&1 && fail=1
@@ -68,7 +53,6 @@ XXX: `ZZZ' and `YYY' are the same file
 EOF
 #'
 
-cmp out2 exp || fail=1
-test $fail = 1 && diff out2 exp 2> /dev/null
+compare out2 exp || fail=1
 
 exit $fail
index d97a0fd..c8b31ff 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # move a directory into itself, with a twist
 
-# Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2000, 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,20 +21,13 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
+. $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+
 dir1=is3-dir1
 dir2=is3-dir2
 
-framework_failure=0
-rm -rf $dir1 $dir2 || framework_failure=1
-mkdir $dir1 $dir2 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
-# Make sure we get English translations.
-. $srcdir/../lang-default
+mkdir $dir1 $dir2 || framework_failure
 
 # This mv command should exit nonzero.
 mv $dir1 $dir2 $dir2 > out 2>&1 && fail=1
@@ -48,8 +41,6 @@ cat > exp <<\EOF
 XXX: cannot move `ZZZ' to a subdirectory of itself, `ZZZ/ZZZ'
 EOF
 
-cmp out2 exp || fail=1
-
-rm -fr out out2 exp $dir1 $dir2
+compare out2 exp || fail=1
 
 exit $fail
index 0bd8f93..c43418a 100755 (executable)
@@ -2,7 +2,7 @@
 # confirm that `mv symlink symlink' doesn't remove symlink
 # Based on an example from David Luyer.
 
-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 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,23 +22,10 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=mv-slink2.$$
-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
-touch file || framework_failure=1
-ln -s file s || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+touch file || framework_failure
+ln -s file s || framework_failure
 
 fail=0
 
index 394c6c9..515ad20 100755 (executable)
@@ -2,7 +2,7 @@
 # Exercise mv's file-descriptor-leak bug, reported against coreutils-5.2.1
 # and fixed (properly) on 2004-10-21.
 
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-# This test is relatively expensive, and might well evoke a
-# framework-failure on systems with a smaller command-line length
 # limit so don't run it by default.
-. $srcdir/../expensive
 
 if test "$VERBOSE" = yes; then
   set -x
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-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
-
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
-t0="$t0 $other_partition_tmpdir"
+# This test is relatively expensive, and might well evoke a
+# framework-failure on systems with a smaller command-line length
+. $srcdir/../expensive
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 b="0 1 2 3 4 5 6 7 8 9
 a b c d e f g h i j k l m n o p q r s t u v w x y z
@@ -56,16 +42,11 @@ for i in `echo $b`; do
     echo $i$j
   done
 done > .dirs
-mkdir `cat .dirs` || framework_failure=1
+mkdir `cat .dirs` || framework_failure
 sed 's,$,/f,' .dirs | xargs touch
 
 last_file=`tail -n1 .dirs`/f
-test -f $last_file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+test -f $last_file || framework_failure
 
 fail=0
 
@@ -73,7 +54,7 @@ mv * $other_partition_tmpdir || fail=1
 test -f $last_file/f && fail=1
 rm .dirs
 
-ls -A > ../out || fail=1
-test -s ../out && fail=1
+out=$(ls -A) || fail=1
+test -z "$out" || fail=1
 
 (exit $fail); exit $fail
index cef4195..4d70e59 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Test "mv" with special files.
 
-# Copyright (C) 1998, 1999, 2000, 2002, 2004, 2005, 2006 Free Software
+# Copyright (C) 1998, 1999, 2000, 2002, 2004-2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -22,41 +22,25 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-pwd=`pwd`
-tmp=mv-spec.$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $tmp $other_partition_tmpdir && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-# Make sure we get English translations.
 . $srcdir/../lang-default
-
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 null=mv-null
 dir=mv-dir
 
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-rm -f $null || framework_failure=1
-mknod $null p || framework_failure=1
-test -p $null || framework_failure=1
-mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure=1
-touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure=1
+rm -f $null || framework_failure
+mknod $null p || framework_failure
+test -p $null || framework_failure
+mkdir -p $dir/a/b/c $dir/d/e/f || framework_failure
+touch $dir/a/b/c/file1 $dir/d/e/f/file2 || framework_failure
 
-if test $framework_failure = 1; then
-  echo '********************************************'
-  echo 'NOTICE: unable to create test prerequisites'
-  echo '********************************************'
-  # exit 77 here to indicate that we couldn't run the test.
-  # At least running on SunOS 4.1.4, using a directory NFS mounted
-  # from an OpenBSD system, the above mknod fails.
-  (exit 77); exit 77
-fi
+# We used to...
+# exit 77 here to indicate that we couldn't run the test.
+# At least running on SunOS 4.1.4, using a directory NFS mounted
+# from an OpenBSD system, the above mknod fails.
+# It's not worth making an exception any more.
 
 fail=0
 mv --verbose $null $dir $other_partition_tmpdir > out || fail=1
@@ -87,7 +71,7 @@ cat <<EOF | sort > exp
 \`$dir/d/e/f/file2' -> \`XXX/$dir/d/e/f/file2'
 EOF
 
-cmp out2 exp || fail=1
+compare out2 exp || fail=1
 
 # cd $other_partition_tmpdir
 # ls -l -A -R $other_partition_tmpdir
index 84b30b4..7f3a926 100755 (executable)
@@ -2,7 +2,7 @@
 # ensure that --no-target-directory (-T) works when the destination is
 # an empty directory.
 
-# 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,24 +22,13 @@ if test "$VERBOSE" = yes; then
   mv --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
-mkdir -p d/sub empty src d2/sub e2 || framework_failure=1
-touch f || framework_failure=1
+mkdir -p d/sub empty src d2/sub e2 || framework_failure
+touch f || framework_failure
 
 # Skip this test if there's an underlying kernel bug.
-mkdir a b b/a || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir a b b/a || framework_failure
 
 mv a b || {
   echo "$0: skipping this test: your kernel's rename syscall is buggy" 1>&2
@@ -58,7 +47,6 @@ ls -d d > /dev/null 2>&1 && fail=1
 # Ensure that the dest dir now has a subdirectory.
 test -d empty/sub || fail=1
 
-
 # rename must fail, since the dest is non-empty.
 mv -fT src d2 2> /dev/null && fail=1
 
index 2be0018..1a43baf 100755 (executable)
@@ -4,7 +4,7 @@
 # This is a bit fragile since it relies on the string used
 # for EPERM: `permission denied'.
 
-# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -24,31 +24,14 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
+cleanup_() { t=$other_partition_tmpdir; chmod -R 700 "$t"; rm -rf "$t"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
-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
-
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
-t0="$t0 $other_partition_tmpdir"
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-touch k $other_partition_tmpdir/k || framework_failure=1
-chmod u-w $other_partition_tmpdir || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch k $other_partition_tmpdir/k || framework_failure
+chmod u-w $other_partition_tmpdir || framework_failure
 
 fail=0
 
index ff17e91..859cab0 100755 (executable)
@@ -4,7 +4,7 @@
 # For additional constraints, see the comment in copy.c.
 # Before coreutils-5.2.1, this test would fail.
 
-# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -24,32 +24,15 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
-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
-
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
-t0="$t0 $other_partition_tmpdir"
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-touch f || framework_failure=1
-ln f g || framework_failure=1
-mkdir a b || framework_failure=1
-touch a/1 || framework_failure=1
-ln a/1 b/1 || 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 f g || framework_failure
+mkdir a b || framework_failure
+touch a/1 || framework_failure
+ln a/1 b/1 || framework_failure
 
 fail=0
 
index b3fbfba..2c60359 100755 (executable)
@@ -3,7 +3,7 @@
 # another, and giving it a different name at the destination would cause mv
 # to get a failed assertion.
 
-# Copyright (C) 2000, 2002, 2004, 2006 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
@@ -23,28 +23,11 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
-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
-
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
-t0="$t0 $other_partition_tmpdir"
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir foo || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir foo || framework_failure
 
 fail=0
 
index 64d531d..1b58666 100755 (executable)
@@ -2,7 +2,7 @@
 # make sure cp and mv can handle many combinations of local and
 # other-partition regular/symlink'd files.
 
-# Copyright (C) 2000, 2003, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 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
@@ -23,35 +23,17 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-tmp=part-sl.$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $tmp $other_partition_tmpdir && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-pwd_tmp=$pwd/$tmp
-
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-# Make sure the programs use C-locale formats/translations.
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
+
+pwd_tmp=`pwd`
 
 # Unset CDPATH.  Otherwise, output from the `cd dir' command
 # can make this test fail.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
-if test -z "$other_partition_tmpdir"; then
-  (exit 77); exit 77
-fi
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
 fail=0
 
 # Four cases:
@@ -220,8 +202,7 @@ cat <<\EOF > $expected
 
 EOF
 
-# Some folks may don't have diff.
-cmp $expected $actual \
-  || { diff -c $expected $actual 1>&2; fail=1; }
+# Redirect to stderr, since stdout is already
+compare $expected $actual || fail=1
 
 (exit $fail); exit $fail
index 2cb84c5..7c78499 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure permissions are preserved when moving from one partition to another.
 
-# Copyright (C) 1999, 2000, 2001, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 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,11 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
-if test -z "$other_partition_tmpdir"; then
-  exit 77
-fi
-
-pwd=`pwd`
-dir=p-perm-$$
-trap 'cd "$pwd" && rm -rf $dir $other_partition_tmpdir' 0 1 2 3 15
-
-mkdir $dir
-
-cd $dir
 : > file
 chmod a=rwx file
 
index 792a914..af85919 100755 (executable)
@@ -2,7 +2,7 @@
 # ensure that mv gives one diagnostic, not two, when failing
 # due to lack of permissions
 
-# Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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,25 +22,12 @@ if test "$VERBOSE" = yes; then
   mv --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 -p no-write/dir || framework_failure=1
-chmod u-w no-write || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p no-write/dir || framework_failure
+chmod u-w no-write || framework_failure
 
 fail=0
 
@@ -49,7 +36,6 @@ cat <<\EOF > exp
 mv: cannot move `no-write/dir' to `./dir': Permission denied
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 37541c1..baa2f3e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that `mv --reply=no f1 f2' works.
 
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -22,21 +22,9 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $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
-touch a b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch a b || framework_failure
 
 fail=0
 
@@ -50,7 +38,6 @@ cat <<EOF > exp_err
 mv: the --reply option is deprecated; use -i or -f instead
 EOF
 
-cmp out exp_err || fail=1
-test $fail = 1 && diff out exp_err 2> /dev/null
+compare out exp_err || fail=1
 
 (exit $fail); exit $fail
index 04b7a8d..0b25ff9 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure that the copying code used in an inter-partition
 # move unlinks a destination symlink before opening it.
 
-# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 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,12 +22,9 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../other-fs-tmpdir
-. $srcdir/../envvar-check
-
-if test -z "$other_partition_tmpdir"; then
-  exit 77
-fi
+. $srcdir/../test-lib.sh
+cleanup_() { rm -rf "$other_partition_tmpdir"; }
+. "$abs_top_srcdir/tests/other-fs-tmpdir"
 
 rem_file="$other_partition_tmpdir/file"
 rem_symlink="$other_partition_tmpdir/symlink"
@@ -35,18 +32,10 @@ file=to-sym-$$
 
 fail=0
 
-trap 'rm -fr $file $other_partition_tmpdir; exit $fail' 0 1 2 3 15
-
-framework_failure=0
-rm -f $file || framework_failure=1
-echo local > $file || framework_failure=1
-echo remote > $rem_file || framework_failure=1
-ln -s $rem_file $rem_symlink || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+rm -f $file || framework_failure
+echo local > $file || framework_failure
+echo remote > $rem_file || framework_failure
+ln -s $rem_file $rem_symlink || framework_failure
 
 # This mv command should succeed, unlinking the symlink
 # before copying.
index 7d78a81..e20d180 100755 (executable)
@@ -4,7 +4,7 @@
 # Also, ensure that "mv dir non-exist-dir/" works.
 # Also, ensure that "cp dir non-exist-dir/" works.
 
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -24,22 +24,9 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-pwd=`pwd`
-tmp=mv-tslash.$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-. $srcdir/../envvar-check
-
-framework_failure=0
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir foo || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  exit 1
-fi
+mkdir foo || framework_failure
 
 fail=0
 
@@ -48,12 +35,8 @@ mv foo/ bar || fail=1
 # mv and cp would misbehave for coreutils versions [5.3.0..5.97], 6.0 and 6.1
 for cmd in mv 'cp -r'; do
   for opt in '' -T -u; do
-    rm -rf d e || framework_failure=1
-    mkdir d    || framework_failure=1
-    if test $framework_failure = 1; then
-      echo 'failure in testing framework'
-      (exit 1); exit 1
-    fi
+    rm -rf d e || framework_failure
+    mkdir d    || framework_failure
 
     $cmd $opt d e/ || fail=1
     if test "$cmd" = mv; then
index 1bd48da..15c922c 100755 (executable)
@@ -22,25 +22,12 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=mv-update.$$
-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
-echo old > old || framework_failure=1
-touch -d yesterday old || framework_failure=1
-echo new > new || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+echo old > old || framework_failure
+touch -d yesterday old || framework_failure
+echo new > new || framework_failure
 
 fail=0
 
index 30a91bc..baee6d5 100755 (executable)
@@ -4,7 +4,7 @@
 # of the current directory.  If one is found, create a temporary directory
 # inside it.
 
-# Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1998, 1999, 2001, 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
@@ -53,7 +53,7 @@ Set your environment variable CANDIDATE_TMP_DIRS to make
 this test use a different list.
 **************************************
 EOF
-    #'
+  (exit 77); exit 77
 fi
 
 test "$VERBOSE" = yes && set -x