"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/align-test2" between
cryptsetup-2.3.6.tar.xz and cryptsetup-2.4.0.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

align-test2  (cryptsetup-2.3.6.tar.xz):align-test2  (cryptsetup-2.4.0.tar.xz)
skipping to change at line 23 skipping to change at line 23
cleanup() { cleanup() {
udevadm settle >/dev/null 2>&1 udevadm settle >/dev/null 2>&1
if [ -d "$MNT_DIR" ] ; then if [ -d "$MNT_DIR" ] ; then
umount -f $MNT_DIR 2>/dev/null umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null rmdir $MNT_DIR 2>/dev/null
fi fi
[ -b /dev/mapper/$DEV_STACKED ] && dmsetup remove --retry $DEV_STACKED >/ dev/null 2>&1 [ -b /dev/mapper/$DEV_STACKED ] && dmsetup remove --retry $DEV_STACKED >/ dev/null 2>&1
[ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/nu ll 2>&1 [ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/nu ll 2>&1
# FIXME scsi_debug sometimes in-use here # FIXME scsi_debug sometimes in-use here
sleep 1 sleep 1
rmmod scsi_debug 2>/dev/null rmmod scsi_debug >/dev/null 2>&1
sleep 1 sleep 1
} }
fail() fail()
{ {
if [ -n "$1" ] ; then echo "FAIL $1" ; fi if [ -n "$1" ] ; then echo "FAIL $1" ; fi
echo "FAILED backtrace:" echo "FAILED backtrace:"
while caller $frame; do ((frame++)); done while caller $frame; do ((frame++)); done
cleanup cleanup
exit 100 exit 100
} }
skip() skip()
{ {
echo "TEST SKIPPED: $1" echo "TEST SKIPPED: $1"
cleanup cleanup
exit 0 exit 77
} }
function dm_crypt_features() function dm_crypt_features()
{ {
VER_STR=$(dmsetup targets | grep crypt | cut -f2 -dv) VER_STR=$(dmsetup targets | grep crypt | cut -f2 -dv)
[ -z "$VER_STR" ] && fail "Failed to parse dm-crypt version." [ -z "$VER_STR" ] && fail "Failed to parse dm-crypt version."
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.) VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.) VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
VER_PTC=$(echo $VER_STR | cut -f 3 -d.) VER_PTC=$(echo $VER_STR | cut -f 3 -d.)
skipping to change at line 67 skipping to change at line 67
} }
[ $VER_MIN -lt 14 ] && return [ $VER_MIN -lt 14 ] && return
DM_PERF_CPU=1 DM_PERF_CPU=1
if [ $VER_MIN -ge 17 -o \( $VER_MIN -eq 14 -a $VER_PTC -ge 5 \) ]; then if [ $VER_MIN -ge 17 -o \( $VER_MIN -eq 14 -a $VER_PTC -ge 5 \) ]; then
DM_SECTOR_SIZE=1 DM_SECTOR_SIZE=1
fi fi
} }
add_device() { add_device() {
modprobe scsi_debug $@ delay=0 modprobe scsi_debug $@ delay=0 >/dev/null 2>&1
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "This kernel seems to not support proper scsi_debug module, test skipped." echo "This kernel seems to not support proper scsi_debug module, test skipped."
exit 77 exit 77
fi fi
sleep 2 sleep 2
DEV=$(grep -l -e scsi_debug /sys/block/*/device/model | cut -f4 -d /) DEV=$(grep -l -e scsi_debug /sys/block/*/device/model | cut -f4 -d /)
if [ ! -e /sys/block/$DEV/alignment_offset ] ; then if [ ! -e /sys/block/$DEV/alignment_offset ] ; then
echo "This kernel seems to not support topology info, test skippe d." echo "This kernel seems to not support topology info, test skippe d."
skipping to change at line 115 skipping to change at line 115
echo -n "Formatting using forced sector alignment $2$_smsg..." echo -n "Formatting using forced sector alignment $2$_smsg..."
echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --align-payload=$2 --sector-size $_sec_size >/dev/nu ll || fail echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q -c aes-cbc-essiv:sha256 --align-payload=$2 --sector-size $_sec_size >/dev/nu ll || fail
fi fi
# check the device can be activated # check the device can be activated
if [ -n "$DM_SECTOR_SIZE" ] ; then if [ -n "$DM_SECTOR_SIZE" ] ; then
echo $PWD1 | $CRYPTSETUP luksOpen $DEV $DEV_NAME || fail echo $PWD1 | $CRYPTSETUP luksOpen $DEV $DEV_NAME || fail
$CRYPTSETUP close $DEV_NAME || fail $CRYPTSETUP close $DEV_NAME || fail
fi fi
ALIGN=$($CRYPTSETUP luksDump $DEV | tee /tmp/last_dump | grep -A1 "0: cr ypt" | grep "offset:" | cut -d ' ' -f2) ALIGN=$($CRYPTSETUP luksDump $DEV | grep -A1 "0: crypt" | grep "offset:" | cut -d ' ' -f2)
# echo "ALIGN = $ALIGN" # echo "ALIGN = $ALIGN"
[ -z "$ALIGN" ] && fail [ -z "$ALIGN" ] && fail
ALIGN=$((ALIGN/512)) ALIGN=$((ALIGN/512))
[ $ALIGN -ne $_exp ] && fail "Expected alignment differs: expected $_exp != detected $ALIGN" [ $ALIGN -ne $_exp ] && fail "Expected alignment differs: expected $_exp != detected $ALIGN"
# test some operation, just in case # test some operation, just in case
echo -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $DEV $FAST_PBKDF --key-sl ot 1 echo -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $DEV $FAST_PBKDF --key-sl ot 1
[ $? -ne 0 ] && fail "Keyslot add failed." [ $? -ne 0 ] && fail "Keyslot add failed."
skipping to change at line 164 skipping to change at line 164
echo "PASSED" echo "PASSED"
} }
if [ $(id -u) != 0 ]; then if [ $(id -u) != 0 ]; then
echo "WARNING: You must be root to run this test, test skipped." echo "WARNING: You must be root to run this test, test skipped."
exit 77 exit 77
fi fi
dm_crypt_features dm_crypt_features
modprobe --dry-run scsi_debug || exit 77 modprobe --dry-run scsi_debug >/dev/null 2>&1 || skip "This kernel seems to not support proper scsi_debug module, test skipped."
cleanup cleanup
if [ -d /sys/module/scsi_debug ] ; then
echo "Cannot use scsi_debug module (in use or compiled-in), test skipped.
"
exit 77
fi
add_device dev_size_mb=32 add_device dev_size_mb=32
echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q >/dev/null || fail echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $DEV -q >/dev/null || fail
EXPCT=$($CRYPTSETUP luksDump $DEV | grep "offset: " | cut -f 2 -d ' ') EXPCT=$($CRYPTSETUP luksDump $DEV | grep "offset: " | cut -f 2 -d ' ')
test "$EXPCT" -gt 512 || fail test "$EXPCT" -gt 512 || fail
EXPCT=$((EXPCT/512)) EXPCT=$((EXPCT/512))
echo "Default alignment detected: $EXPCT sectors" echo "Default alignment detected: $EXPCT sectors"
cleanup cleanup
echo "# Create desktop-class 4K drive" echo "# Create desktop-class 4K drive"
skipping to change at line 359 skipping to change at line 363
format $EXPCT $EXPCT s1024 format $EXPCT $EXPCT s1024
format $EXPCT $EXPCT s2048 format $EXPCT $EXPCT s2048
format $EXPCT $EXPCT s4096 format $EXPCT $EXPCT s4096
cleanup cleanup
echo "# Create enterprise-class 4K drive with fs and LUKS images." echo "# Create enterprise-class 4K drive with fs and LUKS images."
# loop device here presents 512 block but images have 4k block # loop device here presents 512 block but images have 4k block
# cryptsetup should properly use 4k block on direct-io # cryptsetup should properly use 4k block on direct-io
add_device dev_size_mb=32 sector_size=4096 physblk_exp=0 num_tgts=1 opt_blks=64 add_device dev_size_mb=32 sector_size=4096 physblk_exp=0 num_tgts=1 opt_blks=64
for file in $(ls img_fs_*.img.xz) ; do for file in $(ls img_fs_*.img.xz) ; do
echo "Format using fs image $file." echo "Format using fs image $file."
xz -d -c $file | dd of=$DEV bs=1M 2>/dev/null || fail "bad image" xz -d -c $file | dd of=$DEV bs=1M 2>/dev/null || fail "bad image"
[ ! -d $MNT_DIR ] && mkdir $MNT_DIR [ ! -d $MNT_DIR ] && mkdir $MNT_DIR
mount $DEV $MNT_DIR || skip "Mounting image is not available." mount $DEV $MNT_DIR || skip "Mounting image is not available."
echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luks.i echo $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luk
mg --offset 8192 || fail s.img --offset 8192 || fail
echo $PWD2 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luks.i echo $PWD2 | $CRYPTSETUP luksFormat $FAST_PBKDF --type luks2 $MNT_DIR/luk
mg --header $MNT_DIR/luks_header.img || fail s.img --header $MNT_DIR/luks_header.img || fail
umount $MNT_DIR umount $MNT_DIR
done done
cleanup cleanup
 End of changes. 7 change blocks. 
14 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)