summaryrefslogtreecommitdiff
path: root/tests/id
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2014-06-26 12:41:01 +0100
committerPádraig Brady <P@draigBrady.com>2014-06-26 15:30:41 +0100
commitacb422bdd1b325285bb46883f02d8fc6402efd14 (patch)
tree1f77b51c48cff7532a9227fa3517c5c26eee30be /tests/id
parente7c7802964cbf0f77a5883808e28eab56e36907b (diff)
downloadcoreutils-acb422bdd1b325285bb46883f02d8fc6402efd14.tar.xz
tests: use predetermined NON_ROOT_GID
* HACKING: GID is more useful in tests than group name, so rename input param from NON_ROOT_GROUP to NON_ROOT_GID to make it obvious that only a group ID is now acceptable, thus allowing GID lookups to be avoided throughout the tests. * init.cfg (require_root_): Likewise. * tests/misc/truncate-owned-by-other.sh: Avoid looking up the GID. * tests/touch/now-owned-by-other.sh: Likewise. * tests/misc/chroot-credentials.sh: Likewise. Also fix an instance of comparison against NON_ROOT_GROUP which would have given a false failure if a non numeric value was passed in. * tests/id/setgid.sh: Use previously looked up gid as a more accurate base for the subsequent adjustment, and move the uid lookup within chroot, rather than having the overhead of a separate `id` invocation.
Diffstat (limited to 'tests/id')
-rwxr-xr-xtests/id/setgid.sh19
1 files changed, 9 insertions, 10 deletions
diff --git a/tests/id/setgid.sh b/tests/id/setgid.sh
index 0664c47a2..6d9d74f43 100755
--- a/tests/id/setgid.sh
+++ b/tests/id/setgid.sh
@@ -20,21 +20,20 @@
print_ver_ id
require_root_
-u=$(id -u $NON_ROOT_USERNAME) || framework_failure_
-g=$u
-
-# Construct a different group number.
-gp1=$(expr $g + 1)
+# Construct a different group number
+gp1=$(expr $NON_ROOT_GID + 1)
echo $gp1 > exp || framework_failure_
-# With coreutils-8.16 and earlier, id -G would print both: $gp1 $g
-chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \
+# With coreutils-8.16 and earlier, id -G would print both:
+# $gp1 $NON_ROOT_GID
+chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \
id -G > out || fail=1
-compare exp out || { cat out; fail=1; }
+compare exp out || fail=1
-# With coreutils-8.22 and earlier, id would erroneously print groups=$g
-chroot --user=+$u:+$gp1 --groups='' / env PATH="$PATH" \
+# With coreutils-8.22 and earlier, id would erroneously print
+# groups=$NON_ROOT_GID
+chroot --user=$NON_ROOT_USERNAME:+$gp1 --groups='' / env PATH="$PATH" \
id > out || fail=1
grep -F "groups=$gp1" out || { cat out; fail=1; }