confidence_test.sh: assert_file_group() fails if gid name includes space.

This commit is contained in:
tlimoncelli@stackexchange.com
2015-07-03 15:05:31 +00:00
parent 626ff178b6
commit f5eeffd043

View File

@@ -64,17 +64,26 @@ function assert_file_md5hash() {
function assert_file_group() { function assert_file_group() {
local file="$1" local file="$1"
local wanted="$2" local wanted="$2"
local found
assert_file_exists "$file" assert_file_exists "$file"
case $(uname -s) in case $(uname -s) in
Darwin|FreeBSD )
found=$(stat -f '%Sg' $file)
;;
Linux )
found=$(stat -c '%G' $file)
;;
CYGWIN* ) CYGWIN* )
echo "ASSERT_FILE_GROUP: Running on Cygwin. Not being tested." echo "ASSERT_FILE_GROUP: Running on Cygwin. Not being tested."
return 0 return 0
;; ;;
* )
echo 'ERROR: Unknown OS. Exiting.'
exit 1
;;
esac esac
local found=$(ls -lg "$file" | awk '{ print $3 }')
# NB(tlim): We could do this with 'stat' but it would break on BSD-style OSs.
if [[ "$wanted" != "$found" ]]; then if [[ "$wanted" != "$found" ]]; then
echo "ASSERT FAILED: $file chgrp wanted=$wanted found=$found" echo "ASSERT FAILED: $file chgrp wanted=$wanted found=$found"
exit 1 exit 1
@@ -286,9 +295,9 @@ DEFAULT_GID_NAME=$(id -gn)
# Pick a group that is not the default group: # Pick a group that is not the default group:
TEST_GID_NUM=$(id -G | fmt -1 | tail -n +2 | grep -xv $(id -u) | head -n 1) TEST_GID_NUM=$(id -G | fmt -1 | tail -n +2 | grep -xv $(id -u) | head -n 1)
TEST_GID_NAME=$(python -c 'import grp; print grp.getgrgid('"$TEST_GID_NUM"').gr_name') TEST_GID_NAME=$(python -c 'import grp; print grp.getgrgid('"$TEST_GID_NUM"').gr_name')
echo DEFAULT_GID_NAME=$DEFAULT_GID_NAME echo "DEFAULT_GID_NAME=$DEFAULT_GID_NAME"
echo TEST_GID_NUM=$TEST_GID_NUM echo "TEST_GID_NUM=$TEST_GID_NUM"
echo TEST_GID_NAME=$TEST_GID_NAME echo "TEST_GID_NAME=$TEST_GID_NAME"
PHASE 'Bob postdeploys... default.' PHASE 'Bob postdeploys... default.'
blackbox_postdeploy blackbox_postdeploy