summaryrefslogtreecommitdiff
path: root/tests/cp
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-09-06 17:34:49 +0200
committerJim Meyering <jim@meyering.net>2007-09-15 08:40:38 +0200
commitdf0beae1eb1318869d51a064aec8fdd401877cbf (patch)
tree94f2224056162eadbb3d6b640e32f56d3f405cbf /tests/cp
parentc840cd4334c086f5ce4d9144d9fac75643824a38 (diff)
downloadcoreutils-df0beae1eb1318869d51a064aec8fdd401877cbf.tar.xz
Adjust chgrp, chmod, chown, cp tests to use test-lib.sh.
* tests/check.mk: Also define abs_top_builddir.
Diffstat (limited to 'tests/cp')
-rw-r--r--tests/cp/Makefile.am3
-rwxr-xr-xtests/cp/acl37
-rwxr-xr-xtests/cp/backup-118
-rwxr-xr-xtests/cp/backup-dir19
-rwxr-xr-xtests/cp/backup-is-src25
-rwxr-xr-xtests/cp/cp-HL26
-rwxr-xr-xtests/cp/cp-a-selinux34
-rwxr-xr-xtests/cp/cp-deref23
-rwxr-xr-xtests/cp/cp-i22
-rwxr-xr-xtests/cp/cp-mv-backup23
-rwxr-xr-xtests/cp/cp-parents37
-rwxr-xr-xtests/cp/deref-slink21
-rwxr-xr-xtests/cp/dir-rm-dest18
-rwxr-xr-xtests/cp/dir-slash20
-rwxr-xr-xtests/cp/dir-vs-file22
-rwxr-xr-xtests/cp/fail-perm29
-rwxr-xr-xtests/cp/file-perm-race11
-rwxr-xr-xtests/cp/into-self23
-rwxr-xr-xtests/cp/link22
-rwxr-xr-xtests/cp/link-no-deref18
-rwxr-xr-xtests/cp/link-preserve31
-rwxr-xr-xtests/cp/no-deref-link117
-rwxr-xr-xtests/cp/no-deref-link217
-rwxr-xr-xtests/cp/no-deref-link317
-rwxr-xr-xtests/cp/parent-perm-race13
-rwxr-xr-xtests/cp/perm18
-rwxr-xr-xtests/cp/preserve-217
-rwxr-xr-xtests/cp/proc-zero-len20
-rwxr-xr-xtests/cp/r-vs-symlink23
-rwxr-xr-xtests/cp/same-file22
-rwxr-xr-xtests/cp/slink-2-slink30
-rwxr-xr-xtests/cp/sparse20
-rwxr-xr-xtests/cp/special-bits31
-rwxr-xr-xtests/cp/src-base-dot23
-rwxr-xr-xtests/cp/symlink-slash22
-rwxr-xr-xtests/cp/thru-dangling25
36 files changed, 164 insertions, 633 deletions
diff --git a/tests/cp/Makefile.am b/tests/cp/Makefile.am
index ecb718174..074f5f6f6 100644
--- a/tests/cp/Makefile.am
+++ b/tests/cp/Makefile.am
@@ -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
diff --git a/tests/cp/acl b/tests/cp/acl
index f1ca4a8d6..d28537890 100755
--- a/tests/cp/acl
+++ b/tests/cp/acl
@@ -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
diff --git a/tests/cp/backup-1 b/tests/cp/backup-1
index e66ebf06a..882167931 100755
--- a/tests/cp/backup-1
+++ b/tests/cp/backup-1
@@ -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
diff --git a/tests/cp/backup-dir b/tests/cp/backup-dir
index 60acbeb09..879c5164e 100755
--- a/tests/cp/backup-dir
+++ b/tests/cp/backup-dir
@@ -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
diff --git a/tests/cp/backup-is-src b/tests/cp/backup-is-src
index e0ae0ec0e..7721be9c5 100755
--- a/tests/cp/backup-is-src
+++ b/tests/cp/backup-is-src
@@ -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
diff --git a/tests/cp/cp-HL b/tests/cp/cp-HL
index dd9f28b79..6040cc94c 100755
--- a/tests/cp/cp-HL
+++ b/tests/cp/cp-HL
@@ -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
diff --git a/tests/cp/cp-a-selinux b/tests/cp/cp-a-selinux
index 56b9dffdf..8cb5a456c 100755
--- a/tests/cp/cp-a-selinux
+++ b/tests/cp/cp-a-selinux
@@ -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
diff --git a/tests/cp/cp-deref b/tests/cp/cp-deref
index d167e6346..a666f5d6d 100755
--- a/tests/cp/cp-deref
+++ b/tests/cp/cp-deref
@@ -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
diff --git a/tests/cp/cp-i b/tests/cp/cp-i
index d7485e271..e7cd438aa 100755
--- a/tests/cp/cp-i
+++ b/tests/cp/cp-i
@@ -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
diff --git a/tests/cp/cp-mv-backup b/tests/cp/cp-mv-backup
index ab77adaca..9a464a16d 100755
--- a/tests/cp/cp-mv-backup
+++ b/tests/cp/cp-mv-backup
@@ -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
diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents
index 76c63be52..4500e5f48 100755
--- a/tests/cp/cp-parents
+++ b/tests/cp/cp-parents
@@ -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, 2006, 2007 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
diff --git a/tests/cp/deref-slink b/tests/cp/deref-slink
index 0facd134c..d677d4161 100755
--- a/tests/cp/deref-slink
+++ b/tests/cp/deref-slink
@@ -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
diff --git a/tests/cp/dir-rm-dest b/tests/cp/dir-rm-dest
index f531e63c7..45212c748 100755
--- a/tests/cp/dir-rm-dest
+++ b/tests/cp/dir-rm-dest
@@ -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
diff --git a/tests/cp/dir-slash b/tests/cp/dir-slash
index 31bfcb317..6a6a613a3 100755
--- a/tests/cp/dir-slash
+++ b/tests/cp/dir-slash
@@ -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
diff --git a/tests/cp/dir-vs-file b/tests/cp/dir-vs-file
index d14dda2c6..58cdf5eab 100755
--- a/tests/cp/dir-vs-file
+++ b/tests/cp/dir-vs-file
@@ -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
diff --git a/tests/cp/fail-perm b/tests/cp/fail-perm
index 31b4cb3ad..0ed9166f4 100755
--- a/tests/cp/fail-perm
+++ b/tests/cp/fail-perm
@@ -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
diff --git a/tests/cp/file-perm-race b/tests/cp/file-perm-race
index f211e26ef..94e402dbc 100755
--- a/tests/cp/file-perm-race
+++ b/tests/cp/file-perm-race
@@ -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 || {
diff --git a/tests/cp/into-self b/tests/cp/into-self
index d2dc0b8d7..7afe2a5bc 100755
--- a/tests/cp/into-self
+++ b/tests/cp/into-self
@@ -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
diff --git a/tests/cp/link b/tests/cp/link
index 96967b016..26fabfda7 100755
--- a/tests/cp/link
+++ b/tests/cp/link
@@ -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
diff --git a/tests/cp/link-no-deref b/tests/cp/link-no-deref
index 536015250..2e955a559 100755
--- a/tests/cp/link-no-deref
+++ b/tests/cp/link-no-deref
@@ -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
diff --git a/tests/cp/link-preserve b/tests/cp/link-preserve
index 42998c154..137bb901e 100755
--- a/tests/cp/link-preserve
+++ b/tests/cp/link-preserve
@@ -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
diff --git a/tests/cp/no-deref-link1 b/tests/cp/no-deref-link1
index d32fd5d08..a194303c9 100755
--- a/tests/cp/no-deref-link1
+++ b/tests/cp/no-deref-link1
@@ -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
diff --git a/tests/cp/no-deref-link2 b/tests/cp/no-deref-link2
index 47226eba1..e3ad0aab2 100755
--- a/tests/cp/no-deref-link2
+++ b/tests/cp/no-deref-link2
@@ -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
diff --git a/tests/cp/no-deref-link3 b/tests/cp/no-deref-link3
index 28cae539d..13841adb0 100755
--- a/tests/cp/no-deref-link3
+++ b/tests/cp/no-deref-link3
@@ -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
diff --git a/tests/cp/parent-perm-race b/tests/cp/parent-perm-race
index d393dd8f5..b09f8bced 100755
--- a/tests/cp/parent-perm-race
+++ b/tests/cp/parent-perm-race
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure cp -pR --parents isn't too generous with parent permissions.
-# Copyright (C) 2006, 2007 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
diff --git a/tests/cp/perm b/tests/cp/perm
index afaea803c..88052aa02 100755
--- a/tests/cp/perm
+++ b/tests/cp/perm
@@ -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
diff --git a/tests/cp/preserve-2 b/tests/cp/preserve-2
index e80209ffc..36a561cde 100755
--- a/tests/cp/preserve-2
+++ b/tests/cp/preserve-2
@@ -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
diff --git a/tests/cp/proc-zero-len b/tests/cp/proc-zero-len
index cd6f94c83..8330bfd28 100755
--- a/tests/cp/proc-zero-len
+++ b/tests/cp/proc-zero-len
@@ -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
diff --git a/tests/cp/r-vs-symlink b/tests/cp/r-vs-symlink
index 845963877..579c49576 100755
--- a/tests/cp/r-vs-symlink
+++ b/tests/cp/r-vs-symlink
@@ -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
diff --git a/tests/cp/same-file b/tests/cp/same-file
index 9e4d0cca5..7bf6da853 100755
--- a/tests/cp/same-file
+++ b/tests/cp/same-file
@@ -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
diff --git a/tests/cp/slink-2-slink b/tests/cp/slink-2-slink
index 60b93ba51..f6cc6e987 100755
--- a/tests/cp/slink-2-slink
+++ b/tests/cp/slink-2-slink
@@ -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
diff --git a/tests/cp/sparse b/tests/cp/sparse
index 32d46f55a..3238aa9cf 100755
--- a/tests/cp/sparse
+++ b/tests/cp/sparse
@@ -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
diff --git a/tests/cp/special-bits b/tests/cp/special-bits
index 6c99409e6..cce069cd4 100755
--- a/tests/cp/special-bits
+++ b/tests/cp/special-bits
@@ -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
diff --git a/tests/cp/src-base-dot b/tests/cp/src-base-dot
index 9cc03b1cc..274a66429 100755
--- a/tests/cp/src-base-dot
+++ b/tests/cp/src-base-dot
@@ -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
diff --git a/tests/cp/symlink-slash b/tests/cp/symlink-slash
index 9b582e240..3c13fe95d 100755
--- a/tests/cp/symlink-slash
+++ b/tests/cp/symlink-slash
@@ -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
diff --git a/tests/cp/thru-dangling b/tests/cp/thru-dangling
index 5a477957d..0503af943 100755
--- a/tests/cp/thru-dangling
+++ b/tests/cp/thru-dangling
@@ -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