tests: factor out fs-agnostic benchmark script

"canonical-benchmarks.bash TESTDIR"
can now be used on any filesystem.
This commit is contained in:
Jakob Unterwurzacher 2016-07-16 18:08:01 +02:00
parent d3940c6263
commit 6b50f2debc
2 changed files with 56 additions and 29 deletions

View File

@ -1,42 +1,28 @@
#!/bin/bash
#!/bin/bash -eu
# Run the set of "canonical" benchmarks that are shown on
# https://nuetzlich.net/gocryptfs/comparison/
set -eu
TIME="/usr/bin/time -f %e"
cd "$(dirname "$0")"
# Setup
cd /tmp
wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
DIR1=$(mktemp -d)
DIR2=$(mktemp -d)
CRYPT=$(mktemp -d /tmp/benchmark.bash.XXX)
MNT=$CRYPT.mnt
mkdir $MNT
# Mount
if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then
echo "Testing EncFS"
encfs --extpass="echo test" --standard $DIR1 $DIR2 > /dev/null
echo "Testing EncFS at $MNT"
encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
else
gocryptfs -q -init -extpass="echo test" -scryptn=10 $DIR1
gocryptfs -q -extpass="echo test" $DIR1 $DIR2
echo "Testing gocryptfs at $MNT"
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
gocryptfs -q -extpass="echo test" $CRYPT $MNT
fi
cd $DIR2
# Cleanup trap
trap "cd /; fusermount -u -z $MNT; rm -rf $CRYPT $MNT" EXIT
# Benchmarks
echo -n "WRITE: "
dd if=/dev/zero of=zero bs=128K count=1000 2>&1 | tail -n 1
rm zero
sleep 1
echo -n "UNTAR: "
$TIME tar xzf ../linux-3.0.tar.gz
sleep 1
echo -n "LS: "
$TIME ls -lR linux-3.0 > /dev/null
sleep 1
echo -n "RM: "
$TIME rm -Rf linux-3.0
./tests/canonical-benchmarks.bash $MNT
# Cleanup
cd ..
fusermount -u $DIR2 -z
rm -Rf $DIR1 $DIR2

41
tests/canonical-benchmarks.bash Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash -eu
#
# Run the set of "canonical" benchmarks that are shown on
# https://nuetzlich.net/gocryptfs/comparison/
# against the directory passed as "$1".
#
# This is called by the top-level script "benchmark.bash".
if [ $# -ne 1 ]; then
MYNAME=$(basename $0)
echo "usage: $MYNAME TESTDIR"
exit 1
fi
cd "$1"
TGZ=/tmp/linux-3.0.tar.gz
if [ "$(md5sum /tmp/linux-3.0.tar.gz | cut -f1 -d' ')" != \
"f7e6591d86a9dbe123dfd1a0be054e7f" ]; then
echo "Downloading linux-3.0.tar.gz"
wget -nv --show-progress -c -O $TGZ \
https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
fi
function etime {
LC_ALL=C /usr/bin/time -f %e 2>&1 $@ > /dev/null
}
echo -n "WRITE: "
dd if=/dev/zero of=zero bs=128K count=1000 2>&1 | tail -n 1
rm zero
sleep 1
echo -n "UNTAR: "
etime tar xzf $TGZ
sleep 1
echo -n "LS: "
etime ls -lR linux-3.0
sleep 1
echo -n "RM: "
etime rm -Rf linux-3.0