mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-23 08:40:07 +01:00
Fix compat interactive test to run with valgrind too.
This commit is contained in:
@@ -112,6 +112,7 @@ compatimage.img:
|
|||||||
@xz -k -d compatimage.img.xz
|
@xz -k -d compatimage.img.xz
|
||||||
|
|
||||||
valgrind-check: api-test api-test-2 differ
|
valgrind-check: api-test api-test-2 differ
|
||||||
|
@VALG=1 ./compat-test
|
||||||
@VALG=1 ./compat-test2
|
@VALG=1 ./compat-test2
|
||||||
@VALG=1 ./luks2-validation-test
|
@VALG=1 ./luks2-validation-test
|
||||||
@VALG=1 ./verity-compat-test
|
@VALG=1 ./verity-compat-test
|
||||||
@@ -120,6 +121,5 @@ valgrind-check: api-test api-test-2 differ
|
|||||||
@INFOSTRING="api-test-002" ./valg-api.sh ./api-test-2
|
@INFOSTRING="api-test-002" ./valg-api.sh ./api-test-2
|
||||||
@VALG=1 ./luks2-reencryption-test
|
@VALG=1 ./luks2-reencryption-test
|
||||||
@VALG=1 ./bitlk-compat-test
|
@VALG=1 ./bitlk-compat-test
|
||||||
@VALG=1 ./compat-test
|
|
||||||
|
|
||||||
.PHONY: valgrind-check
|
.PHONY: valgrind-check
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
PS4='$LINENO:'
|
PS4='$LINENO:'
|
||||||
[ -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".."
|
[ -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".."
|
||||||
CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup
|
CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup
|
||||||
|
CRYPTSETUP_RAW=$CRYPTSETUP
|
||||||
|
|
||||||
CRYPTSETUP_VALGRIND=../.libs/cryptsetup
|
CRYPTSETUP_VALGRIND=../.libs/cryptsetup
|
||||||
CRYPTSETUP_LIB_VALGRIND=../.libs
|
CRYPTSETUP_LIB_VALGRIND=../.libs
|
||||||
@@ -189,19 +190,28 @@ function add_scsi_device() {
|
|||||||
|
|
||||||
function valgrind_setup()
|
function valgrind_setup()
|
||||||
{
|
{
|
||||||
|
[ -n "$VALG" ] || return
|
||||||
which valgrind >/dev/null 2>&1 || fail "Cannot find valgrind."
|
which valgrind >/dev/null 2>&1 || fail "Cannot find valgrind."
|
||||||
[ ! -f $CRYPTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable."
|
[ ! -f $CRYPTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable."
|
||||||
export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
|
||||||
|
CRYPTSETUP=valgrind_run
|
||||||
|
CRYPTSETUP_RAW="./valg.sh ${CRYPTSETUP_VALGRIND}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function valgrind_run()
|
function valgrind_run()
|
||||||
{
|
{
|
||||||
INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@"
|
export INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}"
|
||||||
|
$CRYPTSETUP_RAW "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function expect_run()
|
||||||
|
{
|
||||||
|
export INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}"
|
||||||
|
expect "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
export LANG=C
|
export LANG=C
|
||||||
|
valgrind_setup
|
||||||
[ -n "$VALG" ] && valgrind_setup && CRYPTSETUP=valgrind_run
|
|
||||||
|
|
||||||
# LUKS non-root-tests
|
# LUKS non-root-tests
|
||||||
if [ $(id -u) != 0 ]; then
|
if [ $(id -u) != 0 ]; then
|
||||||
@@ -801,10 +811,10 @@ which expect >/dev/null 2>&1 || skip "WARNING: expect tool missing, interactive
|
|||||||
prepare "[32] Interactive password retry from terminal." new
|
prepare "[32] Interactive password retry from terminal." new
|
||||||
EXPECT_DEV=$(losetup $LOOPDEV | sed -e "s/.*(\(.*\))/\1/")
|
EXPECT_DEV=$(losetup $LOOPDEV | sed -e "s/.*(\(.*\))/\1/")
|
||||||
|
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksOpen -v -T 2 $LOOPDEV $DEV_NAME
|
eval spawn $CRYPTSETUP_RAW luksOpen -v -T 2 $LOOPDEV $DEV_NAME
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0 x\n"
|
send "$PWD0 x\n"
|
||||||
@@ -822,10 +832,10 @@ check_exists
|
|||||||
$CRYPTSETUP -q luksClose $DEV_NAME || fail
|
$CRYPTSETUP -q luksClose $DEV_NAME || fail
|
||||||
|
|
||||||
prepare "[33] Interactive unsuccessful password retry from terminal." new
|
prepare "[33] Interactive unsuccessful password retry from terminal." new
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksOpen -v -T 2 $LOOPDEV $DEV_NAME
|
eval spawn $CRYPTSETUP_RAW luksOpen -v -T 2 $LOOPDEV $DEV_NAME
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0 x\n"
|
send "$PWD0 x\n"
|
||||||
@@ -840,10 +850,10 @@ EOF
|
|||||||
[ $? -eq 0 ] || fail "Expect script failed."
|
[ $? -eq 0 ] || fail "Expect script failed."
|
||||||
|
|
||||||
prepare "[34] Interactive kill of last key slot." new
|
prepare "[34] Interactive kill of last key slot." new
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 0
|
eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 0
|
||||||
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
||||||
send "YES\n"
|
send "YES\n"
|
||||||
expect timeout abort "Enter any remaining passphrase:"
|
expect timeout abort "Enter any remaining passphrase:"
|
||||||
@@ -851,7 +861,7 @@ sleep 0.1
|
|||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 0
|
eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 0
|
||||||
expect timeout abort "Keyslot 0 is not active."
|
expect timeout abort "Keyslot 0 is not active."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
exit
|
exit
|
||||||
@@ -859,10 +869,10 @@ EOF
|
|||||||
[ $? -eq 0 ] || fail "Expect script failed."
|
[ $? -eq 0 ] || fail "Expect script failed."
|
||||||
|
|
||||||
prepare "[35] Interactive format of device." wipe
|
prepare "[35] Interactive format of device." wipe
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT -v $LOOPDEV
|
eval spawn $CRYPTSETUP_RAW luksFormat --type luks1 $FAST_PBKDF_OPT -v $LOOPDEV
|
||||||
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
||||||
send "YES\n"
|
send "YES\n"
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
@@ -873,7 +883,7 @@ sleep 0.1
|
|||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksOpen -v $LOOPDEV --test-passphrase
|
eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
@@ -884,15 +894,15 @@ EOF
|
|||||||
[ $? -eq 0 ] || fail "Expect script failed."
|
[ $? -eq 0 ] || fail "Expect script failed."
|
||||||
|
|
||||||
prepare "[36] Interactive unsuccessful format of device." new
|
prepare "[36] Interactive unsuccessful format of device." new
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP erase -v $LOOPDEV
|
eval spawn $CRYPTSETUP_RAW erase -v $LOOPDEV
|
||||||
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
||||||
send "YES\n"
|
send "YES\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT -v $LOOPDEV
|
eval spawn $CRYPTSETUP_RAW luksFormat --type luks1 $FAST_PBKDF_OPT -v $LOOPDEV
|
||||||
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
|
||||||
send "YES\n"
|
send "YES\n"
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
@@ -903,7 +913,7 @@ sleep 0.1
|
|||||||
send "$PWD0 x\n"
|
send "$PWD0 x\n"
|
||||||
expect timeout abort "Passphrases do not match."
|
expect timeout abort "Passphrases do not match."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksOpen -v $LOOPDEV -T 1 --test-passphrase
|
eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV -T 1 --test-passphrase
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
@@ -914,10 +924,10 @@ EOF
|
|||||||
[ $? -eq 0 ] || fail "Expect script failed."
|
[ $? -eq 0 ] || fail "Expect script failed."
|
||||||
|
|
||||||
prepare "[37] Interactive add key." new
|
prepare "[37] Interactive add key." new
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksAddKey -S 2 $FAST_PBKDF_OPT -v $LOOPDEV
|
eval spawn $CRYPTSETUP_RAW luksAddKey -S 2 $FAST_PBKDF_OPT -v $LOOPDEV
|
||||||
expect timeout abort "Enter any existing passphrase:"
|
expect timeout abort "Enter any existing passphrase:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
@@ -929,16 +939,16 @@ sleep 0.1
|
|||||||
send "$PWD1\n"
|
send "$PWD1\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksOpen $FAST_PBKDF_OPT -v $LOOPDEV --test-passphrase
|
eval spawn $CRYPTSETUP_RAW luksOpen $FAST_PBKDF_OPT -v $LOOPDEV --test-passphrase
|
||||||
expect timeout abort "Enter passphrase"
|
expect timeout abort "Enter passphrase"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD1\n"
|
send "$PWD1\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 1
|
eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 1
|
||||||
expect timeout abort "Keyslot 1 is not active."
|
expect timeout abort "Keyslot 1 is not active."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 2
|
eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 2
|
||||||
expect timeout abort "Enter any remaining passphrase:"
|
expect timeout abort "Enter any remaining passphrase:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
@@ -949,10 +959,10 @@ EOF
|
|||||||
[ $? -eq 0 ] || fail "Expect script failed."
|
[ $? -eq 0 ] || fail "Expect script failed."
|
||||||
|
|
||||||
prepare "[38] Interactive change key." new
|
prepare "[38] Interactive change key." new
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT -v $LOOPDEV
|
eval spawn $CRYPTSETUP_RAW luksChangeKey $FAST_PBKDF_OPT -v $LOOPDEV
|
||||||
expect timeout abort "Enter passphrase to be changed:"
|
expect timeout abort "Enter passphrase to be changed:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
@@ -964,7 +974,7 @@ sleep 0.1
|
|||||||
send "$PWD1\n"
|
send "$PWD1\n"
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksOpen -v $LOOPDEV --test-passphrase
|
eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD1\n"
|
send "$PWD1\n"
|
||||||
@@ -976,13 +986,13 @@ EOF
|
|||||||
|
|
||||||
prepare "[39] Interactive suspend and resume." new
|
prepare "[39] Interactive suspend and resume." new
|
||||||
echo $PWD0 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || fail
|
echo $PWD0 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || fail
|
||||||
expect - >/dev/null <<EOF
|
expect_run - >/dev/null <<EOF
|
||||||
proc abort {} { send_error "Timeout. "; exit 2 }
|
proc abort {} { send_error "Timeout. "; exit 2 }
|
||||||
set timeout 10
|
set timeout 10
|
||||||
eval spawn $CRYPTSETUP luksSuspend -v $DEV_NAME
|
eval spawn $CRYPTSETUP_RAW luksSuspend -v $DEV_NAME
|
||||||
expect timeout abort "Command successful."
|
expect timeout abort "Command successful."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksResume -v -T 3 $DEV_NAME
|
eval spawn $CRYPTSETUP_RAW luksResume -v -T 3 $DEV_NAME
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0 x\n"
|
send "$PWD0 x\n"
|
||||||
@@ -996,7 +1006,7 @@ sleep 0.1
|
|||||||
send "$PWD0 y\n"
|
send "$PWD0 y\n"
|
||||||
expect timeout abort "No key available with this passphrase."
|
expect timeout abort "No key available with this passphrase."
|
||||||
expect timeout abort eof
|
expect timeout abort eof
|
||||||
eval spawn $CRYPTSETUP luksResume -v $DEV_NAME
|
eval spawn $CRYPTSETUP_RAW luksResume -v $DEV_NAME
|
||||||
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
expect timeout abort "Enter passphrase for $EXPECT_DEV:"
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
send "$PWD0\n"
|
send "$PWD0\n"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ MALLOC="--malloc-fill=aa"
|
|||||||
FREE="--free-fill=21"
|
FREE="--free-fill=21"
|
||||||
STACK="--max-stackframe=300000"
|
STACK="--max-stackframe=300000"
|
||||||
EXTRAS="--read-var-info=yes --show-reachable=yes"
|
EXTRAS="--read-var-info=yes --show-reachable=yes"
|
||||||
LOGFILE="--log-file=./valglog.$(date +%s)_${INFOSTRING}"
|
LOGFILE="--log-file=./valglog.$(date +%H:%M:%S:%N)_${INFOSTRING}"
|
||||||
LEAKCHECK="--leak-check=full --track-origins=yes"
|
LEAKCHECK="--leak-check=full --track-origins=yes"
|
||||||
|
|
||||||
exec valgrind $SUP $GETSUP $CHILD $MALLOC $FREE $STACK $EXTRAS $LOGFILE $LEAKCHECK "$@"
|
exec valgrind $SUP $GETSUP $CHILD $MALLOC $FREE $STACK $EXTRAS $LOGFILE $LEAKCHECK "$@"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ MALLOC="--malloc-fill=aa"
|
|||||||
FREE="--free-fill=21"
|
FREE="--free-fill=21"
|
||||||
STACK="--max-stackframe=2000000"
|
STACK="--max-stackframe=2000000"
|
||||||
EXTRAS="--read-var-info=yes --show-reachable=yes"
|
EXTRAS="--read-var-info=yes --show-reachable=yes"
|
||||||
LOGFILE="--log-file=./valglog.$(date +%s)_${INFOSTRING}"
|
LOGFILE="--log-file=./valglog.$(date +%H:%M:%S:%N)_${INFOSTRING}"
|
||||||
LEAKCHECK="--leak-check=full --track-origins=yes"
|
LEAKCHECK="--leak-check=full --track-origins=yes"
|
||||||
|
|
||||||
exec valgrind $SUP $GETSUP $CHILD $MALLOC $FREE $STACK $EXTRAS $LOGFILE $LEAKCHECK "$@"
|
exec valgrind $SUP $GETSUP $CHILD $MALLOC $FREE $STACK $EXTRAS $LOGFILE $LEAKCHECK "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user