From e65d0d0525159f963b3b859706dc920bcae0a636 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 27 Mar 2009 09:23:35 +0100 Subject: [PATCH] tests: migrate setgid-check into test-lib.sh * 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 | 1 - tests/chmod/c-option | 2 +- tests/cp/cp-parents | 2 +- tests/install/install-C | 2 +- tests/mkdir/parents | 2 +- tests/mkdir/perm | 2 +- tests/setgid-check | 36 ------------------------------------ tests/test-lib.sh | 15 +++++++++++++++ 8 files changed, 20 insertions(+), 42 deletions(-) delete mode 100644 tests/setgid-check diff --git a/tests/Makefile.am b/tests/Makefile.am index 5f150ad..6356eaa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,7 +15,6 @@ EXTRA_DIST = \ other-fs-tmpdir \ require-perl \ sample-test \ - setgid-check \ test-lib.sh \ $(pr_data) diff --git a/tests/chmod/c-option b/tests/chmod/c-option index eb8530a..7bf9e78 100755 --- a/tests/chmod/c-option +++ b/tests/chmod/c-option @@ -28,7 +28,7 @@ file=f touch $file || framework_failure chmod 444 $file || framework_failure -. "$abs_srcdir/setgid-check" +skip_if_setgid_ fail=0 diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents index bfaf747..f4130e6 100755 --- a/tests/cp/cp-parents +++ b/tests/cp/cp-parents @@ -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 diff --git a/tests/install/install-C b/tests/install/install-C index 3bf0c7b..9d0ec90 100755 --- a/tests/install/install-C +++ b/tests/install/install-C @@ -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 diff --git a/tests/mkdir/parents b/tests/mkdir/parents index 46f5867..3ae35a9 100755 --- a/tests/mkdir/parents +++ b/tests/mkdir/parents @@ -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 diff --git a/tests/mkdir/perm b/tests/mkdir/perm index 2f12d07..146a88e 100755 --- a/tests/mkdir/perm +++ b/tests/mkdir/perm @@ -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 index cf26184..0000000 --- a/tests/setgid-check +++ /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 . - -# 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 diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 45026f1..17a3538 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -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 -- 2.7.4