summaryrefslogtreecommitdiff
path: root/tests/stress_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stress_tests')
-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
+