]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
mdadm/test: correct the logic operation in save_log
authorZhilong Liu <zlliu@suse.com>
Tue, 16 Jan 2018 09:45:02 +0000 (17:45 +0800)
committerJes Sorensen <jsorensen@fb.com>
Sun, 21 Jan 2018 21:36:08 +0000 (16:36 -0500)
1. delete the mdadm -As, keep the original testing scene intact.
2. move some actions into 'array' test, 'mdadm -D $array' would
   complain errors if $array is null.

Signed-off-by: Zhilong Liu <zlliu@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
test

diff --git a/test b/test
index e74bbe5756fa2687755eb4934ca1fd980524ce8d..eb67ef53304afc7d2307402386b96bf70d25da65 100755 (executable)
--- a/test
+++ b/test
@@ -59,16 +59,11 @@ save_log() {
        cp $targetdir/log $logdir/$_basename.log
        echo "## $HOSTNAME: saving dmesg." >> $logdir/$logfile
        dmesg -c >> $logdir/$logfile
        cp $targetdir/log $logdir/$_basename.log
        echo "## $HOSTNAME: saving dmesg." >> $logdir/$logfile
        dmesg -c >> $logdir/$logfile
-       $mdadm -As 2> /dev/null
        echo "## $HOSTNAME: saving proc mdstat." >> $logdir/$logfile
        cat /proc/mdstat >> $logdir/$logfile
        array=($(mdadm -Ds | cut -d' ' -f2))
        echo "## $HOSTNAME: saving proc mdstat." >> $logdir/$logfile
        cat /proc/mdstat >> $logdir/$logfile
        array=($(mdadm -Ds | cut -d' ' -f2))
-       echo "## $HOSTNAME: mdadm -D ${array[@]}" >> $logdir/$logfile
-       $mdadm -D ${array[@]} >> $logdir/$logfile
        [ "$1" == "fail" ] &&
                echo "FAILED - see $logdir/$_basename.log and $logdir/$logfile for details"
        [ "$1" == "fail" ] &&
                echo "FAILED - see $logdir/$_basename.log and $logdir/$logfile for details"
-       # ignore saving external(external file, imsm...) bitmap
-       cat /proc/mdstat | grep -q "linear\|external" && return 0
        if [ $DEVTYPE == 'lvm' ]
        then
                # not supported lvm type yet
        if [ $DEVTYPE == 'lvm' ]
        then
                # not supported lvm type yet
@@ -77,6 +72,10 @@ save_log() {
        then
                if [ ! -z "$array" -a ${#array[@]} -ge 1 ]
                then
        then
                if [ ! -z "$array" -a ${#array[@]} -ge 1 ]
                then
+                       echo "## $HOSTNAME: mdadm -D ${array[@]}" >> $logdir/$logfile
+                       $mdadm -D ${array[@]} >> $logdir/$logfile
+                       # ignore saving external(external file, imsm...) bitmap
+                       cat /proc/mdstat | grep -q "linear\|external" && return 0
                        md_disks=($($mdadm -D -Y ${array[@]} | grep "/dev/" | cut -d'=' -f2))
                        cat /proc/mdstat | grep -q "bitmap"
                        if [ $? -eq 0 ]
                        md_disks=($($mdadm -D -Y ${array[@]} | grep "/dev/" | cut -d'=' -f2))
                        cat /proc/mdstat | grep -q "bitmap"
                        if [ $? -eq 0 ]