]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: move "group-names" into test-lib.sh
authorJim Meyering <meyering@redhat.com>
Sat, 3 May 2008 13:43:13 +0000 (15:43 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 6 May 2008 06:21:30 +0000 (08:21 +0200)
* tests/group-names: Remove file  Move contents into ...
* tests/test-lib.sh (require_membership_in_two_groups_): ...here.  New function.
* tests/chgrp/basic: Use the function, not the file.
* tests/chgrp/default-no-deref: Likewise.
* tests/chgrp/deref: Likewise.
* tests/chgrp/no-x: Likewise.
* tests/chgrp/posix-H: Likewise.
* tests/chgrp/recurse: Likewise.
* tests/cp/existing-perm-race: Likewise.
* tests/Makefile.am (EXTRA_DIST): Remove group-names.

tests/Makefile.am
tests/chgrp/basic
tests/chgrp/default-no-deref
tests/chgrp/deref
tests/chgrp/no-x
tests/chgrp/posix-H
tests/chgrp/recurse
tests/cp/existing-perm-race
tests/group-names [deleted file]
tests/test-lib.sh

index 515cfe6fe13526bb27593ead904521b4b7803a05..62defa25aaca9217eb9819362b702c7640e73827 100644 (file)
@@ -12,7 +12,6 @@ EXTRA_DIST =          \
   README               \
   check.mk             \
   envvar-check         \
-  group-names          \
   input-tty            \
   lang-default         \
   mk-script            \
index c21aec04fc86cd3f29d18f76d291e88fe55cfff8..889a62c9a0ec32fce7e9b10289ec6d3f40e3c57c 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 fail=0
 
index e1f711d7cb71dbf1f92e2beed7132f02abb88c88..ff484ed0057db73137397ecd6d85722e61b1d81f 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 set _ $groups; shift
 g2=$2
index f3453fb7a569c6016704b16d8115f4daf16859cf..ce70b9d2fc7a8e06791110a3ccde92869c974244 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 set _ $groups; shift
 g1=$1
index fbe100265456f3e0668675a8813dd8132e7bf83c..93dd520c3c86c5ba5329e00469eee889aca166f8 100755 (executable)
@@ -22,8 +22,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 skip_if_root_
 
 set _ $groups; shift
index 88345767b0a7b964d14604c6631b6356c76a67a2..0b18b44ce76e463aa0ff14f9c73fc8671a4c8a86 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 set _ $groups; shift
 g1=$1
index 4ae30f9693d2627a7ec45b00d91fcdde3165fc21..52b0e1973f6d634a3a1675ab20a233afd1dfbbcf 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   chgrp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 set _ $groups; shift
 g1=$1
index aa6d7c99a2673981387249970e984deb9c092da1..f2a3287238d9b904bee15686b7f6880486deebb7 100755 (executable)
@@ -21,8 +21,8 @@ if test "$VERBOSE" = yes; then
   cp --version
 fi
 
-. $top_srcdir/tests/group-names
 . $top_srcdir/tests/test-lib.sh
+require_membership_in_two_groups_
 
 set _ $groups; shift
 g1=$1
diff --git a/tests/group-names b/tests/group-names
deleted file mode 100644 (file)
index f9e0638..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- sh -*-
-# Set `groups' to a space-separated list of at least two groups of which
-# the user is a member.
-
-# Copyright (C) 2000, 2004, 2005 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/>.
-
-groups=${COREUTILS_GROUPS-`(id -G || /usr/xpg4/bin/id -G) 2>/dev/null`}
-case "$groups" in
-  *' '*) ;;
-  *) cat <<EOF 1>&2
-$0: this test requires that you be a member of more than one group,
-but running \`id -G' either failed or found just one.  If you really
-are a member of at least two groups, then rerun this test with
-COREUTILS_GROUPS set in your environment to the space-separated list
-of group names or numbers.  E.g.,
-
-  env COREUTILS_GROUPS='users cdrom' make check
-
-EOF
-     (exit 77); exit 77
-     ;;
-esac
index acdcbfb9ca58bfdf23dce5a67fef15d89ea0cea1..bd6be422bbaee2b8600620a2fe34dbb0a3e54173 100644 (file)
@@ -174,6 +174,29 @@ skip_if_root_() { uid_is_privileged_ && skip_test_ "must be run as non-root"; }
 error_() { echo "$0: $@" 1>&2; (exit 1); exit 1; }
 framework_failure() { error_ 'failure in testing framework'; }
 
+# Set `groups' to a space-separated list of at least two groups
+# of which the user is a member.
+require_membership_in_two_groups_()
+{
+  test $# = 0 || framework_failure
+
+  groups=${COREUTILS_GROUPS-`(id -G || /usr/xpg4/bin/id -G) 2>/dev/null`}
+  case "$groups" in
+    *' '*) ;;
+    *) skip_test_ '
+$0: this test requires that you be a member of more than one group,
+but running `id -G'\'' either failed or found just one.  If you really
+are a member of at least two groups, then rerun this test with
+COREUTILS_GROUPS set in your environment to the space-separated list
+of group names or numbers.  E.g.,
+
+  env COREUTILS_GROUPS='users cdrom' make check
+
+'
+     ;;
+  esac
+}
+
 mkfifo_or_skip_()
 {
   test $# = 1 || framework_failure