Update pl.po.
[platform/upstream/cryptsetup.git] / tests / verity-compat-test
index b8156d7..b39dcf8 100755 (executable)
@@ -11,7 +11,6 @@ function remove_mapping()
 {
        [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove $DEV_NAME
        [ ! -z "$LOOPDEV1" ] && losetup -d $LOOPDEV1 >/dev/null 2>&1
-       [ ! -z "$LOOPDEV2" ] && losetup -d $LOOPDEV2 >/dev/null 2>&1
        rm -f $IMG $IMG_HASH $DEV_OUT >/dev/null 2>&1
        LOOPDEV1=""
        LOOPDEV2=""
@@ -42,17 +41,13 @@ function prepare() # $1 dev1_siz [$2 dev2_size]
        losetup $LOOPDEV1 $IMG
 
        [ -z "$2" ] && return
-       dd if=/dev/zero of=$IMG_HASH bs=1k count=$2 >/dev/null 2>&1
-       LOOPDEV2=$(losetup -f 2>/dev/null)
-       [ -z "$LOOPDEV2" ] && fail "No free loop device"
-       losetup $LOOPDEV2 $IMG_HASH
+       LOOPDEV2=$IMG_HASH
 }
 
 function wipe()
 {
        dd if=/dev/zero of=$LOOPDEV1 bs=256k >/dev/null 2>&1
-       dd if=/dev/zero of=$LOOPDEV2 bs=256k >/dev/null 2>&1
-       rm -f $DEV_OUT >/dev/null 2>&1
+       rm -f $IMG_HASH $DEV_OUT >/dev/null 2>&1
 }
 
 function check_exists()
@@ -70,9 +65,9 @@ function compare_out() # $1 what, $2 expected
 function check_root_hash() # $1 size, $2 hash, $3 salt, $4 version, $5 hash, [$6 offset]
 {
        if [ -z "$LOOPDEV2" ] ; then
-               BLOCKS=$(($6 * 512 / $1))
+               BLOCKS=$(($6 / $1))
                DEV_PARAMS="$LOOPDEV1 $LOOPDEV1 \
-                          --hash-start $6 \
+                          --hash-offset $6 \
                           --data-blocks=$BLOCKS --debug"
        else
                DEV_PARAMS="$LOOPDEV1 $LOOPDEV2"
@@ -111,14 +106,14 @@ function check_root_hash() # $1 size, $2 hash, $3 salt, $4 version, $5 hash, [$6
 
        case $fail in
        data)
-               dd if=/dev/urandom of=$LOOPDEV1 bs=1 seek=3456 count=1 2>/dev/null
+               dd if=/dev/urandom of=$LOOPDEV1 bs=1 seek=3456 count=8 conv=notrunc 2>/dev/null
                TXT="data_dev"
                ;;
        hash)
                if [ -z "$LOOPDEV2" ] ; then
-                       dd if=/dev/urandom of=$LOOPDEV1 bs=1 seek=$((8193 + $4)) count=1 2>/dev/null
+                       dd if=/dev/urandom of=$LOOPDEV1 bs=1 seek=$((8193 + $4)) count=8 conv=notrunc 2>/dev/null
                else
-                       dd if=/dev/urandom of=$LOOPDEV2 bs=1 seek=8193 count=1 2>/dev/null
+                       dd if=/dev/urandom of=$LOOPDEV2 bs=1 seek=8193 count=8 conv=notrunc 2>/dev/null
                fi
                 TXT="hash_dev"
                ;;
@@ -153,6 +148,7 @@ function valgrind_run()
 [ ! -x "$VERITYSETUP" ] && skip "Cannot find $VERITYSETUP, test skipped."
 
 [ -n "$VALG" ] && valgrind_setup && VERITYSETUP=valgrind_run
+modprobe dm-verity >/dev/null 2>&1
 
 # VERITYSETUP tests
 
@@ -173,16 +169,16 @@ check_root_hash 1024 73509e8e868be6b8ac939817a98a3d35121413b2 dadada 1 sha1
 
 echo "Verity tests [one device offset]"
 prepare $((8192 + 1024))
-check_root_hash  512 9de18652fe74edfb9b805aaed72ae2aa48f94333f1ba5c452ac33b1c39325174 $SALT 1 sha256 16384
-check_root_hash 1024 54d92778750495d1f80832b486ebd007617d746271511bbf0e295e143da2b3df $SALT 1 sha256 16384
-check_root_hash 4096 e522df0f97da4febb882ac40f30b37dc0b444bf6df418929463fa25280f09d5c $SALT 1 sha256 16384
+check_root_hash  512 9de18652fe74edfb9b805aaed72ae2aa48f94333f1ba5c452ac33b1c39325174 $SALT 1 sha256 8388608
+check_root_hash 1024 54d92778750495d1f80832b486ebd007617d746271511bbf0e295e143da2b3df $SALT 1 sha256 8388608
+check_root_hash 4096 e522df0f97da4febb882ac40f30b37dc0b444bf6df418929463fa25280f09d5c $SALT 1 sha256 8388608
 # version 0
-check_root_hash 4096 cbbf4ebd004ef65e29b935bb635a39cf754d677f3fa10b0126da725bbdf10f7d $SALT 0 sha256 16384
+check_root_hash 4096 cbbf4ebd004ef65e29b935bb635a39cf754d677f3fa10b0126da725bbdf10f7d $SALT 0 sha256 8388608
 # no salt
-check_root_hash 4096 ef29c902d87350f1da4bfa536e16cebc162a909bf89abe448b81ec500d4fb9bf - 1 sha256 16384
+check_root_hash 4096 ef29c902d87350f1da4bfa536e16cebc162a909bf89abe448b81ec500d4fb9bf - 1 sha256 8388608
 # sha1
-check_root_hash 1024 d0e9163ca8844aaa2e88fe5265a8c5d9ee494a99 $SALT 1 sha1 16384
-check_root_hash 1024 73509e8e868be6b8ac939817a98a3d35121413b2 dadada 1 sha1 16384
+check_root_hash 1024 d0e9163ca8844aaa2e88fe5265a8c5d9ee494a99 $SALT 1 sha1 8388608
+check_root_hash 1024 73509e8e868be6b8ac939817a98a3d35121413b2 dadada 1 sha1 8388608
 
 remove_mapping
 exit 0