summaryrefslogtreecommitdiff
path: root/tests/password-hash-test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/password-hash-test')
-rwxr-xr-xtests/password-hash-test27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/password-hash-test b/tests/password-hash-test
index 0fb58b3..6e3c78c 100755
--- a/tests/password-hash-test
+++ b/tests/password-hash-test
@@ -9,6 +9,9 @@ KEY_FILE=keyfile
DEV2=$DEV_NAME"_x"
+CRYPTSETUP_VALGRIND=../.libs/cryptsetup
+CRYPTSETUP_LIB_VALGRIND=../.libs
+
dmremove() { # device
udevadm settle >/dev/null 2>&1
dmsetup remove --retry $1 >/dev/null 2>&1
@@ -23,12 +26,30 @@ cleanup() {
function fail()
{
- echo " $1 [FAILED]"
+ echo " $1 [FAILED]"
echo "FAILED backtrace:"
while caller $frame; do ((frame++)); done
cleanup 2
}
+skip()
+{
+ echo "TEST SKIPPED: $1"
+ cleanup 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} "$@"
+}
+
crypt_key() # hash keysize pwd/file name outkey [limit] [offset]
{
DEV2=$DEV_NAME"_x"
@@ -75,7 +96,7 @@ crypt_key() # hash keysize pwd/file name outkey [limit] [offset]
esac
# ignore these cases, not all libs/kernel supports it
- if [ "$1" != "sha1" -a "$1" != "sha256" ] || [ $2 -gt 256 ] ; then
+ if [ "$1" != "sha256" ] || [ $2 -gt 256 ] ; then
if [ $ret -ne 0 ] ; then
echo " [N/A] ($ret, SKIPPED)"
return
@@ -95,6 +116,8 @@ crypt_key() # hash keysize pwd/file name outkey [limit] [offset]
dmremove $DEV2
}
+[ ! -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