Blob Blame History Raw
diff -ur b/t/lib-git-svn.sh c/t/lib-git-svn.sh
--- b/t/lib-git-svn.sh	2021-03-26 23:03:34.000000000 +0100
+++ c/t/lib-git-svn.sh	2023-01-26 13:39:32.822183929 +0100
@@ -13,6 +13,7 @@
 GIT_DIR=$PWD/.git
 GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
 SVN_TREE=$GIT_SVN_DIR/svn-tree
+SVNSERVE_PIDFILE="$PWD"/daemon.pid
 test_set_port SVNSERVE_PORT
 
 svn >/dev/null 2>&1
@@ -115,10 +116,35 @@
 }
 
 start_svnserve () {
-	svnserve --listen-port $SVNSERVE_PORT \
-		 --root "$rawsvnrepo" \
-		 --listen-once \
-		 --listen-host 127.0.0.1 &
+	test_atexit stop_svnserve
+
+	i=0
+	while test $i -lt ${GIT_TEST_START_SVNSERVE_TRIES:-3}
+	do
+		say >&3 "Starting svnserve on port $SVNSERVE_PORT ..."
+		svnserve --listen-port $SVNSERVE_PORT \
+			 --root "$rawsvnrepo" \
+			 --daemon --pid-file="$SVNSERVE_PIDFILE" \
+			 --listen-host 127.0.0.1
+		ret=$?
+		# increment port and retry if unsuccessful
+		if test $ret -ne 0
+		then
+			SVNSERVE_PORT=$(($SVNSERVE_PORT + 1))
+			export SVNSERVE_PORT
+		else
+			break
+		fi
+	done
+}
+
+stop_svnserve () {
+	say >&3 "Stopping svnserve ..."
+	SVNSERVE_PID="$(cat "$SVNSERVE_PIDFILE")"
+	if test -n "$SVNSERVE_PID"
+	then
+		kill "$SVNSERVE_PID" 2>/dev/null
+	fi
 }
 
 prepare_a_utf8_locale () {
diff -ur b/t/t9113-git-svn-dcommit-new-file.sh c/t/t9113-git-svn-dcommit-new-file.sh
--- b/t/t9113-git-svn-dcommit-new-file.sh	2021-03-26 23:03:34.000000000 +0100
+++ c/t/t9113-git-svn-dcommit-new-file.sh	2023-01-26 13:39:30.314168109 +0100
@@ -28,7 +28,6 @@
 	echo hello > git-new-dir/world &&
 	git update-index --add git-new-dir/world &&
 	git commit -m hello &&
-	start_svnserve &&
 	git svn dcommit
 	"