diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/fuse-unmount.bash | 27 | ||||
-rwxr-xr-x | tests/reverse/linux-tarball-test.bash | 3 | ||||
-rwxr-xr-x | tests/stress_tests/extractloop.bash | 5 | ||||
-rwxr-xr-x | tests/stress_tests/fsstress-gocryptfs.bash | 9 | ||||
-rwxr-xr-x | tests/stress_tests/pingpong.bash | 5 |
5 files changed, 41 insertions, 8 deletions
diff --git a/tests/fuse-unmount.bash b/tests/fuse-unmount.bash new file mode 100755 index 0000000..087b6fe --- /dev/null +++ b/tests/fuse-unmount.bash @@ -0,0 +1,27 @@ +#!/bin/bash -eu +# +# Compatability wrapper around "fusermount" on Linux and "umount" on +# Mac OS X and friends. +# +# This script can be sourced or executed directly. +# +function fuse-unmount { + local MYNAME=$(basename "$BASH_SOURCE") + if [[ $# -eq 0 ]] ; then + echo "$MYNAME: missing argument" + exit 1 + fi + if [[ $OSTYPE == linux* ]] ; then + fusermount -u "$@" + else + # Mountpoint is in last argument, ignore anything else + # (like additional flags for fusermount). + local MNT=${@:$#} + umount "$MNT" + fi +} +# If the process name and the source file name is identical +# we have been executed, not sourced. +if [[ $(basename "$0") == $(basename "$BASH_SOURCE") ]] ; then + fuse-unmount "$@" +fi diff --git a/tests/reverse/linux-tarball-test.bash b/tests/reverse/linux-tarball-test.bash index 5fbc3fc..e8ecca6 100755 --- a/tests/reverse/linux-tarball-test.bash +++ b/tests/reverse/linux-tarball-test.bash @@ -5,6 +5,7 @@ set -eu cd "$(dirname "$0")" MD5="$PWD/../stress_tests/linux-3.0.md5sums" MYNAME=$(basename "$0") +source ../fuse-unmount.bash # Setup dirs cd /tmp @@ -12,7 +13,7 @@ wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3 WD=$(mktemp -d /tmp/$MYNAME.XXX) # Cleanup trap -trap "set +u; cd /; fusermount -u -z $WD/c; fusermount -u -z $WD/b; rm -rf $WD" EXIT +trap "set +u; cd /; fuse-unmount -z $WD/c; fuse-unmount -z $WD/b; rm -rf $WD" EXIT cd $WD mkdir a b c diff --git a/tests/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash index 2c139ab..18fc4ef 100755 --- a/tests/stress_tests/extractloop.bash +++ b/tests/stress_tests/extractloop.bash @@ -14,6 +14,7 @@ set -eu cd "$(dirname "$0")" MD5="$PWD/linux-3.0.md5sums" MYNAME=$(basename "$0") +source ../fuse-unmount.bash # Setup dirs cd /tmp @@ -49,8 +50,8 @@ ln -sTf $CSV /tmp/extractloop.csv # Cleanup trap # Note: gocryptfs may have already umounted itself because bash relays SIGINT -# Just ignore fusermount errors. -trap "cd /; fusermount -u -z $MNT; rm -rf $CRYPT $MNT" EXIT +# Just ignore unmount errors. +trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT function loop { # Note: In a subshell, $$ returns the PID of the parent shell. diff --git a/tests/stress_tests/fsstress-gocryptfs.bash b/tests/stress_tests/fsstress-gocryptfs.bash index 51c68db..432899a 100755 --- a/tests/stress_tests/fsstress-gocryptfs.bash +++ b/tests/stress_tests/fsstress-gocryptfs.bash @@ -14,6 +14,10 @@ set -eu +cd "$(dirname "$0")" +MYNAME=$(basename $0) +source ../fuse-unmount.bash + # Backing directory DIR=$(mktemp -d /tmp/fsstress.XXX) # Mountpoint @@ -28,13 +32,12 @@ then fi # Setup -fusermount -u -z $MNT &> /dev/null || true +fuse-unmount -z $MNT &> /dev/null || true mkdir -p $DIR $MNT rm -Rf $DIR/* rm -Rf $MNT/* # FS-specific compile and mount -MYNAME=$(basename $0) if [ $MYNAME = fsstress-loopback.bash ]; then echo "Recompile go-fuse loopback" cd $GOPATH/src/github.com/hanwen/go-fuse/example/loopback @@ -62,7 +65,7 @@ done echo # Cleanup trap -trap "kill %1 ; cd /; fusermount -u -z $MNT; rm -rf $DIR $MNT" EXIT +trap "kill %1 ; cd /; fuse-unmount -z $MNT; rm -rf $DIR $MNT" EXIT echo "Starting fsstress loop" N=1 diff --git a/tests/stress_tests/pingpong.bash b/tests/stress_tests/pingpong.bash index ebcb8c5..02aabc9 100755 --- a/tests/stress_tests/pingpong.bash +++ b/tests/stress_tests/pingpong.bash @@ -11,6 +11,7 @@ set -eu cd "$(dirname "$0")" MD5="$PWD/linux-3.0.md5sums" MYNAME=$(basename $0) +source ../fuse-unmount.bash # Setup cd /tmp @@ -22,8 +23,8 @@ mkdir $PING.mnt $PONG.mnt # Cleanup trap # Note: gocryptfs may have already umounted itself because bash relays SIGINT -# Just ignore fusermount errors. -trap "set +e ; cd /tmp; fusermount -u -z $PING.mnt ; fusermount -u -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT +# Just ignore unmount errors. +trap "set +e ; cd /tmp; fuse-unmount -z $PING.mnt ; fuse-unmount -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT gocryptfs -q -init -extpass="echo test" -scryptn=10 $PING gocryptfs -q -init -extpass="echo test" -scryptn=10 $PONG |