summaryrefslogtreecommitdiff
path: root/tests/chmod
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/chmod
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/chmod')
-rw-r--r--tests/chmod/Makefile.am2
-rwxr-xr-xtests/chmod/c-option29
-rwxr-xr-xtests/chmod/equal-x18
-rwxr-xr-xtests/chmod/equals18
-rwxr-xr-xtests/chmod/inaccessible20
-rwxr-xr-xtests/chmod/no-x21
-rwxr-xr-xtests/chmod/octal16
-rwxr-xr-xtests/chmod/setgid25
-rwxr-xr-xtests/chmod/thru-dangling19
-rwxr-xr-xtests/chmod/umask-x23
-rwxr-xr-xtests/chmod/usage28
11 files changed, 38 insertions, 181 deletions
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 <<EOF > exp
$prog: \`d/no-x': Permission denied
EOF
-cmp out exp || fail=1
-test $fail = 1 && diff out exp 2> /dev/null
+compare out exp || fail=1
mkdir -p a/b
cd a
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