2016-05-05 12:58:44 +02:00
|
|
|
#!/bin/bash
|
2016-05-24 21:08:13 +02:00
|
|
|
#
|
|
|
|
# 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.
|
2018-01-21 20:04:37 +01:00
|
|
|
#
|
|
|
|
# See Documentation/extractloop.md for example output.
|
2016-05-05 12:58:44 +02:00
|
|
|
|
2019-10-06 22:34:19 +02:00
|
|
|
if [[ -z $TMPDIR ]]; then
|
|
|
|
TMPDIR=/var/tmp
|
|
|
|
export TMPDIR
|
|
|
|
fi
|
|
|
|
|
2016-05-05 12:58:44 +02:00
|
|
|
set -eu
|
|
|
|
|
2019-01-03 16:14:05 +01:00
|
|
|
# Run at low priority to not annoy the user too much
|
|
|
|
renice 19 $$
|
|
|
|
|
2016-05-24 21:08:13 +02:00
|
|
|
cd "$(dirname "$0")"
|
2016-06-07 23:36:35 +02:00
|
|
|
MD5="$PWD/linux-3.0.md5sums"
|
2016-09-24 20:38:05 +02:00
|
|
|
MYNAME=$(basename "$0")
|
2017-02-15 23:02:01 +01:00
|
|
|
source ../fuse-unmount.bash
|
2016-05-24 21:08:13 +02:00
|
|
|
|
2016-07-11 22:10:41 +02:00
|
|
|
# Setup dirs
|
2018-03-07 09:45:20 +01:00
|
|
|
../dl-linux-tarball.bash
|
2019-10-06 22:34:19 +02:00
|
|
|
cd $TMPDIR
|
|
|
|
EXTRACTLOOP_TMPDIR=$TMPDIR/extractloop_tmpdir
|
2018-03-13 22:41:26 +01:00
|
|
|
mkdir -p $EXTRACTLOOP_TMPDIR
|
|
|
|
CRYPT=$(mktemp -d $EXTRACTLOOP_TMPDIR/XXX)
|
2016-07-16 21:18:59 +02:00
|
|
|
CSV=$CRYPT.csv
|
|
|
|
MNT=$CRYPT.mnt
|
|
|
|
mkdir $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
|
2018-03-13 22:16:15 +01:00
|
|
|
function check_md5sums {
|
|
|
|
if command -v md5sum > /dev/null ; then
|
|
|
|
md5sum --status -c $1
|
|
|
|
else
|
|
|
|
# MacOS / darwin which do not have the md5sum utility
|
|
|
|
# installed by default
|
|
|
|
echo "Skipping md5sum (not installed). Hint: brew install md5sha1sum"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-07-11 22:10:41 +02:00
|
|
|
# Mount
|
2016-07-16 21:18:59 +02:00
|
|
|
FSPID=0
|
2019-11-03 20:02:46 +01:00
|
|
|
FS=""
|
2016-07-11 22:10:41 +02:00
|
|
|
if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then
|
2019-11-03 20:02:46 +01:00
|
|
|
FS=encfs
|
2016-07-11 22:10:41 +02:00
|
|
|
echo "Testing EncFS"
|
2016-07-16 21:18:59 +02:00
|
|
|
encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
|
2016-07-12 08:30:29 +02:00
|
|
|
elif [ $# -eq 1 ] && [ "$1" == "-loopback" ]; then
|
2019-11-03 20:02:46 +01:00
|
|
|
FS=loopback
|
2016-07-12 08:30:29 +02:00
|
|
|
echo "Testing go-fuse loopback"
|
2016-07-16 21:18:59 +02:00
|
|
|
rm -f /tmp/loopback*.memprof
|
2019-10-19 19:58:39 +02:00
|
|
|
loopback -memprofile=/tmp/loopback $MNT $CRYPT &
|
2016-07-16 21:18:59 +02:00
|
|
|
FSPID=$(jobs -p)
|
2018-03-13 22:16:15 +01:00
|
|
|
disown
|
2016-07-11 22:10:41 +02:00
|
|
|
else
|
2019-11-03 20:02:46 +01:00
|
|
|
FS=gocryptfs
|
2016-07-16 21:18:59 +02:00
|
|
|
echo "Testing gocryptfs"
|
|
|
|
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
|
2018-03-07 21:22:47 +01:00
|
|
|
gocryptfs -q -extpass="echo test" -nosyslog -fg $CRYPT $MNT &
|
2016-07-16 21:18:59 +02:00
|
|
|
FSPID=$(jobs -p)
|
2018-03-13 22:16:15 +01:00
|
|
|
disown
|
2016-07-16 21:18:59 +02:00
|
|
|
#gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem $CRYPT $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
fi
|
2016-07-16 21:18:59 +02:00
|
|
|
echo "Test dir: $CRYPT"
|
|
|
|
# Sleep to make sure the FS is already mounted on MNT
|
|
|
|
sleep 1
|
|
|
|
cd $MNT
|
|
|
|
|
2018-03-07 21:22:47 +01:00
|
|
|
ln -v -sTf $CSV /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, ignore
|
2016-05-05 12:58:44 +02:00
|
|
|
|
|
|
|
# Cleanup trap
|
|
|
|
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
|
2017-02-15 23:02:01 +01:00
|
|
|
# Just ignore unmount errors.
|
2019-11-03 20:02:46 +01:00
|
|
|
trap cleanup_exit EXIT
|
|
|
|
|
|
|
|
function cleanup_exit {
|
|
|
|
if [[ $FS == loopback ]]; then
|
|
|
|
# SIGUSR1 causes loopback to write the memory profile to disk
|
|
|
|
kill -USR1 $FSPID
|
|
|
|
fi
|
|
|
|
cd /
|
|
|
|
rm -Rf $CRYPT
|
|
|
|
fuse-unmount -z $MNT || true
|
|
|
|
rmdir $MNT
|
|
|
|
}
|
2016-05-05 12:58:44 +02:00
|
|
|
|
2016-05-05 14:17:05 +02:00
|
|
|
function loop {
|
2018-03-07 20:37:10 +01:00
|
|
|
ID=$1
|
|
|
|
mkdir $ID
|
|
|
|
cd $ID
|
2016-05-05 14:17:05 +02:00
|
|
|
|
2018-03-07 20:37:10 +01:00
|
|
|
echo "[looper $ID] Starting"
|
2016-05-24 21:08:13 +02:00
|
|
|
|
2016-05-05 14:17:05 +02:00
|
|
|
N=1
|
2016-07-16 21:18:59 +02:00
|
|
|
RSS=0
|
2016-05-05 14:17:05 +02:00
|
|
|
while true
|
|
|
|
do
|
2016-05-24 21:22:02 +02:00
|
|
|
t1=$SECONDS
|
2018-03-07 21:22:47 +01:00
|
|
|
tar xf /tmp/linux-3.0.tar.gz --exclude linux-3.0/arch/microblaze/boot/dts/system.dts
|
|
|
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
# Exclude the one symlink in the tarball - causes problems on MacOS: "Can't set permissions to 0755"
|
2018-03-13 22:16:15 +01:00
|
|
|
check_md5sums $MD5
|
2019-11-03 20:02:46 +01:00
|
|
|
rm -R linux-3.0
|
2016-05-24 21:22:02 +02:00
|
|
|
t2=$SECONDS
|
2016-05-24 21:08:13 +02:00
|
|
|
delta=$((t2-t1))
|
2018-03-13 22:41:26 +01:00
|
|
|
if [[ $FSPID -gt 0 && -d /proc ]]; then
|
2016-07-16 21:18:59 +02:00
|
|
|
RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ')
|
2019-01-03 18:16:02 +01:00
|
|
|
echo "$N,$SECONDS,$RSS,$delta" >> $CSV
|
2016-07-16 21:18:59 +02:00
|
|
|
fi
|
2018-03-07 20:37:10 +01:00
|
|
|
echo "[looper $ID] Iteration $N done, $delta seconds, RSS $RSS kiB"
|
2016-05-05 14:17:05 +02:00
|
|
|
let N=$N+1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-07-16 21:18:59 +02:00
|
|
|
function memprof {
|
|
|
|
while true; do
|
|
|
|
kill -USR1 $FSPID
|
|
|
|
sleep 60
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2018-03-07 20:37:10 +01:00
|
|
|
loop 1 &
|
|
|
|
loop 2 &
|
2019-11-03 20:02:46 +01:00
|
|
|
if [[ $FS == loopback ]]; then
|
|
|
|
memprof &
|
|
|
|
fi
|
2016-05-05 14:17:05 +02:00
|
|
|
wait
|