Fix use of empty keyfile (Issue 120).
[platform/upstream/cryptsetup.git] / tests / align-test
index 57d8c07..2963c8b 100755 (executable)
@@ -43,19 +43,20 @@ format() # key_bits expected [forced]
 {
        if [ -z "$3" ] ; then
                echo -n "Formatting using topology info ($1 bits key)...."
-               echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -s $1
+               echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -c aes-cbc-essiv:sha256 -s $1
        else
                echo -n "Formatting using forced sector alignment $3 ($1 bits key)..."
-               echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -s $1 --align-payload=$2
+               echo xxx| $CRYPTSETUP luksFormat $DEV -q -i1 -s $1 -c aes-cbc-essiv:sha256 --align-payload=$2
        fi
 
        ALIGN=$($CRYPTSETUP luksDump $DEV |grep "Payload offset" | sed -e s/.*\\t//)
        #echo "ALIGN = $ALIGN"
 
-       if [ $ALIGN -ne $2 ] ; then
+       if [ -z "$ALIGN" ] ; then
+               fail "FAIL"
+       elif [ $ALIGN -ne $2 ] ; then
                echo "FAIL"
-               echo "Expected alignment differs: expected $2 != detected $ALIGN"
-               fail
+               fail "Expected alignment differs: expected $2 != detected $ALIGN"
        fi
        echo "PASSED"
 }