tests: extractloop.sh: better cleanup logic, handle missing /proc

macos does not have /proc, so don't try to read it.
This commit is contained in:
Jakob Unterwurzacher 2018-03-13 22:41:26 +01:00
parent e46f6b940f
commit 4b75b578a2
1 changed files with 5 additions and 3 deletions

View File

@ -21,7 +21,9 @@ source ../fuse-unmount.bash
# Setup dirs
../dl-linux-tarball.bash
cd /tmp
CRYPT=$(mktemp -d /tmp/$MYNAME.XXX)
EXTRACTLOOP_TMPDIR=/tmp/extractloop_tmpdir
mkdir -p $EXTRACTLOOP_TMPDIR
CRYPT=$(mktemp -d $EXTRACTLOOP_TMPDIR/XXX)
CSV=$CRYPT.csv
MNT=$CRYPT.mnt
mkdir $MNT
@ -65,7 +67,7 @@ ln -v -sTf $CSV /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, igno
# Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore unmount errors.
trap "cd / ; fuse-unmount -z $MNT ; rm -rf $CRYPT; rmdir $MNT" EXIT
trap "cd / ; rm -Rf $CRYPT ; fuse-unmount -z $MNT || true ; rmdir $MNT" EXIT
function loop {
ID=$1
@ -86,7 +88,7 @@ function loop {
rm -Rf linux-3.0
t2=$SECONDS
delta=$((t2-t1))
if [ $FSPID -gt 0 ]; then
if [[ $FSPID -gt 0 && -d /proc ]]; then
RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ')
echo "$N,$SECONDS,$RSS" >> $CSV
fi