blob: 4949831561808d7c89009b373e2f0555e51659f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#!/bin/bash -eu
# Run the set of "canonical" benchmarks that are shown on
# https://nuetzlich.net/gocryptfs/comparison/
cd "$(dirname "$0")"
MYNAME=$(basename "$0")
source tests/fuse-unmount.bash
function usage {
echo "Usage: $MYNAME [-encfs] [-openssl=true] [-openssl=false] [-dd] [DIR]"
}
OPT_ENCFS=0
OPT_LOOPBACK=0
OPT_OPENSSL=""
OPT_DIR=""
DD_ONLY=""
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"
;;
-dd)
DD_ONLY=1
;;
-loopback)
OPT_LOOPBACK=1
;;
-*)
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
if [[ -z $OPT_DIR ]] ; then
OPT_DIR=/tmp
fi
# Create directories
CRYPT=$(mktemp -d "$OPT_DIR/$MYNAME.XXX")
MNT=$CRYPT.mnt
mkdir $MNT
# Mount
if [[ $OPT_ENCFS -eq 1 ]]; then
if [[ ! -z $OPT_OPENSSL ]] ; then
echo "The option $OPT_OPENSSL only works with gocryptfs"
exit 1
fi
echo -n "Testing EncFS at $CRYPT: "
encfs --version
/home/jakob.donotbackup/encfs/build/encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
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
else
echo -n "Testing gocryptfs at $CRYPT: "
gocryptfs -version
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
gocryptfs -q -extpass="echo test" $OPT_OPENSSL $CRYPT $MNT
fi
# Make sure we have actually mounted something
if ! mountpoint $MNT ; then
exit 1
fi
# Cleanup trap
trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT
# Benchmarks
if [[ $DD_ONLY -eq 1 ]]; then
echo -n "WRITE: "
dd if=/dev/zero of=$MNT/zero bs=131072 count=20000 2>&1 | tail -n 1
rm $MNT/zero
else
./tests/canonical-benchmarks.bash $MNT
fi
|