xfstests: Allow to re-read configuration

Move configuration initialization into a function so we can re-read it
without the need to reinclude the common/config file which would be
ugly. This is in preparation for adding support for sections into config
files.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
This commit is contained in:
Lukas Czerner
2013-07-11 10:38:00 +00:00
committed by Rich Johnston
parent 2ff460998d
commit dcaf866187
+54 -48
View File
@@ -214,64 +214,70 @@ esac
known_hosts()
{
[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
[ -f /etc/xfsqa.config ] && . /etc/xfsqa.config
[ -f $HOST_CONFIG_DIR/$HOST ] && . $HOST_CONFIG_DIR/$HOST
[ -f $HOST_CONFIG_DIR/$HOST.config ] && . $HOST_CONFIG_DIR/$HOST.config
# Mandatory Config values.
MC=""
[ -z "$EMAIL" ] && MC="$MC EMAIL"
[ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
[ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
if [ -n "$MC" ]; then
echo "Warning: need to define parameters for host $HOST"
echo " or set variables:"
echo " $MC"
exit 1
fi
[ -f /etc/xfsqa.config ] && export HOST_OPTIONS=/etc/xfsqa.config
[ -f $HOST_CONFIG_DIR/$HOST ] && export HOST_OPTIONS=$HOST_CONFIG_DIR/$HOST
[ -f $HOST_CONFIG_DIR/$HOST.config ] && export HOST_OPTIONS=$HOST_CONFIG_DIR/$HOST.config
}
if [ ! -f "$HOST_OPTIONS" ]; then
known_hosts
fi
if [ -f "$HOST_OPTIONS" ]; then
. "$HOST_OPTIONS"
else
known_hosts
. $HOST_OPTIONS
fi
echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
echo "common/config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
exit 1
fi
get_next_config() {
# Mandatory Config values.
MC=""
[ -z "$EMAIL" ] && MC="$MC EMAIL"
[ -z "$TEST_DIR" ] && MC="$MC TEST_DIR"
[ -z "$TEST_DEV" ] && MC="$MC TEST_DEV"
if [ ! -d "$TEST_DIR" ]; then
echo "common/config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
exit 1
fi
if [ -n "$MC" ]; then
echo "Warning: need to define parameters for host $HOST"
echo " or set variables:"
echo " $MC"
exit 1
fi
# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev
# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility
if [ ! -z "$SCRATCH_DEV_POOL" ]; then
if [ ! -z "$SCRATCH_DEV" ]; then
echo "common/config: Error: \$SCRATCH_DEV should be unset when \$SCRATCH_DEV_POOL is set"
exit 1
fi
SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
fi
echo $TEST_DEV | grep -q ":" > /dev/null 2>&1
if [ ! -b "$TEST_DEV" -a "$?" != "0" ]; then
echo "common/config: Error: \$TEST_DEV ($TEST_DEV) is not a block device or a NFS filesystem"
exit 1
fi
echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a NFS filesystem"
exit 1
fi
if [ ! -d "$TEST_DIR" ]; then
echo "common/config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
exit 1
fi
if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then
echo "common/config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory"
exit 1
fi
# a btrfs tester will set only SCRATCH_DEV_POOL, we will put first of its dev
# to SCRATCH_DEV and rest to SCRATCH_DEV_POOL to maintain the backward compatibility
if [ ! -z "$SCRATCH_DEV_POOL" ]; then
if [ ! -z "$SCRATCH_DEV" ]; then
echo "common/config: Error: \$SCRATCH_DEV should be unset when \$SCRATCH_DEV_POOL is set"
exit 1
fi
SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
SCRATCH_DEV_POOL=`echo $SCRATCH_DEV_POOL | awk '{ ORS=" "; for (i = 2; i <= NF; i++) print $i}'`
fi
echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]; then
echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) is not a block device or a NFS filesystem"
exit 1
fi
if [ ! -z "$SCRATCH_MNT" -a ! -d "$SCRATCH_MNT" ]; then
echo "common/config: Error: \$SCRATCH_MNT ($SCRATCH_MNT) is not a directory"
exit 1
fi
}
get_next_config
# make sure this script returns success
/bin/true