You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2013/07/29 06:21:03 UTC
svn commit: r1507909 - in /subversion/trunk/subversion/tests/cmdline: ./
davautocheck.sh
Author: danielsh
Date: Mon Jul 29 04:21:02 2013
New Revision: 1507909
URL: http://svn.apache.org/r1507909
Log:
davautocheck.sh: teach it to re-use the same port every time. I really
shouldn't have to copy the port number from the "run httpd under gdb" shell
to the "exercise it" shell by hand.
Note: this also makes davautocheck.sh auto-stop the last instance it started.
* subversion/tests/cmdline/davautocheck.sh
(STOPSCRIPT): New filename.
(random_port): Remove as unused.
(HTTPD_PORT): Use the first available port ≥3691.
(START): Before starting httpd, automatically stop the previous httpd
launched by this script.
Modified:
subversion/trunk/subversion/tests/cmdline/ (props changed)
subversion/trunk/subversion/tests/cmdline/davautocheck.sh
Propchange: subversion/trunk/subversion/tests/cmdline/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jul 29 04:21:02 2013
@@ -8,3 +8,4 @@ httpd-*
entries-dump
atomic-ra-revprop-change
.libs
+.davautocheck.sh.stop
Modified: subversion/trunk/subversion/tests/cmdline/davautocheck.sh
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/davautocheck.sh?rev=1507909&r1=1507908&r2=1507909&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/davautocheck.sh (original)
+++ subversion/trunk/subversion/tests/cmdline/davautocheck.sh Mon Jul 29 04:21:02 2013
@@ -85,6 +85,7 @@ PYTHON=${PYTHON:-python}
SCRIPTDIR=$(dirname $0)
SCRIPT=$(basename $0)
+STOPSCRIPT=$SCRIPTDIR/.$SCRIPT.stop
trap stop_httpd_and_die HUP TERM INT
@@ -313,17 +314,13 @@ if [ ${USE_SSL:+set} ]; then
|| fail "SSL module not found"
fi
-random_port() {
- if [ -n "$BASH_VERSION" ]; then
- echo $(($RANDOM+1024))
- else
- $PYTHON -c 'import random; print random.randint(1024, 2**16-1)'
+HTTPD_PORT=3691
+while netstat -an | grep $HTTPD_PORT | grep 'LISTEN' >/dev/null; do
+ HTTPD_PORT=$(( HTTPD_PORT + 1 ))
+ if [ $HTTPD_PORT -eq 65536 ]; then
+ # Most likely the loop condition is true regardless of $HTTPD_PORT
+ fail "netstat claims you have no free ports for httpd to listen on."
fi
-}
-
-HTTPD_PORT=$(random_port)
-while netstat -an | grep $HTTPD_PORT | grep 'LISTEN'; do
- HTTPD_PORT=$(random_port)
done
HTTPD_ROOT="$ABS_BUILDDIR/subversion/tests/cmdline/httpd-$(date '+%Y%m%d-%H%M%S')"
HTTPD_CFG="$HTTPD_ROOT/cfg"
@@ -505,6 +502,15 @@ RedirectMatch ^/svn-test-work/
__EOF__
START="$HTTPD -f $HTTPD_CFG"
+if [ -x $STOPSCRIPT ]; then $STOPSCRIPT ; fi
+printf \
+'#!/bin/sh
+if [ -d "%s" ]; then
+ %s -k stop || kill -9 `cat %s`
+fi
+' >$STOPSCRIPT "$HTTPD_ROOT" "$START" "$HTTPD_PID"
+chmod +x $STOPSCRIPT
+sed -e 's/^/DEBUG: /' < $STOPSCRIPT
$START -t \
|| fail "Configuration file didn't pass the check, most likely modules couldn't be loaded"