]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
config: Fix SCRATCH_DEV_POOL handling
authorLukas Czerner <lczerner@redhat.com>
Tue, 8 Apr 2014 23:55:50 +0000 (09:55 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 8 Apr 2014 23:55:50 +0000 (09:55 +1000)
With changes introduced in 667308dd97bf41382d4ab299fa5b56c235cfeb27
it is no longer possible to use SCRATCH_DEV_POOL variable because of
error:

 common/config: Error: $SCRATCH_DEV should be unset when
 $SCRATCH_DEV_POOL is set

This was because get_next_config() would get called twice and hence it
would complain on the second run that SCRATCH_DEV is already set. Fix
it by making sure that we call get_next_config() only once if there
are no sections in the config file.

Also make sure that we export SCRATCH_DEV in the case we're deducing it
from SCRATCH_DEV_POOL.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Filipe David Manana <fdmanana@gmail.com>
Tested-by: Filipe David Manana <fdmanana@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
common/config

index 4178c27f16f8a4338b87c6f8b6c2420fd7d10c8a..6fa18e210f6ebb9527bda4608f4b47a72006dcd4 100644 (file)
@@ -360,6 +360,10 @@ parse_config_section() {
 }
 
 get_next_config() {
+       if [ ! -z "$CONFIG_INCLUDED" ] && ! $OPTIONS_HAVE_SECTIONS; then
+               return 0
+       fi
+
        local OLD_FSTYP=$FSTYP
        local OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
        local OLD_MKFS_OPTIONS=$MKFS_OPTIONS
@@ -414,10 +418,11 @@ get_next_config() {
        # 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"
+                       echo "common/config: Error: \$SCRATCH_DEV ($SCRATCH_DEV) should be unset when \$SCRATCH_DEV_POOL ($SCRATCH_DEV_POOL) is set"
                        exit 1
                fi
                SCRATCH_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
+               export SCRATCH_DEV
        fi
 
        echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1