summaryrefslogtreecommitdiff
path: root/tests/stress_tests/loopback-mem.bash
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-07-14 09:26:00 +0200
committerJakob Unterwurzacher2016-07-14 09:26:00 +0200
commite98c51afd6870c73d5006a22cff5322c2f4d0ba7 (patch)
tree01c3386ce7150fc9ac9aae6864a6ac4f646ff12f /tests/stress_tests/loopback-mem.bash
parent09c16ed2a713a89b583bf9ff0bee356cd7b44141 (diff)
tests: add loopback-mem script
Helps to find memory leaks in go-fuse's loopback, which gocryptfs builds upon.
Diffstat (limited to 'tests/stress_tests/loopback-mem.bash')
-rwxr-xr-xtests/stress_tests/loopback-mem.bash45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/stress_tests/loopback-mem.bash b/tests/stress_tests/loopback-mem.bash
new file mode 100755
index 0000000..fa3b0e3
--- /dev/null
+++ b/tests/stress_tests/loopback-mem.bash
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Mount a loopback filesystem somewhere on /tmp, then run an
+# infinite loop inside that does the following:
+# 1) Extract linux-3.0.tar.gz
+# 2) Delete
+# 3) Get memory profile
+#
+# This test is good at discovering inode-related memory leaks because it creates
+# huge numbers of files.
+
+set -eu
+
+# Setup dirs
+cd /tmp
+wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
+DIR1=$(mktemp -d /tmp/loopback-mem.XXX)
+DIR2=$DIR1.mnt
+mkdir $DIR2
+
+# Mount
+loopback -l -memprofile /tmp/lmem $DIR2 $DIR1 &
+LOOPBACKPID=$(jobs -p)
+sleep 1
+cd $DIR2
+
+# Cleanup trap
+trap "cd /; fusermount -u -z $DIR2; rm -rf $DIR1 $DIR2" EXIT
+
+echo "Starting loop"
+
+N=1
+while true; do
+ t1=$SECONDS
+ tar xf /tmp/linux-3.0.tar.gz
+ rm -Rf linux-3.0
+ t2=$SECONDS
+ delta=$((t2-t1))
+ rss=$(grep VmRSS /proc/$LOOPBACKPID/status)
+ echo "Iteration $N done, $delta seconds, $rss"
+ let N=$N+1
+ sleep 1
+ kill -USR1 $LOOPBACKPID
+done
+