2016-07-16 18:08:01 +02:00
|
|
|
#!/bin/bash -eu
|
2016-01-23 19:33:03 +01:00
|
|
|
|
2016-01-23 20:17:34 +01:00
|
|
|
# Run the set of "canonical" benchmarks that are shown on
|
|
|
|
# https://nuetzlich.net/gocryptfs/comparison/
|
|
|
|
|
2016-07-16 18:08:01 +02:00
|
|
|
cd "$(dirname "$0")"
|
2016-11-23 21:54:55 +01:00
|
|
|
MYNAME=$(basename "$0")
|
2017-02-15 23:02:01 +01:00
|
|
|
source tests/fuse-unmount.bash
|
2016-01-23 19:33:03 +01:00
|
|
|
|
2016-11-23 21:54:55 +01:00
|
|
|
function usage {
|
2017-06-11 12:05:59 +02:00
|
|
|
echo "Usage: $MYNAME [-encfs] [-openssl=true] [-openssl=false] [-dd] [DIR]"
|
2016-11-23 21:54:55 +01:00
|
|
|
}
|
|
|
|
|
2016-12-13 22:13:54 +01:00
|
|
|
OPT_ENCFS=0
|
2019-03-31 21:19:07 +02:00
|
|
|
OPT_LOOPBACK=0
|
2016-12-13 22:13:54 +01:00
|
|
|
OPT_OPENSSL=""
|
|
|
|
OPT_DIR=""
|
2017-06-11 12:05:59 +02:00
|
|
|
DD_ONLY=""
|
2016-12-13 22:13:54 +01:00
|
|
|
|
|
|
|
while [[ $# -gt 0 ]] ; do
|
|
|
|
case $1 in
|
|
|
|
-h)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
-encfs)
|
|
|
|
OPT_ENCFS=1
|
|
|
|
;;
|
|
|
|
-openssl=true)
|
|
|
|
OPT_OPENSSL="-openssl=true"
|
|
|
|
;;
|
|
|
|
-openssl=false)
|
|
|
|
OPT_OPENSSL="-openssl=false"
|
|
|
|
;;
|
2017-06-11 12:05:59 +02:00
|
|
|
-dd)
|
|
|
|
DD_ONLY=1
|
|
|
|
;;
|
2019-03-31 21:19:07 +02:00
|
|
|
-loopback)
|
|
|
|
OPT_LOOPBACK=1
|
|
|
|
;;
|
2016-12-13 22:13:54 +01:00
|
|
|
-*)
|
|
|
|
echo "Invalid option: $1"
|
|
|
|
usage
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [[ ! -z $OPT_DIR ]] ; then
|
|
|
|
echo "Duplicate DIR argument: $1"
|
|
|
|
usage
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
OPT_DIR=$1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-11-23 21:54:55 +01:00
|
|
|
|
2016-12-13 22:13:54 +01:00
|
|
|
if [[ -z $OPT_DIR ]] ; then
|
|
|
|
OPT_DIR=/tmp
|
2016-11-23 21:54:55 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Create directories
|
2016-12-13 22:13:54 +01:00
|
|
|
CRYPT=$(mktemp -d "$OPT_DIR/$MYNAME.XXX")
|
2016-07-16 18:08:01 +02:00
|
|
|
MNT=$CRYPT.mnt
|
|
|
|
mkdir $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
|
2016-07-16 18:08:01 +02:00
|
|
|
# Mount
|
2016-12-13 22:13:54 +01:00
|
|
|
if [[ $OPT_ENCFS -eq 1 ]]; then
|
2016-12-13 22:16:21 +01:00
|
|
|
if [[ ! -z $OPT_OPENSSL ]] ; then
|
|
|
|
echo "The option $OPT_OPENSSL only works with gocryptfs"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-02-06 23:01:56 +01:00
|
|
|
echo -n "Testing EncFS at $CRYPT: "
|
|
|
|
encfs --version
|
2019-09-21 19:25:50 +02:00
|
|
|
encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
|
2019-03-31 21:19:07 +02:00
|
|
|
elif [[ $OPT_LOOPBACK -eq 1 ]]; then
|
|
|
|
echo "Testing go-fuse loopback"
|
|
|
|
$HOME/go/src/github.com/hanwen/go-fuse/example/loopback/loopback $MNT $CRYPT &
|
|
|
|
sleep 0.5
|
2016-07-11 22:10:41 +02:00
|
|
|
else
|
2018-02-06 23:01:56 +01:00
|
|
|
echo -n "Testing gocryptfs at $CRYPT: "
|
|
|
|
gocryptfs -version
|
2016-07-16 18:08:01 +02:00
|
|
|
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
|
2016-12-13 22:13:54 +01:00
|
|
|
gocryptfs -q -extpass="echo test" $OPT_OPENSSL $CRYPT $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
fi
|
2016-07-16 18:08:01 +02:00
|
|
|
|
2019-03-31 21:19:07 +02:00
|
|
|
# Make sure we have actually mounted something
|
|
|
|
if ! mountpoint $MNT ; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-07-16 18:08:01 +02:00
|
|
|
# Cleanup trap
|
2017-02-15 23:02:01 +01:00
|
|
|
trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT
|
2016-01-23 19:33:03 +01:00
|
|
|
|
|
|
|
# Benchmarks
|
2017-06-11 12:05:59 +02:00
|
|
|
if [[ $DD_ONLY -eq 1 ]]; then
|
|
|
|
echo -n "WRITE: "
|
2019-03-31 21:19:07 +02:00
|
|
|
dd if=/dev/zero of=$MNT/zero bs=131072 count=20000 2>&1 | tail -n 1
|
2017-06-11 12:05:59 +02:00
|
|
|
rm $MNT/zero
|
|
|
|
else
|
|
|
|
./tests/canonical-benchmarks.bash $MNT
|
|
|
|
fi
|
2016-01-23 19:33:03 +01:00
|
|
|
|