aboutsummaryrefslogtreecommitdiff
path: root/tests/stress_tests/extractloop.bash
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-06 23:57:42 +0200
committerJakob Unterwurzacher2016-06-07 00:08:56 +0200
commitc2a5303eebc84d616072163f74eef8483c9f5386 (patch)
tree181ffdbb956eb76351d137a4fa9f52ed98b8f242 /tests/stress_tests/extractloop.bash
parent0f4d3501369e13c8ba6ee4c9fc7df02a3cc698b1 (diff)
tests: split example_filesystems into its own package
Running these tests from integration_tests' TestMain() was awkward because they were run twice with unchanged settings. integration_tests tests everything with OpenSSL and with native Go crypto, but this does not take affect for the example filesystems. To make this work, test_helpers is also split into its own package.
Diffstat (limited to 'tests/stress_tests/extractloop.bash')
-rwxr-xr-xtests/stress_tests/extractloop.bash56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash
new file mode 100755
index 0000000..c488707
--- /dev/null
+++ b/tests/stress_tests/extractloop.bash
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Mount a gocryptfs filesystem somewhere on /tmp, then run two parallel
+# infinite loops inside that do the following:
+# 1) Extract linux-3.0.tar.gz
+# 2) Verify the md5sums
+# 3) Delete, go to (1)
+#
+# This test is good at discovering inode-related memory leaks because it creates
+# huge numbers of files.
+
+set -eu
+
+cd "$(dirname "$0")"
+MD5="$PWD/extractloop.md5sums"
+
+# 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)
+gocryptfs -q -init -extpass="echo test" $DIR1
+gocryptfs -q -extpass="echo test" -nosyslog $DIR1 $DIR2
+#gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem $DIR1 $DIR2
+cd $DIR2
+
+# Cleanup trap
+# Note: gocryptfs may have already umounted itself because bash relays SIGINT
+# Just ignore fusermount errors.
+trap "cd /; fusermount -u -z $DIR2; rm -rf $DIR1 $DIR2" EXIT
+
+function loop {
+ # Note: In a subshell, $$ returns the PID of the *parent* shell,
+ # we need our own, which is why we have to use $BASHPID.
+ mkdir $BASHPID
+ cd $BASHPID
+
+ echo "[pid $BASHPID] Starting loop"
+
+ N=1
+ while true
+ do
+ t1=$SECONDS
+ tar xf /tmp/linux-3.0.tar.gz
+ md5sum --status -c $MD5
+ rm -Rf linux-3.0
+ t2=$SECONDS
+ delta=$((t2-t1))
+ echo "[pid $BASHPID] Iteration $N done, $delta seconds"
+ let N=$N+1
+ done
+}
+
+loop &
+loop &
+wait