tisolated functions to speed up test environment - tomb - the crypto undertaker HTML git clone git://parazyd.org/tomb.git DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 3eff8aeebe96dc66cbef399e25bf29af6c90d7ce DIR parent 828579e10d7660155b6656f499e94119c9d8f6d9 HTML Author: Jaromil <jaromil@dyne.org> Date: Fri, 14 Nov 2014 17:43:53 +0100 isolated functions to speed up test environment Diffstat: M extras/test/runtests | 115 +++++++++++++++++++------------- 1 file changed, 69 insertions(+), 46 deletions(-) --- DIR diff --git a/extras/test/runtests b/extras/test/runtests t@@ -28,7 +28,7 @@ tt() { } # check for auxiliary programs -KDF=1 +KDF=0 STEGHIDE=1 RESIZER=1 command -v steghide > /dev/null || STEGHIDE=0 t@@ -44,39 +44,80 @@ tests=(dig forge lock badpass open close passwd chksum bind setkey) { test $STEGHIDE = 1 } && { tests+=(stgin stgout stgopen stgpipe stgimpl) } { test $QRENCODE = 1 } && { tests+=(qrenc) } -sudo rm -f /tmp/test.tomb{,.key} +notice "Loading test suite and wiping all test.tomb* in /tmp" +sudo rm -f /tmp/test.tomb{,.key,.new.key} -startloops=(`sudo losetup -a |cut -d: -f1`) +# functions that can be called singularly +test-tomb-create() { + notice "Testing creation: dig" + tt dig -s 20 /tmp/test.tomb + { test $? = 0 } && { results+=(dig SUCCESS) } -notice "Testing creation: dig" + notice "Testing creation: forge" -tt dig -s 20 /tmp/test.tomb + tt --ignore-swap --unsecure-dev-mode --tomb-pwd ${dummypass} --use-urandom forge /tmp/test.tomb.key -{ test $? = 0 } && { results+=(dig SUCCESS) } + { test $? = 0 } && { + results+=(forge SUCCESS) + # + say "Dump of clear key contents to examine them:" + print ${dummypass} \ + | gpg --batch --passphrase-fd 0 --no-tty --no-options -d /tmp/test.tomb.key \ + | hexdump -C + echo -- + } -notice "Testing creation: forge" + notice "Testing creation: lock" -tt --ignore-swap --unsecure-dev-mode --tomb-pwd ${dummypass} --use-urandom forge /tmp/test.tomb.key + tt --ignore-swap --unsecure-dev-mode --tomb-pwd ${dummypass} lock /tmp/test.tomb -k /tmp/test.tomb.key -{ test $? = 0 } && { - results+=(forge SUCCESS) - # - say "Dump of clear key contents to examine them:" - print ${dummypass} \ - | gpg --batch --passphrase-fd 0 --no-tty --no-options -d /tmp/test.tomb.key \ - | hexdump -C - echo -- + { test $? = 0 } && { results+=(lock SUCCESS) } } -notice "Testing creation: lock" +test-bind-hooks() { + notice "Testing bind hooks" + tt list test + [[ $? = 0 ]] || { + tt --ignore-swap --unsecure-dev-mode --tomb-pwd ${dummypass} \ + open /tmp/test.tomb -k /tmp/test.tomb.key } + rnd=$RANDOM + bindtest="dyne-tomb-bind-test-$rnd" + echo $rnd > /media/test.tomb/$bindtest + rm -f /media/test.tomb/bind-hooks + echo "$bindtest $bindtest" > /media/test.tomb/bind-hooks + touch $HOME/$bindtest + tt close test + tt -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypass} open /tmp/test.tomb + rnd2=`cat $HOME/$bindtest` + if [ "$rnd" = "$rnd2" ]; then + notice "Bind hook on file matches" + results+=(bind SUCCESS) + tt list test + else + error "Bind hook on file reports incongruence" + fi + rm -f "/media/test.tomb/$bindtest" + tt close test + # Remove test file in HOME + rm -f "$HOME/$bindtest" +} -tt --ignore-swap --unsecure-dev-mode --tomb-pwd ${dummypass} lock /tmp/test.tomb -k /tmp/test.tomb.key -{ test $? = 0 } && { results+=(lock SUCCESS) } +startloops=(`sudo losetup -a |cut -d: -f1`) + +[[ $1 = "source" ]] && { return 0 } + +[[ $1 = "" ]] || { + tt ${=@} + return $? +} + +# isolated function (also called with source) +test-tomb-create notice "Testing open with wrong password" t@@ -110,7 +151,7 @@ notice "Generating content for file integrity test" tt -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypassnew} open /tmp/test.tomb -${T} dig -s 10 /media/test.tomb/datacheck.raw +tt dig -s 10 /media/test.tomb/datacheck.raw crc="sha256 /media/test.tomb/datacheck.raw" echo "$crc" > /media/test.tomb/datacheck.sha t@@ -128,7 +169,7 @@ tt --unsecure-dev-mode close test notice "Testing contents integrity" -${T} -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypassnew} open /tmp/test.tomb +tt -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypassnew} open /tmp/test.tomb { test $? = 0 } && { t@@ -136,30 +177,11 @@ ${T} -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypassnew} open / { test "$crc" = "$crc2" } && { results+=(chksum SUCCESS) } + tt close test } - - -notice "Testing bind hooks" - -rnd=$RANDOM -bindtest="dyne-tomb-bind-test-$rnd" -echo $rnd > /media/test.tomb/$bindtest -echo "$bindtestfile $bindtest" > /media/test.tomb/bind-hooks -touch $HOME/$bindtest -tt close test -tt -k /tmp/test.tomb.key --unsecure-dev-mode --tomb-pwd ${dummypassnew} open /tmp/test.tomb -rnd2=`cat $HOME/$bindtest` -if [ "$rnd" = "$rnd2" ]; then - notice "Bind hook on file matches" - results+=(bind SUCCESS) - tt list test -else - error "Bind hook on file reports incongruence" -fi -tt close test -# Remove all test files in case some previous tests failed. -rm -f $HOME/dyne-tomb-bind-test-* +# isolated function +test-bind-hooks notice "Testing set key" t@@ -169,14 +191,15 @@ tt -k /tmp/test.tomb.new.key --force --unsecure-dev-mode --tomb-pwd ${dummypass} tt -k /tmp/test.tomb.new.key --unsecure-dev-mode --tomb-pwd ${dummypass} --tomb-old-pwd ${dummypassnew} setkey /tmp/test.tomb.key /tmp/test.tomb +tt -k /tmp/test.tomb.new.key --unsecure-dev-mode --tomb-pwd ${dummypass} open /tmp/test.tomb + if [ $? = 0 ]; then notice "Setkey succesfully swapped tomb key" results+=(setkey SUCCESS) - mv /tmp/test.tomb.new.key /tmp/test.tomb.key + mv /tmp/test.tomb.new.key /tmp/test.tomb.key + tt close test fi - - { test $KDF = 1 } && { notice "Testing KDF key"