[neon/backports-focal/xdg-desktop-portal/Neon/unstable] tests: test-document-fuse: Quote more defensively

Simon McVittie null at kde.org
Wed Jan 13 06:32:43 GMT 2021


Git commit 243379f203fb11249bab96eab9f8935a725fe311 by Simon McVittie.
Committed on 09/09/2020 at 12:01.
Pushed by ash into branch 'Neon/unstable'.

test-document-fuse: Quote more defensively

Signed-off-by: Simon McVittie <smcv at debian.org>

M  +15   -15   tests/test-document-fuse.sh

https://invent.kde.org/neon/backports-focal/xdg-desktop-portal/commit/243379f203fb11249bab96eab9f8935a725fe311

diff --git a/tests/test-document-fuse.sh b/tests/test-document-fuse.sh
index da0aa47..f0013d4 100755
--- a/tests/test-document-fuse.sh
+++ b/tests/test-document-fuse.sh
@@ -25,20 +25,20 @@ set -e
 if [ -n "${G_TEST_SRCDIR:-}" ]; then
     test_srcdir="${G_TEST_SRCDIR}"
 else
-    test_srcdir=$(realpath $(dirname $0))
+    test_srcdir=$(realpath "$(dirname $0)")
 fi
 
 if [ -n "${G_TEST_BUILDDIR:-}" ]; then
     test_builddir="${G_TEST_BUILDDIR}"
 else
-    test_builddir=$(realpath $(dirname $0))
+    test_builddir=$(realpath "$(dirname $0)")
 fi
 
 export TEST_DATA_DIR=`mktemp -d /tmp/xdp-XXXXXX`
-mkdir -p ${TEST_DATA_DIR}/home
-mkdir -p ${TEST_DATA_DIR}/runtime
-mkdir -p ${TEST_DATA_DIR}/system
-mkdir -p ${TEST_DATA_DIR}/config
+mkdir -p "${TEST_DATA_DIR}/home"
+mkdir -p "${TEST_DATA_DIR}/runtime"
+mkdir -p "${TEST_DATA_DIR}/system"
+mkdir -p "${TEST_DATA_DIR}/config"
 
 export HOME=${TEST_DATA_DIR}/home
 export XDG_CACHE_HOME=${TEST_DATA_DIR}/home/cache
@@ -47,15 +47,15 @@ export XDG_DATA_HOME=${TEST_DATA_DIR}/home/share
 export XDG_RUNTIME_DIR=${TEST_DATA_DIR}/runtime
 
 cleanup () {
-    fusermount -u $XDG_RUNTIME_DIR/doc || :
+    fusermount -u "$XDG_RUNTIME_DIR/doc" || :
     sleep 0.1
-    kill -9 $DBUS_SESSION_BUS_PID
+    kill -9 "$DBUS_SESSION_BUS_PID"
     kill $(jobs -p) &> /dev/null || true
-    rm -rf $TEST_DATA_DIR
+    rm -rf "$TEST_DATA_DIR"
 }
 trap cleanup EXIT
 
-sed s#@testdir@#${test_builddir}# ${test_srcdir}/session.conf.in > session.conf
+sed "s#@testdir@#${test_builddir}#" "${test_srcdir}/session.conf.in" > session.conf
 
 dbus-daemon --fork --config-file=session.conf --print-address=3 --print-pid=4 \
             3> dbus-session-bus-address 4> dbus-session-bus-pid
@@ -76,20 +76,20 @@ fi
 
 # First run a basic single-thread test
 echo Testing single-threaded
-${test_srcdir}/test-document-fuse.py --iterations 3 -v
+"${test_srcdir}/test-document-fuse.py" --iterations 3 -v
 echo "ok single-threaded"
 
 # Then a bunch of copies in parallel to stress-test
 echo Testing in parallel
 PIDS=()
 for i in $(seq 20); do
-    ${test_srcdir}/test-document-fuse.py --iterations 10 --prefix $i &
+    "${test_srcdir}/test-document-fuse.py" --iterations 10 --prefix "$i" &
     PID="$!"
     PIDS+=( "$PID" )
 done
 
-for PID in ${PIDS[@]}; do
-    echo waiting for pid ${PID}
-    wait ${PID}
+for PID in "${PIDS[@]}"; do
+    echo waiting for pid "${PID}"
+    wait "${PID}"
 done
 echo "ok load-test"



More information about the Neon-commits mailing list