mdadm/test: correct the logic operation in save_log

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>
This commit is contained in:
Zhilong Liu 2018-01-16 17:45:02 +08:00 committed by Jes Sorensen
parent 3bf9495270
commit ed5e31aa21
1 changed files with 4 additions and 5 deletions

9
test
View File

@ -59,16 +59,11 @@ save_log() {
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: mdadm -D ${array[@]}" >> $logdir/$logfile
$mdadm -D ${array[@]} >> $logdir/$logfile
[ "$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
@ -77,6 +72,10 @@ save_log() {
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 ]