tests: migrate setgid-check into test-lib.sh
authorJim Meyering <meyering@redhat.com>
Fri, 27 Mar 2009 08:23:35 +0000 (09:23 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 27 Mar 2009 08:28:08 +0000 (09:28 +0100)
* tests/test-lib.sh (skip_if_setgid_): New function.
* tests/setgid-check: Remove file.
* tests/Makefile.am (EXTRA_DIST): Remove setgid-check.
* tests/chmod/c-option: Use the new function rather than sourcing
the separate file.
* tests/cp/cp-parents: Likewise.
* tests/install/install-C: Likewise.
* tests/mkdir/parents: Likewise.
* tests/mkdir/perm: Likewise.

tests/Makefile.am
tests/chmod/c-option
tests/cp/cp-parents
tests/install/install-C
tests/mkdir/parents
tests/mkdir/perm
tests/setgid-check [deleted file]
tests/test-lib.sh

index 5f150ad..6356eaa 100644 (file)
@@ -15,7 +15,6 @@ EXTRA_DIST =          \
   other-fs-tmpdir      \
   require-perl         \
   sample-test          \
-  setgid-check         \
   test-lib.sh          \
   $(pr_data)
 
index eb8530a..7bf9e78 100755 (executable)
@@ -28,7 +28,7 @@ file=f
 touch $file || framework_failure
 chmod 444 $file || framework_failure
 
-. "$abs_srcdir/setgid-check"
+skip_if_setgid_
 
 fail=0
 
index bfaf747..f4130e6 100755 (executable)
@@ -28,7 +28,7 @@ fi
 working_umask_or_skip_
 
 # Run the setgid check from the just-created directory.
-. "$abs_srcdir/setgid-check"
+skip_if_setgid_
 
 mkdir foo bar || framework_failure
 mkdir -p a/b/c d e g || framework_failure
index 3bf0c7b..9d0ec90 100755 (executable)
@@ -22,7 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/test-lib.sh
-. "$abs_srcdir/setgid-check"
+skip_if_setgid_
 
 mode1=0644
 mode2=0755
index 46f5867..3ae35a9 100755 (executable)
@@ -22,7 +22,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/test-lib.sh
-. "$abs_srcdir/setgid-check"
+skip_if_setgid_
 
 mkdir -m 700 e-dir || framework_failure
 
index 2f12d07..146a88e 100755 (executable)
@@ -23,7 +23,7 @@ if test "$VERBOSE" = yes; then
 fi
 
 . $srcdir/test-lib.sh
-. "$abs_srcdir/setgid-check"
+skip_if_setgid_
 
 working_umask_or_skip_
 
diff --git a/tests/setgid-check b/tests/setgid-check
deleted file mode 100644 (file)
index cf26184..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- sh -*-
-# Disable the current test if the working directory seems to have
-# the setgid bit set.
-
-# Copyright (C) 2000, 2002, 2004, 2005, 2007, 2009 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
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-# This test should be run in the temporary directory that ends
-# up being removed via the trap commands.
-
-cwd_is_setgid=no
-
-setgid_tmpdir=setgid-$$
-(umask 77; mkdir $setgid_tmpdir)
-perms=$(stat --printf %A $setgid_tmpdir)
-rmdir $setgid_tmpdir
-case $perms in
-  drwx------);;
-  drwxr-xr-x);;  # Windows98 + DJGPP 2.03
-  *) cwd_is_setgid=yes;;
-esac
-if test $cwd_is_setgid = yes; then
-  skip_test_ 'this directory has the setgid bit set'
-fi
index 45026f1..17a3538 100644 (file)
@@ -262,6 +262,21 @@ mkfifo_or_skip_()
   fi
 }
 
+# Disable the current test if the working directory seems to have
+# the setgid bit set.
+skip_if_setgid_()
+{
+  setgid_tmpdir=setgid-$$
+  (umask 77; mkdir $setgid_tmpdir)
+  perms=$(stat --printf %A $setgid_tmpdir)
+  rmdir $setgid_tmpdir
+  case $perms in
+    drwx------);;
+    drwxr-xr-x);;  # Windows98 + DJGPP 2.03
+    *) skip_test_ 'this directory has the setgid bit set';;
+  esac
+}
+
 skip_if_mcstransd_is_running_()
 {
   test $# = 0 || framework_failure