Whamcloud - gitweb
LU-7993 test: Fix division by 0 in info prints 59/19359/2
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Wed, 6 Apr 2016 16:09:55 +0000 (12:09 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 14 Jun 2016 03:53:26 +0000 (03:53 +0000)
Some of the information only prints in sanity/116a don't account for a
0 in the minimum number and thus divide by zero, but only print if MIN
is above zero, so this just doesn't do the calculation if it isn't
needed.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I7003739f6b518f981a1058d41b19bca258e1d11e
Reviewed-on: http://review.whamcloud.com/19359
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/tests/sanity.sh

index fdfca1f..ef03ac1 100644 (file)
@@ -7617,9 +7617,10 @@ test_116a() { # was previously test_116()
        echo "Wrote ${DIFF}KB to smaller OST $MINI1"
        DIFF2=$(($MAXV1 - ${AVAIL[$MAXI1]}))
        echo "Wrote ${DIFF2}KB to larger OST $MAXI1"
-       FILL=$(($DIFF2 * 100 / $DIFF - 100))
-       [ $DIFF -gt 0 ] &&
+       if [[ $DIFF -gt 0 ]]; then
+               FILL=$(($DIFF2 * 100 / $DIFF - 100))
                echo "Wrote ${FILL}% more data to larger OST $MAXI1"
+       fi
 
        # Figure out which files were written where
        UUID=$(lctl get_param -n lov.${FSNAME}-clilov-*.target_obd |
@@ -7632,9 +7633,10 @@ test_116a() { # was previously test_116()
        echo $UUID
        MAXC=$($GETSTRIPE --ost $UUID $DIR/$tdir | grep $DIR | wc -l)
        echo "$MAXC files created on larger OST $MAXI1"
-       FILL=$(($MAXC * 100 / $MINC - 100))
-       [[ $MINC -gt 0 ]] &&
+       if [[ $MINC -gt 0 ]]; then
+               FILL=$(($MAXC * 100 / $MINC - 100))
                echo "Wrote ${FILL}% more files to larger OST $MAXI1"
+       fi
        [[ $MAXC -gt $MINC ]] ||
                error_ignore LU-9 "stripe QOS didn't balance free space"
        simple_cleanup_common