public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: xfs@oss.sgi.com
Cc: lczerner@redhat.com
Subject: [PATCH 05/10 v2] xfstests: Allow to re-read configuration
Date: Thu, 11 Jul 2013 12:38:00 +0200	[thread overview]
Message-ID: <1373539085-8577-6-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1373539085-8577-1-git-send-email-lczerner@redhat.com>

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>
---
 common/config | 104 +++++++++++++++++++++++++++++++---------------------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/common/config b/common/config
index 1679acf..34c99e1 100644
--- a/common/config
+++ b/common/config
@@ -214,64 +214,70 @@ esac
 
 known_hosts()
 {
-  [ "$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
+	[ "$HOST_CONFIG_DIR" ] || HOST_CONFIG_DIR=`pwd`/configs
+
+	[ -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
-    . "$HOST_OPTIONS"
-else
-    known_hosts
+if [ ! -f "$HOST_OPTIONS" ]; then
+	known_hosts
 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
+if [ -f "$HOST_OPTIONS" ]; then
+	. $HOST_OPTIONS
 fi
 
-if [ ! -d "$TEST_DIR" ]; then
-    echo "common/config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
-    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 [ -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
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2013-07-11 10:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-11 10:37 [RFC][PATCH 00/10 v2] xfstests: Add support for config section Lukas Czerner
2013-07-11 10:37 ` [PATCH 01/10 v2] xfstests: Run all tests when nothing is specified Lukas Czerner
2013-08-02 23:48   ` Chandra Seetharaman
2013-10-16 19:36   ` Rich Johnston
2013-07-11 10:37 ` [PATCH 02/10 v2] xfstests: Export all important variables in common/config Lukas Czerner
2013-08-02 23:49   ` Chandra Seetharaman
2013-07-11 10:37 ` [PATCH 03/10 v2] xfstests: Refactor code for obtaining test list Lukas Czerner
2013-08-02 23:49   ` Chandra Seetharaman
2013-07-11 10:37 ` [PATCH 04/10 v2] xfstests: Allow to recheck options in common/rc Lukas Czerner
2013-08-02 23:50   ` Chandra Seetharaman
2013-07-11 10:38 ` Lukas Czerner [this message]
2013-08-02 23:51   ` [PATCH 05/10 v2] xfstests: Allow to re-read configuration Chandra Seetharaman
2013-07-11 10:38 ` [PATCH 06/10 v2] xfstests: Allow to specify RESULT_BASE directory Lukas Czerner
2013-08-02 23:51   ` Chandra Seetharaman
2013-07-11 10:38 ` [PATCH 07/10 v2] xfstests: Prepare for config section Lukas Czerner
2013-08-02 23:53   ` Chandra Seetharaman
2013-07-11 10:38 ` [PATCH 08/10 v2] xfstests: Add support for sections in config file Lukas Czerner
2013-08-03  0:05   ` Chandra Seetharaman
2013-07-11 10:38 ` [PATCH 09/10 v2] xfstests: Allow to recreate TEST_DEV Lukas Czerner
2013-08-03  0:13   ` Chandra Seetharaman
2013-07-11 10:38 ` [PATCH 10/10 v2] xfstests: Remount file system if MOUNT_OPTIONS changed Lukas Czerner
2013-08-03  0:14   ` Chandra Seetharaman
2013-10-16 20:51   ` Rich Johnston
2013-10-17 10:49     ` [PATCH 10/10 v2] xfstests: Remount file system if MOUNT_OPTIONS changedx Lukáš Czerner
2013-08-16 15:43 ` [RFC][PATCH 00/10 v2] xfstests: Add support for config section Rich Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373539085-8577-6-git-send-email-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox