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 2011/06/26 17:00:22 UTC

svn commit: r1139806 - in /subversion/trunk: Makefile.in subversion/tests/cmdline/svnserveautocheck.sh

Author: danielsh
Date: Sun Jun 26 15:00:21 2011
New Revision: 1139806

URL: http://svn.apache.org/viewvc?rev=1139806&view=rev
Log:
Make svnserveautocheck more portable.

* Makefile.in
  (svnserveautocheck): Pass $PYTHON and don't call bash.

* subversion/tests/cmdline/svnserveautocheck.sh
  (#!): s#/bin/bash#/bin/sh#
  ($PYTHON): Use this environment variable, if available.
  (): Replace bash-specific constructs with more portable equivalents.

Modified:
    subversion/trunk/Makefile.in
    subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh

Modified: subversion/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=1139806&r1=1139805&r2=1139806&view=diff
==============================================================================
--- subversion/trunk/Makefile.in (original)
+++ subversion/trunk/Makefile.in Sun Jun 26 15:00:21 2011
@@ -511,8 +511,8 @@ svncheck: bin $(TEST_DEPS) @BDB_TEST_DEP
 
 # 'make svnserveautocheck' runs svnserve for you and kills it.
 svnserveautocheck: svnserve bin $(TEST_DEPS) @BDB_TEST_DEPS@
-	@env THREADED=$(THREADED) \
-	  bash $(top_srcdir)/subversion/tests/cmdline/svnserveautocheck.sh
+	@env PYTHON=$(PYTHON) THREADED=$(THREADED) \
+	  $(top_srcdir)/subversion/tests/cmdline/svnserveautocheck.sh
 
 # First, run:
 #   subversion/svnserve/svnserve --listen-host "::1" -d -r `pwd`/subversion/tests/cmdline

Modified: subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh?rev=1139806&r1=1139805&r2=1139806&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh (original)
+++ subversion/trunk/subversion/tests/cmdline/svnserveautocheck.sh Sun Jun 26 15:00:21 2011
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 #
 # Licensed to the Apache Software Foundation (ASF) under one
@@ -32,6 +32,9 @@
 # svnserveautocheck".  Like "make check", you can specify further options
 # like "make svnserveautocheck FS_TYPE=bdb TESTS=subversion/tests/cmdline/basic.py".
 
+echo "PYTHON=$PYTHON" >&2
+PYTHON=${PYTHON:-python}
+
 SCRIPTDIR=$(dirname $0)
 SCRIPT=$(basename $0)
 
@@ -43,23 +46,23 @@ trap trap_cleanup SIGHUP SIGTERM SIGINT
 LC_ALL=C
 export LC_ALL
 
-function really_cleanup() {
+really_cleanup() {
     if [ -e  "$SVNSERVE_PID" ]; then
         kill $(cat "$SVNSERVE_PID")
         rm -f $SVNSERVE_PID
     fi
 }
 
-function trap_cleanup() {
+trap_cleanup() {
     really_cleanup
     exit 1
 }
 
-function say() {
+say() {
   echo "$SCRIPT: $*"
 }
 
-function fail() {
+fail() {
   say $*
   exit 1
 }
@@ -67,9 +70,9 @@ function fail() {
 if [ -x subversion/svn/svn ]; then
   ABS_BUILDDIR=$(pwd)
 elif [ -x $SCRIPTDIR/../../svn/svn ]; then
-  pushd $SCRIPTDIR/../../../ >/dev/null
+  cd $SCRIPTDIR/../../../
   ABS_BUILDDIR=$(pwd)
-  popd >/dev/null
+  cd - >/dev/null
 else
   fail "Run this script from the root of Subversion's build tree!"
 fi
@@ -84,9 +87,17 @@ SERVER_CMD="$ABS_BUILDDIR/subversion/svn
 
 rm -f $SVNSERVE_PID
 
-SVNSERVE_PORT=$(($RANDOM+1024))
+random_port() {
+  if [ -n "$BASH_VERSION" ]; then
+    echo $(($RANDOM+1024))
+  else
+    $PYTHON -c 'import random; print random.randint(1024, 2**16-1)'
+  fi
+}
+
+SVNSERVE_PORT=$(random_port)
 while netstat -an | grep $SVNSERVE_PORT | grep 'LISTEN'; do
-  SVNSERVE_PORT=$(($RANDOM+1024))
+  SVNSERVE_PORT=$(random_port)
 done
 
 if [ "$THREADED" != "" ]; then
@@ -100,16 +111,16 @@ fi
             $SVNSERVE_ARGS &
 
 BASE_URL=svn://127.0.0.1:$SVNSERVE_PORT
-if [ $# == 0 ]; then
+if [ $# = 0 ]; then
   time make check "BASE_URL=$BASE_URL"
   r=$?
 else
-  pushd "$ABS_BUILDDIR/subversion/tests/cmdline/" >/dev/null
+  cd "$ABS_BUILDDIR/subversion/tests/cmdline/"
   TEST="$1"
   shift
   time "./${TEST}_tests.py" "--url=$BASE_URL" $*
   r=$?
-  popd >/dev/null
+  cd - > /dev/null
 fi
 
 really_cleanup



Re: svn commit: r1139806 - in /subversion/trunk: Makefile.in subversion/tests/cmdline/svnserveautocheck.sh

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 06/27/2011 02:07 PM, Peter Samuelson wrote:
> The first two are false positives.  The last two ... I don't know why
> checkbashisms thinks 'time' might be bash-specific.

Maybe because running 'time' in bash might not give the same output as
running '/usr/bin/time' ?

$ time ls > /dev/null

real	0m0.005s
user	0m0.000s
sys	0m0.004s
$ /usr/bin/time ls > /dev/null
0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 3632maxresident)k
0inputs+0outputs (0major+292minor)pagefaults 0swaps
$

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Re: svn commit: r1139806 - in /subversion/trunk: Makefile.in subversion/tests/cmdline/svnserveautocheck.sh

Posted by Peter Samuelson <pe...@p12n.org>.
[danielsh@apache.org]
> * subversion/tests/cmdline/svnserveautocheck.sh
>   (#!): s#/bin/bash#/bin/sh#
>   ($PYTHON): Use this environment variable, if available.
>   (): Replace bash-specific constructs with more portable equivalents.

Looks good:

    $ checkbashisms svnserveautocheck.sh
    possible bashism in svnserveautocheck.sh line 90 ($BASH_SOMETHING):
      if [ -n "$BASH_VERSION" ]; then
    possible bashism in svnserveautocheck.sh line 91 ($RANDOM):
        echo $(($RANDOM+1024))
    possible bashism in svnserveautocheck.sh line 114 (time):
      time make check "BASE_URL=$BASE_URL"
    possible bashism in svnserveautocheck.sh line 120 (time):
      time "./${TEST}_tests.py" "--url=$BASE_URL" $*

The first two are false positives.  The last two ... I don't know why
checkbashisms thinks 'time' might be bash-specific.
-- 
Peter Samuelson | org-tld!p12n!peter | http://p12n.org/