Include 'sys/sysmacros.h' for GCC-9
[platform/upstream/cryptsetup.git] / tests / discards-test
index 465f518..a8c4bc6 100755 (executable)
@@ -3,6 +3,7 @@
 CRYPTSETUP="../src/cryptsetup"
 DEV_NAME="discard-t3st"
 DEV=""
+PWD1="93R4P4pIqAH8"
 
 cleanup() {
        [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove $DEV_NAME
@@ -26,7 +27,7 @@ add_device() {
        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."
@@ -62,8 +63,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 $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 +72,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 $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