aboutsummaryrefslogtreecommitdiff
path: root/tests/stress_tests
diff options
context:
space:
mode:
authora13460542021-08-31 17:01:47 +0000
committerrfjakob2021-09-01 10:22:01 +0200
commitc63f7e9f64ee394b3311edb7f36f56fd786d145a (patch)
tree84dec7ad0b4759532f622174c008e3aa645c5a29 /tests/stress_tests
parentc505e73a13d8e2083b53c5c1af1f937b46665abd (diff)
shell scripts: fix shellcheck warnings
Diffstat (limited to 'tests/stress_tests')
-rwxr-xr-xtests/stress_tests/extractloop.bash48
-rwxr-xr-xtests/stress_tests/fsstress-gocryptfs.bash40
-rwxr-xr-xtests/stress_tests/parallel_cp.sh16
-rwxr-xr-xtests/stress_tests/pingpong.bash36
4 files changed, 70 insertions, 70 deletions
diff --git a/tests/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash
index cdd0c25..1f78a5e 100755
--- a/tests/stress_tests/extractloop.bash
+++ b/tests/stress_tests/extractloop.bash
@@ -28,17 +28,17 @@ source ../fuse-unmount.bash
# Setup dirs
../dl-linux-tarball.bash
-cd $TMPDIR
+cd "$TMPDIR"
EXTRACTLOOP_TMPDIR=$TMPDIR/extractloop_tmpdir
-mkdir -p $EXTRACTLOOP_TMPDIR
-CRYPT=$(mktemp -d $EXTRACTLOOP_TMPDIR/XXX)
+mkdir -p "$EXTRACTLOOP_TMPDIR"
+CRYPT=$(mktemp -d "$EXTRACTLOOP_TMPDIR/XXX")
CSV=$CRYPT.csv
MNT=$CRYPT.mnt
-mkdir $MNT
+mkdir "$MNT"
-function check_md5sums {
+check_md5sums() {
if command -v md5sum > /dev/null ; then
- md5sum --status -c $1
+ md5sum --status -c "$1"
else
# MacOS / darwin which do not have the md5sum utility
# installed by default
@@ -52,50 +52,50 @@ FS=""
if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then
FS=encfs
echo "Testing EncFS"
- encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
+ encfs --extpass="echo test" --standard "$CRYPT" "$MNT" > /dev/null
elif [ $# -eq 1 ] && [ "$1" == "-loopback" ]; then
FS=loopback
echo "Testing go-fuse loopback"
rm -f /tmp/loopback*.memprof
- loopback -memprofile=/tmp/loopback $MNT $CRYPT &
+ loopback -memprofile=/tmp/loopback "$MNT" "$CRYPT" &
FSPID=$(jobs -p)
disown
else
FS=gocryptfs
echo "Testing gocryptfs"
- gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
- gocryptfs -q -extpass="echo test" -nosyslog -fg $CRYPT $MNT &
+ gocryptfs -q -init -extpass="echo test" -scryptn=10 "$CRYPT"
+ gocryptfs -q -extpass="echo test" -nosyslog -fg "$CRYPT" "$MNT" &
FSPID=$(jobs -p)
disown
- #gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem $CRYPT $MNT
+ #gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem "$CRYPT" "$MNT"
fi
echo "Test dir: $CRYPT"
# Sleep to make sure the FS is already mounted on MNT
sleep 1
-cd $MNT
+cd "$MNT"
-ln -v -sTf $CSV /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, ignore
+ln -v -sTf "$CSV" /tmp/extractloop.csv 2> /dev/null || true # fails on MacOS, ignore
# Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore unmount errors.
trap cleanup_exit EXIT
-function cleanup_exit {
+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
+ rm -Rf "$CRYPT"
+ fuse-unmount -z "$MNT" || true
+ rmdir "$MNT"
}
-function loop {
+loop() {
ID=$1
- mkdir $ID
- cd $ID
+ mkdir "$ID"
+ cd "$ID"
echo "[looper $ID] Starting"
@@ -107,20 +107,20 @@ function loop {
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"
- check_md5sums $MD5
+ check_md5sums "$MD5"
rm -R linux-3.0
t2=$SECONDS
delta=$((t2-t1))
if [[ $FSPID -gt 0 && -d /proc ]]; then
RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ')
- echo "$N,$SECONDS,$RSS,$delta" >> $CSV
+ echo "$N,$SECONDS,$RSS,$delta" >> "$CSV"
fi
echo "[looper $ID] Iteration $N done, $delta seconds, RSS $RSS kiB"
- let N=$N+1
+ N=$((N+1))
done
}
-function memprof {
+memprof() {
while true; do
kill -USR1 $FSPID
sleep 60
diff --git a/tests/stress_tests/fsstress-gocryptfs.bash b/tests/stress_tests/fsstress-gocryptfs.bash
index a7aa811..08cdd45 100755
--- a/tests/stress_tests/fsstress-gocryptfs.bash
+++ b/tests/stress_tests/fsstress-gocryptfs.bash
@@ -19,7 +19,7 @@ export TMPDIR=${TMPDIR:-/var/tmp}
DEBUG=${DEBUG:-0}
cd "$(dirname "$0")"
-MYNAME=$(basename $0)
+MYNAME=$(basename "$0")
source ../fuse-unmount.bash
# fsstress binary
@@ -32,23 +32,23 @@ then
fi
# Backing directory
-DIR=$(mktemp -d $TMPDIR/$MYNAME.XXX)
+DIR=$(mktemp -d "$TMPDIR/$MYNAME.XXX")
# Mountpoint
MNT="$DIR.mnt"
-mkdir $MNT
+mkdir "$MNT"
# Set the GOPATH variable to the default if it is empty
GOPATH=$(go env GOPATH)
# Clean up old mounts
-for i in $(mount | cut -d" " -f3 | grep $TMPDIR/$MYNAME) ; do
- fusermount -u $i
+for i in $(mount | cut -d" " -f3 | grep "$TMPDIR/$MYNAME") ; do
+ fusermount -u "$i"
done
# FS-specific compile and mount
if [[ $MYNAME = fsstress-loopback.bash ]]; then
echo -n "Recompile go-fuse loopback: "
- cd $GOPATH/src/github.com/hanwen/go-fuse/example/loopback
+ cd "$GOPATH/src/github.com/hanwen/go-fuse/example/loopback"
git describe
go build && go install
OPTS="-q"
@@ -59,20 +59,20 @@ if [[ $MYNAME = fsstress-loopback.bash ]]; then
disown
elif [[ $MYNAME = fsstress-gocryptfs.bash ]]; then
echo "Recompile gocryptfs"
- cd $GOPATH/src/github.com/rfjakob/gocryptfs
+ cd "$GOPATH/src/github.com/rfjakob/gocryptfs"
./build.bash # also prints the version
- $GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 $DIR
- $GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog -fusedebug=$DEBUG $DIR $MNT
+ $GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 "$DIR"
+ $GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog -fusedebug="$DEBUG" "$DIR" "$MNT"
elif [[ $MYNAME = fsstress-encfs.bash ]]; then
- encfs --extpass "echo test" --standard $DIR $MNT
+ encfs --extpass "echo test" --standard "$DIR" "$MNT"
else
- echo Unknown mode: $MYNAME
+ echo "Unknown mode: $MYNAME"
exit 1
fi
sleep 0.5
echo -n "Waiting for mount: "
-while ! grep "$(basename $MNT) fuse" /proc/self/mounts > /dev/null
+while ! grep "$(basename "$MNT") fuse" /proc/self/mounts > /dev/null
do
sleep 1
echo -n x
@@ -87,26 +87,26 @@ N=1
while true
do
echo "$N ................................. $(date)"
- mkdir $MNT/fsstress.1
+ mkdir "$MNT/fsstress.1"
echo -n " fsstress.1 "
- $FSSTRESS -r -m 8 -n 1000 -d $MNT/fsstress.1 &
+ $FSSTRESS -r -m 8 -n 1000 -d "$MNT/fsstress.1" &
wait
- mkdir $MNT/fsstress.2
+ mkdir "$MNT/fsstress.2"
echo -n " fsstress.2 "
- $FSSTRESS -p 20 -r -m 8 -n 1000 -d $MNT/fsstress.2 &
+ $FSSTRESS -p 20 -r -m 8 -n 1000 -d "$MNT/fsstress.2" &
wait
- mkdir $MNT/fsstress.3
+ mkdir "$MNT/fsstress.3"
echo -n " fsstress.3 "
$FSSTRESS -p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
-f rename=30 -f stat=30 -f unlink=30 -f truncate=20 -m 8 \
- -n 1000 -d $MNT/fsstress.3 &
+ -n 1000 -d "$MNT/fsstress.3" &
wait
echo " rm"
- rm -Rf $MNT/*
+ rm -Rf "$MNT"/*
- let N=$N+1
+ N=$((N+1))
done
diff --git a/tests/stress_tests/parallel_cp.sh b/tests/stress_tests/parallel_cp.sh
index ad98e5e..cd08d31 100755
--- a/tests/stress_tests/parallel_cp.sh
+++ b/tests/stress_tests/parallel_cp.sh
@@ -18,32 +18,32 @@ if [[ -z $TMPDIR ]]; then
fi
cd "$(dirname "$0")"
-MYNAME=$(basename $0)
+MYNAME=$(basename "$0")
source ../fuse-unmount.bash
# Set the GOPATH variable to the default if it is empty
GOPATH=$(go env GOPATH)
# Backing directory
-DIR=$(mktemp -d $TMPDIR/$MYNAME.XXX)
-$GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 $DIR
+DIR=$(mktemp -d "$TMPDIR/$MYNAME.XXX")
+$GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 "$DIR"
# Mountpoint
MNT="$DIR.mnt"
-mkdir $MNT
-$GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog $DIR $MNT
+mkdir "$MNT"
+$GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog "$DIR" "$MNT"
echo "Mounted gocryptfs $DIR at $MNT"
# Cleanup trap
trap "cd / ; fuse-unmount -z $MNT ; rm -rf $DIR $MNT" EXIT
-cd $MNT
+cd "$MNT"
SECONDS=0
echo "creating files with dd"
mkdir -p origin
for i in $(seq 1 778) ; do
- dd if=/dev/zero of=origin/file_$i bs=8192 count=1 status=none
+ dd if=/dev/zero of="origin/file_$i" bs=8192 count=1 status=none
done
# Perform the shell expansion only once and store the list
ORIGIN_FILES=origin/*
@@ -51,7 +51,7 @@ ORIGIN_FILES=origin/*
echo -n "cp starting: "
for i in $(seq 1 100) ; do
echo -n "$i "
- (mkdir sub_$i && cp $ORIGIN_FILES sub_$i ; echo -n "$i ") &
+ (mkdir "sub_$i" && cp $ORIGIN_FILES "sub_$i" ; echo -n "$i ") &
done
echo
diff --git a/tests/stress_tests/pingpong.bash b/tests/stress_tests/pingpong.bash
index 218b6e8..4b8346e 100755
--- a/tests/stress_tests/pingpong.bash
+++ b/tests/stress_tests/pingpong.bash
@@ -13,7 +13,7 @@ renice 19 $$
cd "$(dirname "$0")"
MD5="$PWD/linux-3.0.md5sums"
-MYNAME=$(basename $0)
+MYNAME=$(basename "$0")
source ../fuse-unmount.bash
# Setup
@@ -22,48 +22,48 @@ cd /tmp
PING=$(mktemp -d ping.XXX)
PONG=$(mktemp -d pong.XXX)
-mkdir $PING.mnt $PONG.mnt
+mkdir "$PING.mnt" "$PONG.mnt"
# Cleanup trap
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
# Just ignore unmount errors.
trap "set +e ; cd /tmp; fuse-unmount -z $PING.mnt ; fuse-unmount -z $PONG.mnt ; rm -rf $PING $PONG $PING.mnt $PONG.mnt" EXIT
-gocryptfs -q -init -extpass="echo test" -scryptn=10 $PING
-gocryptfs -q -init -extpass="echo test" -scryptn=10 $PONG
+gocryptfs -q -init -extpass="echo test" -scryptn=10 "$PING"
+gocryptfs -q -init -extpass="echo test" -scryptn=10 "$PONG"
-gocryptfs -q -extpass="echo test" -nosyslog $PING $PING.mnt
-gocryptfs -q -extpass="echo test" -nosyslog $PONG $PONG.mnt
+gocryptfs -q -extpass="echo test" -nosyslog "$PING" "$PING.mnt"
+gocryptfs -q -extpass="echo test" -nosyslog "$PONG" "$PONG.mnt"
echo "Initial extract"
-tar xf /tmp/linux-3.0.tar.gz -C $PING.mnt
+tar xf /tmp/linux-3.0.tar.gz -C "$PING.mnt"
-function move_and_md5 {
- if [ $MYNAME = pingpong-rsync.bash ]; then
+move_and_md5() {
+ if [ "$MYNAME" = "pingpong-rsync.bash" ]; then
echo -n "rsync "
- rsync -a --remove-source-files $1 $2
- find $1 -type d -delete
+ rsync -a --remove-source-files "$1" "$2"
+ find "$1" -type d -delete
else
echo -n "mv "
- mv $1 $2
+ mv "$1" "$2"
fi
- if [ -e $1 ]; then
+ if [ -e "$1" ]; then
echo "error: source directory $1 was not removed"
exit 1
fi
- cd $2
+ cd "$2"
echo -n "md5 "
- md5sum --status -c $MD5
+ md5sum --status -c "$MD5"
cd ..
}
N=1
while true; do
echo -n "$N: "
- move_and_md5 $PING.mnt/linux-3.0 $PONG.mnt
- move_and_md5 $PONG.mnt/linux-3.0 $PING.mnt
+ move_and_md5 "$PING.mnt/linux-3.0" "$PONG.mnt"
+ move_and_md5 "$PONG.mnt/linux-3.0" "$PING.mnt"
date +%H:%M:%S
- let N=$N+1
+ N=$((N+1))
done
wait