From 92a670efd88ab2100b1e842cd315f123e5e41877 Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Mon, 1 May 2017 23:02:49 +0100 Subject: [PATCH] Add integrity tests --- extras/test/50_integrity.sh | 20 ++++++++++++++++++++ extras/test/setup | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 extras/test/50_integrity.sh diff --git a/extras/test/50_integrity.sh b/extras/test/50_integrity.sh new file mode 100644 index 0000000..f97cd17 --- /dev/null +++ b/extras/test/50_integrity.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh + +export test_description="Testing file integrity" + +source ./setup + +test_export "test" # Using already generated tomb +test_expect_success 'Testing contents integrity' ' + tt_open --tomb-pwd $DUMMYPASS && + tomb_set_ownership "$MEDIA/$USER/$testname" && + tt dig -s 10 "$MEDIA/$USER/$testname/datacheck.raw" && + CRC1=$(sha256sum "$MEDIA/$USER/$testname/datacheck.raw") && + tt_close --unsafe && + tt_open --tomb-pwd $DUMMYPASS && + CRC2=$(sha256sum "$MEDIA/$USER/$testname/datacheck.raw") && + [[ "$CRC1" == "$CRC2" ]] && + tt_close + ' + +test_done diff --git a/extras/test/setup b/extras/test/setup index 32fa76d..782b572 100644 --- a/extras/test/setup +++ b/extras/test/setup @@ -103,3 +103,11 @@ tt_forge() { tt forge "$tomb_key" --ignore-swap --unsafe --use-urandom "${@}"; } tt_lock() { tt lock "$tomb" -k "$tomb_key" --ignore-swap --unsafe "${@}"; } tt_open() { tt open "$tomb" -k "$tomb_key" --ignore-swap --unsafe "${@}"; } tt_close() { tt close "$testname" "${@}"; } + +tomb_set_ownership() { + local dir="$1" + local uid=$(id -u $USERNAME) + local gid=$(id -g $USERNAME) + sudo chown -R "$uid:$gid" "$dir" + sudo chmod 0711 "$dir" +}