From df0beae1eb1318869d51a064aec8fdd401877cbf Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 6 Sep 2007 17:34:49 +0200 Subject: Adjust chgrp, chmod, chown, cp tests to use test-lib.sh. * tests/check.mk: Also define abs_top_builddir. --- tests/check.mk | 1 + tests/chgrp/Makefile.am | 2 ++ tests/chgrp/basic | 16 +--------------- tests/chgrp/default-no-deref | 19 ++++--------------- tests/chgrp/deref | 17 ++--------------- tests/chgrp/no-x | 28 ++++++++-------------------- tests/chgrp/posix-H | 28 ++++++++-------------------- tests/chgrp/recurse | 17 ++--------------- tests/chmod/Makefile.am | 2 ++ tests/chmod/c-option | 29 +++++------------------------ tests/chmod/equal-x | 18 +++--------------- tests/chmod/equals | 18 +++--------------- tests/chmod/inaccessible | 20 ++++---------------- tests/chmod/no-x | 21 ++++----------------- tests/chmod/octal | 16 ++-------------- tests/chmod/setgid | 25 +++++-------------------- tests/chmod/thru-dangling | 19 +++---------------- tests/chmod/umask-x | 23 ++--------------------- tests/chmod/usage | 28 +++++----------------------- tests/chown/Makefile.am | 2 ++ tests/chown/basic | 19 +++---------------- tests/chown/deref | 22 ++++------------------ tests/chown/preserve-root | 20 +++----------------- tests/chown/separator | 33 ++++++++++----------------------- tests/cp/Makefile.am | 3 ++- tests/cp/acl | 37 ++++++++++--------------------------- tests/cp/backup-1 | 18 +++--------------- tests/cp/backup-dir | 19 +++---------------- tests/cp/backup-is-src | 25 +++++-------------------- tests/cp/cp-HL | 26 ++++++-------------------- tests/cp/cp-a-selinux | 34 +++++++++++----------------------- tests/cp/cp-deref | 23 ++++++----------------- tests/cp/cp-i | 22 ++++------------------ tests/cp/cp-mv-backup | 23 +++-------------------- tests/cp/cp-parents | 37 ++++++++----------------------------- tests/cp/deref-slink | 21 ++++----------------- tests/cp/dir-rm-dest | 18 +++--------------- tests/cp/dir-slash | 20 ++++---------------- tests/cp/dir-vs-file | 22 ++++------------------ tests/cp/fail-perm | 29 ++++++++--------------------- tests/cp/file-perm-race | 11 ++--------- tests/cp/into-self | 23 ++++------------------- tests/cp/link | 22 +++++----------------- tests/cp/link-no-deref | 18 +++--------------- tests/cp/link-preserve | 31 +++++++++---------------------- tests/cp/no-deref-link1 | 17 ++--------------- tests/cp/no-deref-link2 | 17 ++--------------- tests/cp/no-deref-link3 | 17 ++--------------- tests/cp/parent-perm-race | 13 +++---------- tests/cp/perm | 18 ++---------------- tests/cp/preserve-2 | 17 +++-------------- tests/cp/proc-zero-len | 20 +++----------------- tests/cp/r-vs-symlink | 23 +++++------------------ tests/cp/same-file | 22 +++------------------- tests/cp/slink-2-slink | 30 +++++++----------------------- tests/cp/sparse | 20 +++----------------- tests/cp/special-bits | 31 +++++++++---------------------- tests/cp/src-base-dot | 23 ++++------------------- tests/cp/symlink-slash | 22 ++++------------------ tests/cp/thru-dangling | 25 +++++-------------------- tests/test-lib.sh | 6 ++++++ 61 files changed, 258 insertions(+), 988 deletions(-) (limited to 'tests') diff --git a/tests/check.mk b/tests/check.mk index f5c08a259..2b152df98 100644 --- a/tests/check.mk +++ b/tests/check.mk @@ -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) diff --git a/tests/chgrp/Makefile.am b/tests/chgrp/Makefile.am index 8dffd0157..8fc5f6876 100644 --- a/tests/chgrp/Makefile.am +++ b/tests/chgrp/Makefile.am @@ -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 diff --git a/tests/chgrp/basic b/tests/chgrp/basic index e970cac5d..8a795d63b 100755 --- a/tests/chgrp/basic +++ b/tests/chgrp/basic @@ -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 diff --git a/tests/chgrp/default-no-deref b/tests/chgrp/default-no-deref index 73137ff95..e7239d52d 100755 --- a/tests/chgrp/default-no-deref +++ b/tests/chgrp/default-no-deref @@ -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 diff --git a/tests/chgrp/deref b/tests/chgrp/deref index b40dd5a45..5dd61e105 100755 --- a/tests/chgrp/deref +++ b/tests/chgrp/deref @@ -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 diff --git a/tests/chgrp/no-x b/tests/chgrp/no-x index 58ac089c7..a98ba90ef 100755 --- a/tests/chgrp/no-x +++ b/tests/chgrp/no-x @@ -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 < 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 diff --git a/tests/chgrp/posix-H b/tests/chgrp/posix-H index 1e715dc08..a9b41d011 100755 --- a/tests/chgrp/posix-H +++ b/tests/chgrp/posix-H @@ -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 diff --git a/tests/chgrp/recurse b/tests/chgrp/recurse index b06f1a001..a0cacd645 100755 --- a/tests/chgrp/recurse +++ b/tests/chgrp/recurse @@ -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 diff --git a/tests/chmod/Makefile.am b/tests/chmod/Makefile.am index 643015fef..8fb595a79 100644 --- a/tests/chmod/Makefile.am +++ b/tests/chmod/Makefile.am @@ -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 diff --git a/tests/chmod/c-option b/tests/chmod/c-option index eaecc2adc..e491b75b0 100755 --- a/tests/chmod/c-option +++ b/tests/chmod/c-option @@ -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 diff --git a/tests/chmod/equal-x b/tests/chmod/equal-x index bcfb511cc..5a1b85926 100755 --- a/tests/chmod/equal-x +++ b/tests/chmod/equal-x @@ -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 diff --git a/tests/chmod/equals b/tests/chmod/equals index 27bbcbce2..47a9c52d0 100755 --- a/tests/chmod/equals +++ b/tests/chmod/equals @@ -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 diff --git a/tests/chmod/inaccessible b/tests/chmod/inaccessible index d6d8f5009..318d4bba5 100755 --- a/tests/chmod/inaccessible +++ b/tests/chmod/inaccessible @@ -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 diff --git a/tests/chmod/no-x b/tests/chmod/no-x index 34abba9cc..64dffb95b 100755 --- a/tests/chmod/no-x +++ b/tests/chmod/no-x @@ -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 < 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 diff --git a/tests/chmod/octal b/tests/chmod/octal index f29a53dd4..781b904dc 100755 --- a/tests/chmod/octal +++ b/tests/chmod/octal @@ -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 diff --git a/tests/chmod/setgid b/tests/chmod/setgid index 92a026ff0..0c583f274 100755 --- a/tests/chmod/setgid +++ b/tests/chmod/setgid @@ -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," \ diff --git a/tests/chmod/thru-dangling b/tests/chmod/thru-dangling index 7a82db83d..9423a7401 100755 --- a/tests/chmod/thru-dangling +++ b/tests/chmod/thru-dangling @@ -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 diff --git a/tests/chmod/umask-x b/tests/chmod/umask-x index 8d2be9353..c7b139b88 100755 --- a/tests/chmod/umask-x +++ b/tests/chmod/umask-x @@ -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 diff --git a/tests/chmod/usage b/tests/chmod/usage index 98944f54d..8e45edc69 100755 --- a/tests/chmod/usage +++ b/tests/chmod/usage @@ -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 diff --git a/tests/chown/Makefile.am b/tests/chown/Makefile.am index 61e65818f..e0017c1be 100644 --- a/tests/chown/Makefile.am +++ b/tests/chown/Makefile.am @@ -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 diff --git a/tests/chown/basic b/tests/chown/basic index 668e39d68..a4276b8de 100755 --- a/tests/chown/basic +++ b/tests/chown/basic @@ -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 diff --git a/tests/chown/deref b/tests/chown/deref index 9da201325..74684fe6a 100755 --- a/tests/chown/deref +++ b/tests/chown/deref @@ -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 diff --git a/tests/chown/preserve-root b/tests/chown/preserve-root index 6889fa579..de45cbc16 100755 --- a/tests/chown/preserve-root +++ b/tests/chown/preserve-root @@ -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 diff --git a/tests/chown/separator b/tests/chown/separator index 991589735..de33831a9 100755 --- a/tests/chown/separator +++ b/tests/chown/separator @@ -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 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/'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/'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 diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 79d0ef2c7..10571a1e6 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -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,.*/,,'; } -- cgit v1.2.3-54-g00ecf