X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Fdiscards-test;h=870f74da90b823d418be22b26fa26398dbf8d81f;hb=6497abd1df88001eb1f45f7348534911b33d05b5;hp=8a838e60a653a220d52bf2a6621635cd83723f71;hpb=f7fc3bb4e50cce23dd95111b246b6e034537e2cf;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/tests/discards-test b/tests/discards-test index 8a838e6..870f74d 100755 --- a/tests/discards-test +++ b/tests/discards-test @@ -6,10 +6,13 @@ DEV_NAME="discard-t3st" DEV="" PWD1="93R4P4pIqAH8" +CRYPTSETUP_VALGRIND=../.libs/cryptsetup +CRYPTSETUP_LIB_VALGRIND=../.libs + cleanup() { [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME udevadm settle >/dev/null 2>&1 - rmmod scsi_debug 2>/dev/null + rmmod scsi_debug >/dev/null 2>&1 sleep 2 } @@ -21,8 +24,31 @@ fail() exit 100 } +skip() +{ + [ -n "$1" ] && echo "$1" + exit 77 +} + +function valgrind_setup() +{ + command -v valgrind >/dev/null || fail "Cannot find valgrind." + [ ! -f $CRYPTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable." + export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH" +} + +function valgrind_run() +{ + INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@" +} + add_device() { - modprobe scsi_debug $@ delay=0 + rmmod scsi_debug >/dev/null 2>&1 + if [ -d /sys/module/scsi_debug ] ; then + echo "Cannot use scsi_debug module (in use or compiled-in), test skipped." + exit 77 + fi + modprobe scsi_debug $@ delay=0 >/dev/null 2>&1 if [ $? -ne 0 ] ; then echo "This kernel seems to not support proper scsi_debug module, test skipped." exit 77 @@ -49,12 +75,13 @@ function check_version() return 1 } +[ ! -x "$CRYPTSETUP" ] && skip "Cannot find $CRYPTSETUP, test skipped." +[ -n "$VALG" ] && valgrind_setup && CRYPTSETUP=valgrind_run if [ $(id -u) != 0 ]; then echo "WARNING: You must be root to run this test, test skipped." exit 77 fi -modprobe --dry-run scsi_debug || exit 77 modprobe dm-crypt >/dev/null 2>&1 if ! check_version ; then echo "Probably old kernel, test skipped." @@ -76,7 +103,7 @@ dmsetup table $DEV_NAME | grep allow_discards >/dev/null || fail $CRYPTSETUP luksClose $DEV_NAME || fail echo "[2] Allowing discards for plain device" -echo $PWD1 | $CRYPTSETUP create -q $DEV_NAME $DEV --hash sha1 --allow-discards || fail +echo $PWD1 | $CRYPTSETUP create -q $DEV_NAME $DEV --hash sha256 --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