Add integrity tests

This commit is contained in:
Alexandre Pujol 2017-05-01 23:02:49 +01:00
parent 045c55436f
commit 92a670efd8
No known key found for this signature in database
GPG Key ID: C5469996F0DF68EC
2 changed files with 28 additions and 0 deletions

View File

@ -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

View File

@ -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"
}