X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Fdiscards-test;h=8a838e60a653a220d52bf2a6621635cd83723f71;hb=refs%2Ftags%2Fupstream%2F2.3.3;hp=9251820dab851fabf77d8f9a8b4dd9c03204ad63;hpb=e5244bc47cd270ee7ee2c28bb514b71a209533bd;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/tests/discards-test b/tests/discards-test index 9251820..8a838e6 100755 --- a/tests/discards-test +++ b/tests/discards-test @@ -1,11 +1,13 @@ #!/bin/bash -CRYPTSETUP="../src/cryptsetup" +[ -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".." +CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup DEV_NAME="discard-t3st" DEV="" +PWD1="93R4P4pIqAH8" cleanup() { - [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove $DEV_NAME + [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME udevadm settle >/dev/null 2>&1 rmmod scsi_debug 2>/dev/null sleep 2 @@ -13,20 +15,21 @@ cleanup() { fail() { - echo "FAILED" + echo "FAILED backtrace:" + while caller $frame; do ((frame++)); done cleanup exit 100 } add_device() { - modprobe scsi_debug $@ + modprobe scsi_debug $@ delay=0 if [ $? -ne 0 ] ; then echo "This kernel seems to not support proper scsi_debug module, test skipped." - exit 0 + exit 77 fi sleep 2 - DEV=$(grep scsi_debug /sys/block/*/device/model | cut -f4 -d /) + DEV=$(grep -l -e scsi_debug /sys/block/*/device/model | cut -f4 -d /) DEV="/dev/$DEV" [ -b $DEV ] || fail "Cannot find $DEV." @@ -34,26 +37,28 @@ add_device() { function check_version() { - VER_STR=$(dmsetup targets | grep crypt | cut -f 2 -dv) - VER_MAJ=$(echo $VER_STR | cut -f 1 -d.) - VER_MIN=$(echo $VER_STR | cut -f 2 -d.) + VER_STR=$(dmsetup targets | grep crypt | cut -f 2 -dv) + [ -z "$VER_STR" ] && fail "Failed to parse dm-crypt version." + + VER_MAJ=$(echo $VER_STR | cut -f 1 -d.) + VER_MIN=$(echo $VER_STR | cut -f 2 -d.) # option supported in 1.11 - test $VER_MAJ -gt 1 && return 0 - test $VER_MIN -ge 11 && return 0 - return 1 + test $VER_MAJ -gt 1 && return 0 + test $VER_MIN -ge 11 && return 0 + return 1 } if [ $(id -u) != 0 ]; then echo "WARNING: You must be root to run this test, test skipped." - exit 0 + exit 77 fi -modprobe --dry-run scsi_debug || exit 0 +modprobe --dry-run scsi_debug || exit 77 modprobe dm-crypt >/dev/null 2>&1 if ! check_version ; then echo "Probably old kernel, test skipped." - exit 0 + exit 77 fi add_device dev_size_mb=16 sector_size=512 num_tgts=1 lbpu=1 @@ -62,8 +67,8 @@ add_device dev_size_mb=16 sector_size=512 num_tgts=1 lbpu=1 # for now just check that flag is enabled echo "[1] Allowing discards for LUKS device" -echo xxx | $CRYPTSETUP luksFormat $DEV -q -i1 || fail -echo xxx | $CRYPTSETUP luksOpen $DEV $DEV_NAME --allow-discards || fail +echo $PWD1 | $CRYPTSETUP luksFormat --type luks1 $DEV -q -i1 || fail +echo $PWD1 | $CRYPTSETUP luksOpen $DEV $DEV_NAME --allow-discards || fail $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail $CRYPTSETUP resize $DEV_NAME --size 100 || fail $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail @@ -71,7 +76,7 @@ dmsetup table $DEV_NAME | grep allow_discards >/dev/null || fail $CRYPTSETUP luksClose $DEV_NAME || fail echo "[2] Allowing discards for plain device" -echo xxx | $CRYPTSETUP create $DEV_NAME $DEV --hash sha1 --allow-discards || fail +echo $PWD1 | $CRYPTSETUP create -q $DEV_NAME $DEV --hash sha1 --allow-discards || fail $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail $CRYPTSETUP resize $DEV_NAME --size 100 || fail $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail