]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Adjust chgrp, chmod, chown, cp tests to use test-lib.sh.
authorJim Meyering <jim@meyering.net>
Thu, 6 Sep 2007 15:34:49 +0000 (17:34 +0200)
committerJim Meyering <jim@meyering.net>
Sat, 15 Sep 2007 06:40:38 +0000 (08:40 +0200)
* tests/check.mk: Also define abs_top_builddir.

61 files changed:
tests/check.mk
tests/chgrp/Makefile.am
tests/chgrp/basic
tests/chgrp/default-no-deref
tests/chgrp/deref
tests/chgrp/no-x
tests/chgrp/posix-H
tests/chgrp/recurse
tests/chmod/Makefile.am
tests/chmod/c-option
tests/chmod/equal-x
tests/chmod/equals
tests/chmod/inaccessible
tests/chmod/no-x
tests/chmod/octal
tests/chmod/setgid
tests/chmod/thru-dangling
tests/chmod/umask-x
tests/chmod/usage
tests/chown/Makefile.am
tests/chown/basic
tests/chown/deref
tests/chown/preserve-root
tests/chown/separator
tests/cp/Makefile.am
tests/cp/acl
tests/cp/backup-1
tests/cp/backup-dir
tests/cp/backup-is-src
tests/cp/cp-HL
tests/cp/cp-a-selinux
tests/cp/cp-deref
tests/cp/cp-i
tests/cp/cp-mv-backup
tests/cp/cp-parents
tests/cp/deref-slink
tests/cp/dir-rm-dest
tests/cp/dir-slash
tests/cp/dir-vs-file
tests/cp/fail-perm
tests/cp/file-perm-race
tests/cp/into-self
tests/cp/link
tests/cp/link-no-deref
tests/cp/link-preserve
tests/cp/no-deref-link1
tests/cp/no-deref-link2
tests/cp/no-deref-link3
tests/cp/parent-perm-race
tests/cp/perm
tests/cp/preserve-2
tests/cp/proc-zero-len
tests/cp/r-vs-symlink
tests/cp/same-file
tests/cp/slink-2-slink
tests/cp/sparse
tests/cp/special-bits
tests/cp/src-base-dot
tests/cp/symlink-slash
tests/cp/thru-dangling
tests/test-lib.sh

index f5c08a259e52b693bcf9f8063f7826ce63bf9a4e..2b152df98d6a25bb47c8f22c6143c7759375b502 100644 (file)
@@ -13,6 +13,7 @@ FIXME_hook_this_to_make_distcheck:
 # Append this, because automake does the same.
 TESTS_ENVIRONMENT +=                   \
   abs_top_srcdir=$(abs_top_srcdir)     \
+  abs_top_builddir=$(abs_top_builddir) \
   srcdir=$(srcdir)
 
 TEST_LOGS = $(TESTS:=.log)
index 8dffd0157448f6e21fd28b74f5d914053a5a3184..8fc5f68760b77e7fed9a0cde75dd4f3709e7beda 100644 (file)
@@ -12,3 +12,5 @@ TESTS_ENVIRONMENT = \
   host_triplet=$(host_triplet) \
   CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
index e970cac5dcf7a794678831a379d47fd6960110a8..8a795d63b38183ba1c5a0cf8f20a4b5dd4f543a8 100755 (executable)
@@ -21,23 +21,9 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 . $srcdir/../group-names
-
-pwd=`pwd`
-tmp=basic.$$
-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 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
 
 fail=0
 
index 73137ff95c3b952be034c4a7b62068b3fa9c5842..e7239d52d34309d270bd22133c266725e76be74c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that chgrp -R does not dereference symlinks.
 
-# 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,23 +22,12 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../group-names
+. $srcdir/../test-lib.sh
+
 set _ $groups; shift
 g2=$2
 
-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 && touch f && ln -s ../f d/s || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir d && touch f && ln -s ../f d/s || framework_failure
 
 fail=0
 
index b40dd5a45cc0b6442900e40271daf27622b4074d..5dd61e1057b912cf93af289052b601727f02a89f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # see if chgrp can change the group of a symlink
 
-# Copyright (C) 2000, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 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
@@ -22,20 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../group-names
-
-pwd=`pwd`
-tmp=slink.$$
-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 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
 
 set _ $groups; shift
 g1=$1
index 58ac089c7f3e3540e1211b6ecb71bc597112554f..a98ba90eff5799f9b4576d72b2fc9d7ea3978ae0 100755 (executable)
@@ -22,29 +22,18 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $srcdir/../group-names
-set _ $groups; shift
-g1=$1
-g2=$2
-
 . $srcdir/../lang-default
+. $srcdir/../group-names
 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
+. $srcdir/../test-lib.sh
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir -p d/no-x/y || framework_failure=1
-chmod u=rw d/no-x || framework_failure=1
+set _ $groups; shift
+g1=$1
+g2=$2
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p d/no-x/y || framework_failure
+chmod u=rw d/no-x || framework_failure
 
 fail=0
 
@@ -67,7 +56,6 @@ cat <<EOF > exp
 $prog: \`d/no-x': 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 1e715dc080cc1f7c73c0f49a0a8471efb9ac070a..a9b41d0110d24dcff4fdd4adec06fe611be237df 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test POSIX-mandated -H option.
 
-# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003-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,29 +22,17 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../group-names
+. $srcdir/../test-lib.sh
+
 set _ $groups; shift
 g1=$1
 g2=$2
 
-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 1 2 3 || framework_failure=1
-touch 1/1F 2/2F 3/3F || framework_failure=1
-ln -s 1 1s || framework_failure=1
-ln -s ../3 2/2s || framework_failure=1
-chgrp -R $g1 1 2 3 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir 1 2 3 || framework_failure
+touch 1/1F 2/2F 3/3F || framework_failure
+ln -s 1 1s || framework_failure
+ln -s ../3 2/2s || framework_failure
+chgrp -R $g1 1 2 3 || framework_failure
 
 fail=0
 
index b06f1a001f5beb53cde2156648157ed7652ac7d9..a0cacd6454377dfd83f09f8016ca327cbc144de3 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ad-hoc tests of chgrp with -R and -H or -L and symlinks
 
-# Copyright (C) 2000, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2003-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,20 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../group-names
-
-pwd=`pwd`
-tmp=recurse.$$
-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 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
 
 set _ $groups; shift
 g1=$1
index 643015fef72b0d9354a74ac168c15af751cc9e00..8fb595a798e07430b065b864a766f65568fcb625 100644 (file)
@@ -15,3 +15,5 @@ EXTRA_DIST = $(TESTS)
 TESTS_ENVIRONMENT = \
   CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
index eaecc2adc57f0918e6d4a1dff74d4c4458520c80..e491b75b0376ca965ba24fb7db460bfd6eb5c01e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Verify that chmod's --changes (-c) option works.
 
-# 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
@@ -22,33 +22,14 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-
-pwd=`pwd`
-tmp=c-option.$$
-trap 'status=$?; cd "$pwd" && rm -rf $tmp && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-
-# Record absolute path of srcdir.
-cd $srcdir || framework_failure=1
-abs_srcdir=`pwd`
-
-cd "$pwd" || framework_failure=1
-mkdir $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
 
 umask 0
 file=f
-touch $file || framework_failure=1
-chmod 444 $file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+touch $file || framework_failure
+chmod 444 $file || framework_failure
 
-. "$abs_srcdir/../setgid-check"
+. "$abs_top_srcdir/tests/setgid-check"
 
 fail=0
 
index bcfb511cc24f89bb2b409637c0c259acd77ffcd1..5a1b85926fd47f77d0bbda20b5600c4251eba058 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test "chmod =x" and the like.
 
-# Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006 Free Software Foundation,
+# Copyright (C) 1999, 2000, 2002, 2004-2007 Free Software Foundation,
 # Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -22,22 +22,10 @@ if test "$VERBOSE" = yes; then
   chmod --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
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+. $srcdir/../test-lib.sh
 
 file=f
-touch $file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+touch $file || framework_failure
 
 fail=0
 umask 005
index 27bbcbce27b6827a57847fe8ca05f40db194019b..47a9c52d050224214b52218caee0557014be1321 100755 (executable)
@@ -3,8 +3,7 @@
 # Before fileutils-4.1.2, some of them didn't.
 # Also, before coreutils-5.3.1, =[ugo] sometimes didn't work.
 
-# Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 2001, 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
@@ -24,20 +23,9 @@ if test "$VERBOSE" = yes; then
   chmod --version
 fi
 
-pwd=`pwd`
-tmp=equals.$$
-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
-touch 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
 
 fail=0
 
index d6d8f5009ffca7c4f3ac8849070141107615646d..318d4bba5a82f51d3c348ce4b3ec416f16d51fa1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test for the bug fixed on 2006-09-20.
 
-# 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,22 +21,10 @@ if test "$VERBOSE" = yes; then
   chmod --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/e
-chmod 0 d/e d
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p d/e || framework_failure
+chmod 0 d/e d || framework_failure
 
 fail=0
 
index 34abba9ccb685fda1472806bf0c23cb32f1e7846..64dffb95bf4fb1c455628592ec229eff793ef7b1 100755 (executable)
@@ -24,22 +24,10 @@ fi
 
 . $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 d/no-x/y || framework_failure=1
-chmod u=rw d/no-x || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+mkdir -p d/no-x/y || framework_failure
+chmod u=rw d/no-x || framework_failure
 
 fail=0
 
@@ -62,8 +50,7 @@ cat <<EOF > exp
 $prog: \`d/no-x': Permission denied
 EOF
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 mkdir -p a/b
 cd a
index f29a53dd4744d10e49e2921984f15e109e660c76..781b904dc830c08bdb0e46fc852d9a5fa9bd5697 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ensure that chmod diagnoses a certain type of invalid mode string
 
-# 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
@@ -21,19 +21,7 @@ if test "$VERBOSE" = yes; then
   chmod --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
-
-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
 
index 92a026ff08097cd23011a3680c6225d72dcdf831..0c583f2745609615e20432bfe0aa9b289bf8b715 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure GNU chmod works the same way as those of Solaris, HPUX, AIX
 # wrt directories with the setgid bit set.
 
-# Copyright (C) 2001, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 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
@@ -22,23 +22,13 @@ if test "$VERBOSE" = yes; then
   chmod --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=setgid.$$
-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
-
-test=../../../src/test
+test=$abs_top_builddir/src/test
 
 umask 0
-mkdir d || framework_failure=1
+mkdir d || framework_failure
 
 chmod g+s d 2> /dev/null && $test -g d ||
   {
@@ -50,14 +40,9 @@ chmod g+s d 2> /dev/null && $test -g d ||
     id_g=`id -g` &&
     test -n "$id_g" &&
     chgrp "$id_g" d &&
-    chmod g+s d || framework_failure=1
+    chmod g+s d || framework_failure
   }
 
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
-
 # "chmod g+s d" does nothing on some NFS file systems.
 $test -g d || {
   echo 1>&2 "$0: cannot create setgid directories," \
index 7a82db83da45ff550f046bc060894fe30116a9d9..9423a74013a33ce0a503cef7566cf1412f4509c6 100755 (executable)
@@ -21,21 +21,9 @@ if test "$VERBOSE" = yes; then
   chmod --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 non-existent dangle || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+ln -s non-existent dangle || framework_failure
 
 fail=0
 
@@ -43,7 +31,6 @@ fail=0
 chmod 644 dangle 2> out && fail=1
 
 echo "chmod: cannot operate on dangling symlink \`dangle'" > exp
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 8d2be9353df39677ff449665015350f83dff146f..c7b139b88f299b3dc1fb1e9f655d919294735bb7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test that chmod -x file reports an error if the result is executable.
 
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2005, 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,30 +22,11 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-
-pwd=`pwd`
-tmp=minus.$$
-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
-
 touch file
 chmod 755 file
 (umask 77 && chmod -x file) 2>/dev/null && fail=1
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  fail=1
-fi
-
 (exit $fail); exit $fail
index 98944f54d83c39d42a32a4113c20959f9862c8f6..8e45edc69096198fbe60c3f90ab5295fb5bfcd71 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Verify that chmod works correctly with odd option combinations.
 
-# 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
@@ -22,20 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $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 $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
 
 fail=0
 
@@ -85,26 +72,21 @@ for case in $cases; do
 
   case $files in
   '')
-    touch -- $all_files || framework_failure=1
+    touch -- $all_files || framework_failure
     chmod $args 2>/dev/null && fail=1
     ;;
   ?*)
-    touch -- $files || framework_failure=1
+    touch -- $files || framework_failure
     chmod $args || fail=1
     for file in $files; do
       # Test for misparsing args by creating all $files but $file.
       # chmod has a bug if it succeeds even though $file is absent.
       rm -f -- $all_files && touch -- $files && rm -- $file \
-         || framework_failure=1
+         || framework_failure
       chmod $args 2>/dev/null && fail=1
     done
     ;;
   esac
 done
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  fail=1
-fi
-
 (exit $fail); exit $fail
index 61e65818f82f4357a1847952ff552257f7537785..e0017c1be548d23762314469fb126933cfdb9d8e 100644 (file)
@@ -8,3 +8,5 @@ EXTRA_DIST = $(TESTS)
 TESTS_ENVIRONMENT = \
   CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
index 668e39d68a29ba37cd4d001de6202b08cc8f0615..a4276b8dec950c59b982cab01efb90db49e331bc 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # make sure chown --from=... works
 
-# Copyright (C) 2001, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2001, 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,24 +21,11 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-tmp=basic.$$
-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 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+touch f || framework_failure
 
 fail=0
 chown -R --preserve-root 0:1 f
index 9da2013259812e1ddc77226935b88ae797bccd53..74684fe6a689dc3a8fed82b3aafc1c9b92507e85 100755 (executable)
@@ -2,7 +2,7 @@
 # For coreutils-5.2.1 and earlier, chown --dereference would skip
 # symlinks having owner/group matching the specified owner/group.
 
-# 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
@@ -22,23 +22,10 @@ if test "$VERBOSE" = yes; then
   chown --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
-ln -s no-such dangle || 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 dangle || framework_failure
 
 fail=0
 
@@ -52,7 +39,6 @@ cat <<\EOF > exp || fail=1
 chown: cannot dereference `dangle'
 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 6889fa57941bf66110535b9f7742c0426ee9a845..de45cbc167f54b98e8ebf368fe103d69b685291f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Verify that --preserve-root works.
 
-# 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,12 @@ if test "$VERBOSE" = yes; then
   chown --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 && ln -s / d/slink-to-root
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
-
 fail=0
 
 # Even if --preserve-root were to malfunction, allowing the chown or
@@ -80,7 +67,6 @@ chgrp: it is dangerous to operate recursively on `d/slink-to-root' (same as `/')
 chgrp: use --no-preserve-root to override this failsafe
 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 991589735f1ba516d269c5d83a9ad6dfcc63f15a..de33831a9532c328244853d2307b974fb7026a37 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure "chown USER:GROUP FILE" works, and similar tests with separators.
 
-# 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
@@ -21,32 +21,19 @@ if test "$VERBOSE" = yes; then
   chown --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 'status=$?; (exit $status); exit $status' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-framework_failure=0
+id_u=`id -u` || framework_failure
+test -n "$id_u" || framework_failure
 
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+id_un=`id -un` || framework_failure
+test -n "$id_un" || framework_failure
 
-id_u=`id -u` || framework_failure=1
-test -n "$id_u" || framework_failure=1
+id_g=`id -g` || framework_failure
+test -n "$id_g" || framework_failure
 
-id_un=`id -un` || framework_failure=1
-test -n "$id_un" || framework_failure=1
-
-id_g=`id -g` || framework_failure=1
-test -n "$id_g" || framework_failure=1
-
-id_gn=`id -gn` || framework_failure=1
-test -n "$id_gn" || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 77); exit 77
-fi
+id_gn=`id -gn` || framework_failure
+test -n "$id_gn" || framework_failure
 
 fail=0
 
index ecb71817469091b32fec4324357a9590c078a5f0..074f5f6f642728016624bbea2bdc723d01433f51 100644 (file)
@@ -34,7 +34,8 @@ TESTS = \
 EXTRA_DIST = $(TESTS) trailing-slash
 TESTS_ENVIRONMENT =                    \
   MAKE=$(MAKE)                         \
-  abs_top_builddir=$(abs_top_builddir) \
   CONFIG_HEADER=$(CONFIG_HEADER)       \
   CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
   PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
+
+include $(top_srcdir)/tests/check.mk
index f1ca4a8d63bb40f646ef78985263adf73b16ec91..d28537890acc2dc5334a1f1d5033dea3b3acb127 100755 (executable)
@@ -2,7 +2,7 @@
 # copy files/directories across file system boundaries
 # and make sure acls are preserved appropriately
 
-# 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
@@ -35,22 +35,10 @@ if test "$VERBOSE" = yes; then
   setfacl --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 a b || framework_failure=1
-touch a/file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  (exit 1); exit 1
-fi
+mkdir -p a b || framework_failure
+touch a/file || framework_failure
 
 skip=no
 # Ensure that setfacl and getfacl work on this file system.
@@ -68,21 +56,16 @@ test $skip = yes &&
 # copy a file without preserving permissions
 cp a/file b/ || fail=1
 
-acl2=`cd b && getfacl file` || framework_failure=1
+acl2=`cd b && getfacl file` || framework_failure
 test "$acl1" = "$acl2" || fail=1
-rm a/file || framework_failure=1
+rm a/file || framework_failure
 
 # copy a file, preserving permissions
-touch a/file || framework_failure=1
-setfacl -m user:bin:rw a/file || framework_failure=1
-acl1=`cd a && getfacl file` || framework_failure=1
+touch a/file || framework_failure
+setfacl -m user:bin:rw a/file || framework_failure
+acl1=`cd a && getfacl file` || framework_failure
 cp -p a/file b/ || fail=1
-acl2=`cd b && getfacl file` || framework_failure=1
+acl2=`cd b && getfacl file` || 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 e66ebf06a282bdee423462caf0a2458dcbf91ded..882167931bf700ff0b1127f4e1ac076524735aac 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test cp backup.
 
-# Copyright (C) 1997, 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999, 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,19 +21,7 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 suffix=.b
 file=b1.$$
@@ -51,6 +39,6 @@ cp --force --backup=simple --suffix=$suffix $file $file \
 
 test -f $file || fail=1
 test -f $file_backup || fail=1
-cmp $file $file_backup > /dev/null || fail=1
+compare $file $file_backup > /dev/null || fail=1
 
 (exit $fail); exit $fail
index 60acbeb0900e9003bd3061b6ebe3fdbb0da5c44b..879c5164e9ce8adbe3dd3ad61c51f7327ac8f4bd 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that cp -b doesn't back up directories.
 
-# 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,22 +21,9 @@ if test "$VERBOSE" = yes; then
   cp --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
-mkdir 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 x y || framework_failure
 
 fail=0
 
index e0ae0ec0e99816f7215ca2a1b85d03fe21aa5bbd..7721be9c5a4f2a5a9c1997a533511760ddc4b69e 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
 # Test cp backup to source file.
 
-# Copyright (C) 1998, 1999, 2000, 2002, 2004, 2006 Free Software Foundation,
-# Inc.
+# Copyright (C) 1998-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,24 +22,10 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
-
-echo a > a || framework_failure=1
-echo a-tilde > a~ || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+echo a > a || framework_failure
+echo a-tilde > a~ || framework_failure
 
 # This cp command should exit nonzero.
 cp --b=simple a~ a > out 2>&1 && fail=1
@@ -51,6 +36,6 @@ cat > exp <<\EOF
 XXX: backing up `a' would destroy source;  `a~' not copied
 EOF
 
-cmp out2 exp || fail=1
+compare out2 exp || fail=1
 
 (exit $fail); exit $fail
index dd9f28b79b1002c4ec14c46e6dbaa8a78e50b59c..6040cc94cee4b4f253ba41ceffba4eb54be49f1c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # test cp's -H and -L options
 
-# 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
@@ -21,26 +21,12 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir src-dir dest-dir || framework_failure=1
-echo f > f || framework_failure=1
-ln -s f slink || framework_failure=1
-ln -s no-such-file src-dir/slink || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir src-dir dest-dir || framework_failure
+echo f > f || framework_failure
+ln -s f slink || framework_failure
+ln -s no-such-file src-dir/slink || framework_failure
 
 fail=0
 
index 56b9dffdfc959ba1d76676749b722d5602c3e47c..8cb5a456cfe9624e8d1ff081d35b2dbb6f6e10a3 100755 (executable)
@@ -22,36 +22,25 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
 . $srcdir/../selinux
 PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd"; umount $tmp/mnt; 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
+cwd=`pwd`
+cleanup_() { cd /; umount "$cwd/mnt"; }
 
 # Create a file system, then mount it with the context=... option.
 dd if=/dev/zero of=blob bs=8192 count=200 > /dev/null 2>&1 \
-                                             || framework_failure=1
-mkdir mnt                                    || framework_failure=1
-mkfs -t ext2 -F blob > /dev/null 2>&1        || framework_failure=1
+                                             || framework_failure
+mkdir mnt                                    || framework_failure
+mkfs -t ext2 -F blob > /dev/null 2>&1        || framework_failure
 mount -oloop,context=system_u:object_r:removable_t blob mnt \
-                                             || framework_failure=1
-cd mnt                                       || framework_failure=1
-
-echo > f                                     || framework_failure=1
-echo > g                                     || framework_failure=1
+                                             || framework_failure
+cd mnt                                       || framework_failure
 
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+echo > f                                     || framework_failure
+echo > g                                     || framework_failure
 
 fail=0
 
@@ -86,7 +75,6 @@ cat <<\EOF > exp || fail=1
 cp: failed to set the security context of
 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 d167e6346a543be256d0be0a1f2ff1137e926c72..a666f5d6d65d6b527a74ffbc1d1e9e2b1d5815ac 100755 (executable)
@@ -2,7 +2,7 @@
 # cp -RL dir1 dir2' must handle the case in which each of dir1 and dir2
 # contain a symlink pointing to some third 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,22 +22,11 @@ if test "$VERBOSE" = yes; then
   cp --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
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-mkdir a b c d || framework_failure=1
-ln -s ../c a || framework_failure=1
-ln -s ../c 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
+
+mkdir a b c d || framework_failure
+ln -s ../c a || framework_failure
+ln -s ../c b || framework_failure
 
 fail=0
 
index d7485e2715d6828aea2acbfb4d4c8c81724a899b..e7cd438aa3ff91fa0d6170f518db2b01ad032c86 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test whether cp -i prompts in the right place.
 
-# 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
   cp --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 b/a/c || framework_failure=1
-touch 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 -p a b/a/c || framework_failure
+touch a/c || framework_failure
 
 fail=0
 
index ab77adacaa33fbdd1f14355ce930ff9d65123986..9a464a16d3a5f0c248135aa8f1803b6b66aecb3c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test basic --backup functionality for both cp and mv.
 
-# Copyright (C) 1999, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1999, 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
@@ -24,7 +24,7 @@ fi
 # Ensure that ls sorts the same way for everyone.
 . $srcdir/../lang-default
 
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
 umask 022
 
@@ -32,20 +32,6 @@ umask 022
 # Use `1>&2' rather than `1<&-' since the latter appears not to work
 # with /bin/sh from powerpc-ibm-aix4.2.0.0.
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; 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
-
 actual=actual
 expected=expected
 
@@ -107,9 +93,6 @@ EOF
 
 sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected
 
-cmp $expected $actual || fail=1
-
-# Uncomment this if you see a failure and want to try to diagnose it.
-test $fail = 1 && diff -c $expected $actual 1>&2
+compare $expected $actual || fail=1
 
 (exit $fail); exit $fail
index 76c63be521db2a9fc17eb35171c0367fe402fd65..4500e5f48379188e62a7fa46b16b6fc7acaa015e 100755 (executable)
@@ -2,7 +2,7 @@
 # cp -R --parents dir-specified-with-trailing-slash/ other-dir
 # would get a failed assertion.
 
-# Copyright (C) 2000, 2002, 2004, 2005, 20062007 Free Software
+# Copyright (C) 2000, 2002, 2004, 2005, 2006-2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -23,37 +23,16 @@ if test "$VERBOSE" = yes; then
   mv --version
 fi
 
-umask 022
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $t0 && exit $status' 0
-trap '(exit $?); exit' 1 2 13 15
-
-framework_failure=0
-
-# Record absolute path of srcdir and cd back to current dir.
-cd $srcdir || framework_failure=1
-abs_srcdir=`pwd`
-cd "$pwd" || framework_failure=1
-
-. $srcdir/../envvar-check
 . $srcdir/../umask-check
+. $srcdir/../test-lib.sh
 
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
+# Run the setgid check from the just-created directory.
+. "$abs_top_srcdir/tests/setgid-check"
 
-. "$abs_srcdir/../setgid-check"
-
-mkdir foo bar || framework_failure=1
-mkdir -p a/b/c d e g || framework_failure=1
-ln -s d/a sym || framework_failure=1
-touch f || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir foo bar || framework_failure
+mkdir -p a/b/c d e g || framework_failure
+ln -s d/a sym || framework_failure
+touch f || framework_failure
 
 fail=0
 
index 0facd134c507db35b0e529af8f518f8d6c53f4a2..d677d416184063c49b43456b360bdd3181f5107a 100755 (executable)
@@ -2,7 +2,7 @@
 # Demonstrate bug when using -d with an existing destination file
 # that is a symlink.
 
-# 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
@@ -22,24 +22,11 @@ if test "$VERBOSE" = yes; then
   cp --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" && 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 slink-target || framework_failure=1
-ln -s slink-target slink || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+touch f slink-target || framework_failure
+ln -s slink-target slink || framework_failure
 
 fail=0
 cp -d f slink || fail=1
index f531e63c75684e660e1a9033bdfeaa4c9e3c9e09..45212c748181fcd5f9a26a5a655f096918418a3f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # verify that cp's --remove-destination option works with -R
 
-# 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
@@ -21,23 +21,11 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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 d e || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir d e || framework_failure
 
 fail=0
-
 # Do it once with no destination...
 cp -R --remove-destination d e || fail=1
 
index 31bfcb317789719e7f6aae1c4a4402b21da594d2..6a6a613a3fa23e4075dcfd33f47150f76ee2408f 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure that cp -R DIR1 DIR2 does the right thing
 # when DIR1 is written with a trailing slash.
 
-# 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
@@ -22,22 +22,10 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 || exit $?; exit $status' 0
-trap 'exit $?' 1 2 13 15
+. $srcdir/../test-lib.sh
 
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp || framework_failure=1
-
-mkdir dir1 dir2 || framework_failure=1
-touch dir1/file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir dir1 dir2 || framework_failure
+touch dir1/file || framework_failure
 
 fail=0
 cp -R dir1/ dir2 || fail=1
index d14dda2c61f62e1020eedf99da335af8d0927ec5..58cdf5eabdcbed5fdf19d89f990f200d236d3e9d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # A directory may not replace an existing file.
 
-# 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,24 +21,10 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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 dir || framework_failure=1
-touch file || 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
+touch file || framework_failure
 
 fail=0
 
index 31b4cb3ad053d2924ef9a1cb86e7636ffd6317aa..0ed9166f49530b6917791df610472b71a57f07ca 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 Free Software
+# Copyright (C) 2000, 2002-2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -23,25 +23,12 @@ fi
 
 . $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 D/D || framework_failure=1
-touch D/a || framework_failure=1
-chmod 0 D/a || framework_failure=1
-chmod u=rx,go=,-st D || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+mkdir D D/D || framework_failure
+touch D/a || framework_failure
+chmod 0 D/a || framework_failure
+chmod u=rx,go=,-st D || framework_failure
 
 fail=0
 
@@ -66,11 +53,11 @@ cp F symlink 2> out && fail=1
 #   ...: The file access permissions do not allow the specified action.
 # to the expected one:
 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
-cmp out exp || { (diff -c out exp) 2> /dev/null; fail=1; }
+compare out exp || fail=1
 
 cp --target-directory=symlink F 2> out && fail=1
 sed 's/: The file access permissions.*/: Permission denied/'<out>o1;mv o1 out
-cmp out exp || { (diff -c out exp) 2> /dev/null; fail=1; }
+compare out exp || fail=1
 
 chmod 700 D
 
index f211e26ef7f227a4a9592a058d6b7d72a6deb361..94e402dbcef0304fa626b23f84b945c400a0d2f1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure cp -p isn't too generous with file permissions.
 
-# 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,14 +21,7 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 umask 022
 mkfifo fifo || {
index d2dc0b8d7a8ec30fcd18ec4e2790201a1286dc9c..7afe2a5bc53f7ec924f13ad1e65f5d8111f45fd7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Confirm that copying a directory into itself gets a proper diagnostic.
 
-# 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
@@ -26,24 +26,10 @@ if test "$VERBOSE" = yes; then
   cp --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" && 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 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
 
@@ -55,7 +41,6 @@ cp: cannot copy a directory, `dir', into itself, `dir/dir'
 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 96967b0160a99123f382820d179829d63443a812..26fabfda7c406107e022815c07972d673d7da683 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure cp --link -f works when the target exists.
 # This failed for 4.0z (due to a bug introduced in that test release).
 
-# 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
@@ -22,23 +22,11 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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 src || framework_failure=1
-touch dest || framework_failure=1
-touch dest2 || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+touch src || framework_failure
+touch dest || framework_failure
+touch dest2 || framework_failure
 
 fail=0
 
index 536015250edee2048d7ad90ad30831c0153bb94b..2e955a55902d6f2fd5712cce62a182c7ba4ab48e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that cp --link --no-dereference works properly
 
-# 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,9 @@ if test "$VERBOSE" = yes; then
   cp --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 dangling-slink || 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 dangling-slink || framework_failure
 
 fail=0
 
index 42998c1546fa6656e0b757a694f36764930bfe5b..137bb901eb7f82fd936d24963d7827a0cc7f8975 100755 (executable)
@@ -2,7 +2,7 @@
 # ensure that `cp -d' preserves hard-links between command line arguments
 # ensure that --preserve=links works with -RH and -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
@@ -22,28 +22,15 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../lang-default
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
-mkdir c || framework_failure=1
-cp -d a b c || framework_failure=1
-test -f c/a || framework_failure=1
-test -f c/b || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework' 1>&2
-  (exit 1); exit 1
-fi
+. $srcdir/../test-lib.sh
+
+touch a || framework_failure
+ln a b || framework_failure
+mkdir c || framework_failure
+cp -d a b c || framework_failure
+test -f c/a || framework_failure
+test -f c/b || framework_failure
 
 fail=0
 
index d32fd5d08a20c99ae2dd823cd7f6f22e729511f7..a194303c9e0220fc58a1d0bf21d99a9f072f9099 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
-# FIXME: This test requires ln -s.
 # cp from 3.16 fails this test
 
-# Copyright (C) 1997, 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999, 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,19 +21,7 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 mkdir a b
 msg=bar
index 47226eba180d9b187d2b089f7ec6dd9740c98886..e3ad0aab25cf80c98dd7196e80dded63bf59ee2e 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
-# FIXME: This test requires ln -s.
 # cp from 3.16 fails this test
 
-# Copyright (C) 1997, 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999, 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,19 +21,7 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 mkdir b
 msg=bar
index 28cae539d97ae51413118964eb634dff59d463f9..13841adb085da53429dbcdf6da02e4ba620d6bce 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/sh
-# FIXME: This test requires ln -s.
 # cp from 3.16 fails this test
 
-# Copyright (C) 1997, 1999, 2002, 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999, 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,19 +21,7 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 msg=bar
 echo $msg > a
index d393dd8f58fc4c10f721f67b9436da9907653d1e..b09f8bcedd2ba08ee04af31aa928702ecb613c2b 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure cp -pR --parents isn't too generous with parent permissions.
 
-# Copyright (C) 20062007 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,17 +21,10 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
 
 umask 002
-mkdir mode ownership d || framework_failure=1
+mkdir mode ownership d || framework_failure
 chmod g+s d 2>/dev/null # The cp test is valid either way.
 
 fail=0
index afaea803c7ecfea54e0c99ac11e126b1fb418e73..88052aa023d91630f4f4f3510093fcfad289942f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Make sure the permission-preserving code in copy.c (mv, cp, install) works.
 
-# Copyright (C) 2000, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 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
@@ -24,24 +24,10 @@ 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" && 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
 
 umask 037
 
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
-
 fail=0
 
 # Now, try it with `mv', with combinations of --force, no-f and
index e80209ffc9ab89e82183b54362db989d42206725..36a561cdea0308fb62d922caaa67770692fbaafe 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # ensure that cp's --preserve=X,Y option is parsed properly
 
-# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 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,9 @@ if test "$VERBOSE" = yes; then
   cp --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
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch f || framework_failure
 
 fail=0
 
index cd6f94c8343ecae546a3f38ad4af4df12312f302..8330bfd28d9f65a1715014668e838389a3f4d555 100755 (executable)
@@ -21,22 +21,9 @@ if test "$VERBOSE" = yes; then
   cp --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
-touch empty || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+touch empty || framework_failure
 
 f=/proc/cpuinfo
 test -r $f || f=empty
@@ -53,7 +40,6 @@ cp $f exp || fail=1
 test -s out && { rm -f out; echo nonempty > out; }
 test -s exp && { rm -f exp; echo nonempty > exp; }
 
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
 
 (exit $fail); exit $fail
index 8459638772aecaf1dbad568280358c0ebaa5eff6..579c49576f8224dd96a02d85abe288ed4fc794bc 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # cp -r should not create symlinks.  Fixed in fileutils-4.1.5.
 
-# 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,24 +25,11 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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
-echo abc > foo || framework_failure=1
-ln -s foo slink || framework_failure=1
-ln -s no-such-file no-file || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+echo abc > foo || framework_failure
+ln -s foo slink || framework_failure
+ln -s no-such-file no-file || framework_failure
 
 fail=0
 
index 9e4d0cca5031babe90f0982e120725f0ee772b17..7bf6da85388f74eb7c3092c175f0387b6c9c5d3c 100755 (executable)
@@ -2,7 +2,7 @@
 # Test some of cp's options and how cp handles situations in
 # which a naive implementation might overwrite the source file.
 
-# Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006 Free Software
+# Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2006-2007 Free Software
 # Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -24,7 +24,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/../lang-default
-. $srcdir/../envvar-check
+. $srcdir/../test-lib.sh
 
 # Unset CDPATH.  Otherwise, output from the `cd dir' command
 # can make this test fail.
@@ -32,20 +32,6 @@ fi
 
 VERSION_CONTROL=numbered; export VERSION_CONTROL
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && exec 1>&2; rm -rf $t0 && exit $status' 0
-trap '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 'failure in testing framework'
-  exit 1
-fi
-
 actual=actual-$$
 expected=expected-$$
 
@@ -210,8 +196,6 @@ EOF
 
 fail=0;
 
-# Some folks don't have diff.
-cmp $expected $actual \
-  || { diff -c $expected $actual 1>&2; fail=1; }
+compare $expected $actual || fail=1
 
 (exit $fail); exit $fail
index 60b93ba51245c24efe3409b60257590bddd92c1e..f6cc6e987a5a48aa9f6748a035702a47c87320ea 100755 (executable)
@@ -2,7 +2,7 @@
 # `test cp --update A B' where A and B are both symlinks that point
 # to the same file
 
-# 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
@@ -22,30 +22,14 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
-
-# Make sure we get English translations.
 . $srcdir/../lang-default
+. $srcdir/../test-lib.sh
 
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
-trap 'exit $?' 1 2 13 15
-
-framework_failure=0
-mkdir -p $tmp || framework_failure=1
-cd $tmp
-
-touch file || framework_failure=1
-ln -s file a || framework_failure=1
-ln -s file b || framework_failure=1
-ln -s no-such-file c || framework_failure=1
-ln -s no-such-file d || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+touch file || framework_failure
+ln -s file a || framework_failure
+ln -s file b || framework_failure
+ln -s no-such-file c || framework_failure
+ln -s no-such-file d || framework_failure
 
 fail=0
 cp --update --no-dereference a b || fail=1
index 32d46f55af488e5d26bc51c6f73dcd1c2c9d94f7..3238aa9cfb2f9330bcb9fe4cfddee18e67338238 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test cp --sparse=always
 
-# 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,29 +21,15 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $srcdir/../envvar-check
 . $srcdir/../sparse-file
-
-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
 
 # Create a sparse file.
 # It has to be at least 128K in order to be sparse on some systems.
 # Make its size one larger than 128K, in order to tickle the
 # bug in coreutils-6.0.
 size=`expr 128 \* 1024 + 1`
-dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo "$0: failure in testing framework" 1>&2
-  (exit 1); exit 1
-fi
+dd bs=1 seek=$size of=sparse < /dev/null 2> /dev/null || framework_failure
 
 fail=0
 
index 6c99409e6859e23860b022af64b73e66a8ce908c..cce069cd4af8e55c88f1e8cc5bf150fd7c43b61c 100755 (executable)
@@ -2,7 +2,7 @@
 # make sure `cp -p' preserves special bits
 # This works only when run as root.
 
-# Copyright (C) 2000, 2001, 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
@@ -26,27 +26,14 @@ if test "$VERBOSE" = yes; then
 fi
 
 PRIV_CHECK_ARG=require-root . $srcdir/../priv-check
-
-pwd=`pwd`
-t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
-trap 'status=$?; cd "$pwd" && 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 c || framework_failure=1
-chmod u+sx,go= a || framework_failure=1
-chmod u=rwx,g=sx,o= b || framework_failure=1
-chmod a=r,ug+sx c || framework_failure=1
-chown $NON_ROOT_USERNAME . || framework_failure=1
-chmod u=rwx,g=rx,o=rx . || framework_failure=1
-
-if test $framework_failure = 1; then
-  echo 'failure in testing framework'
-  exit 1
-fi
+. $srcdir/../test-lib.sh
+
+touch a b c || framework_failure
+chmod u+sx,go= a || framework_failure
+chmod u=rwx,g=sx,o= b || framework_failure
+chmod a=r,ug+sx c || framework_failure
+chown $NON_ROOT_USERNAME . || framework_failure
+chmod u=rwx,g=rx,o=rx . || framework_failure
 
 fail=0
 
index 9cc03b1cc79eec1148e1eac9df240514a52e1876..274a66429a7ca421eca5c89644870971f2e3a76d 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Ensure that "mkdir x y; cd y; cp -ab ../x/. ." is a successful, silent, no-op.
 
-# 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,23 +21,9 @@ if test "$VERBOSE" = yes; then
   cp --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
-
-mkdir 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 x y || framework_failure
 
 fail=0
 
@@ -46,7 +32,6 @@ cp --verbose -ab ../x/. . > out 2>&1 || fail=1
 cat <<\EOF > exp || fail=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 9b582e240e4d25e95b632b480328d91e8c09deaa..3c13fe95dc4c665cae0413d99a334b43d35b8dd6 100755 (executable)
@@ -2,7 +2,7 @@
 # Make sure that cp -dR dereferences a symlink arg if its name is
 # written with a trailing slash.
 
-# 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
@@ -22,25 +22,11 @@ if test "$VERBOSE" = yes; then
   cp --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" && 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 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
 cp -dR symlink/ s || fail=1
index 5a477957db4f806103d2e931cf24c7f01b2eed8c..0503af943bf3f8db93bc50ebc789f9d8c85bf79f 100755 (executable)
@@ -21,32 +21,17 @@ if test "$VERBOSE" = yes; then
   cp --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
-
-ln -s no-such dangle || framework_failure=1
-echo hi > f || framework_failure=1
-echo hi > exp || 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 dangle || framework_failure
+echo hi > f || framework_failure
+echo hi > exp || framework_failure
 
 fail=0
 
 cp f dangle > out 2>&1 || fail=1
 cat no-such >> 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
index 79d0ef2c74587fdfca14e2c762e5c3e4eff5abf2..10571a1e61c32f26010e669529d5c96b9d7bf499 100644 (file)
@@ -8,6 +8,12 @@ if test $? != 11; then
   (exit 77); exit 77
 fi
 
+framework_failure()
+{
+  echo "$0: failure in testing framework" 1>&2
+  (exit 1); exit 1
+}
+
 test_dir_=$(pwd)
 
 this_test_() { echo "./$0" | sed 's,.*/,,'; }