| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 1 | #!/bin/sh | 
 | 2 |  | 
 | 3 | ## Script to build and test the latest python from svn.  It basically | 
 | 4 | ## does this: | 
 | 5 | ##   svn up ; ./configure ; make ; make test ; make install ; cd Doc ; make | 
 | 6 | ## | 
 | 7 | ## Logs are kept and rsync'ed to the host.  If there are test failure(s), | 
 | 8 | ## information about the failure(s) is mailed. | 
 | 9 | ## | 
 | 10 | ## This script is run on the PSF's machine as user neal via crontab. | 
 | 11 | ## | 
 | 12 | ## Yes, this script would probably be easier in python, but then | 
 | 13 | ## there's a bootstrap problem.  What if Python doesn't build? | 
 | 14 | ## | 
 | 15 | ## This script should be fairly clean Bourne shell, ie not too many | 
 | 16 | ## bash-isms.  We should try to keep it portable to other Unixes. | 
 | 17 | ## Even though it will probably only run on Linux.  I'm sure there are | 
 | 18 | ## several GNU-isms currently (date +%s and readlink). | 
 | 19 | ## | 
 | 20 | ## Perhaps this script should be broken up into 2 (or more) components. | 
 | 21 | ## Building doc is orthogonal to the rest of the python build/test. | 
 | 22 | ## | 
 | 23 |  | 
 | 24 | ## FIXME: we should detect test hangs (eg, if they take more than 45 minutes) | 
 | 25 |  | 
 | 26 | ## FIXME: we should run valgrind | 
 | 27 | ## FIXME: we should run code coverage | 
 | 28 |  | 
 | 29 | ## Utilities invoked in this script include: | 
| Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 30 | ##    basename, date, dirname, expr, grep, readlink, uname | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 31 | ##    cksum, make, mutt, rsync, svn | 
 | 32 |  | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 33 | ## remember where did we started from | 
 | 34 | DIR=`dirname $0` | 
 | 35 | if [ "$DIR" = "" ]; then | 
 | 36 |    DIR="." | 
 | 37 | fi | 
 | 38 |  | 
 | 39 | ## make directory absolute | 
 | 40 | DIR=`readlink -f $DIR` | 
| Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 41 | FULLPATHNAME="$DIR/`basename $0`" | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 42 | ## we want Misc/.. | 
 | 43 | DIR=`dirname $DIR` | 
 | 44 |  | 
 | 45 | ## Configurable options | 
 | 46 |  | 
 | 47 | FAILURE_SUBJECT="Python Regression Test Failures" | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 48 | #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com" | 
| Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 49 | FAILURE_MAILTO="python-checkins@python.org" | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 50 |  | 
 | 51 | REMOTE_SYSTEM="neal@dinsdale.python.org" | 
 | 52 | REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/" | 
 | 53 | RESULT_FILE="$DIR/build/index.html" | 
 | 54 | INSTALL_DIR="/tmp/python-test/local" | 
 | 55 | RSYNC_OPTS="-aC -e ssh" | 
 | 56 |  | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 57 | # Always run the installed version of Python. | 
 | 58 | PYTHON=$INSTALL_DIR/bin/python | 
 | 59 |  | 
 | 60 | # Python options and regression test program that should always be run. | 
 | 61 | REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.5/test/regrtest.py" | 
 | 62 |  | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 63 | REFLOG="build/reflog.txt.out" | 
| Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 64 | # These tests are not stable and falsely report leaks sometimes. | 
| Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 65 | # The entire leak report will be mailed if any test not in this list leaks. | 
| Neal Norwitz | a1f9b7f | 2006-04-06 07:58:59 +0000 | [diff] [blame] | 66 | # Note: test_XXX (none currently) really leak, but are disabled | 
| Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 67 | # so we don't send spam.  Any test which really leaks should only  | 
 | 68 | # be listed here if there are also test cases under Lib/test/leakers. | 
| Neal Norwitz | 9602cc2 | 2006-06-18 19:35:01 +0000 | [diff] [blame] | 69 | LEAKY_TESTS="test_(XXX)"  # Currently no tests should report spurious leaks. | 
| Neal Norwitz | ee6d23e | 2006-04-12 05:56:00 +0000 | [diff] [blame] | 70 |  | 
 | 71 | # Skip these tests altogether when looking for leaks.  These tests | 
 | 72 | # do not need to be stored above in LEAKY_TESTS too. | 
 | 73 | # test_compiler almost never finishes with the same number of refs | 
 | 74 | # since it depends on other modules, skip it. | 
 | 75 | # test_logging causes hangs, skip it. | 
 | 76 | LEAKY_SKIPS="-x test_compiler test_logging" | 
| Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 77 |  | 
| Neal Norwitz | 770a800 | 2006-03-17 04:52:38 +0000 | [diff] [blame] | 78 | # Change this flag to "yes" for old releases to only update/build the docs. | 
| Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 79 | BUILD_DISABLED="no" | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 80 |  | 
 | 81 | ## utility functions | 
 | 82 | current_time() { | 
 | 83 |     date +%s | 
 | 84 | } | 
 | 85 |  | 
 | 86 | update_status() { | 
 | 87 |     now=`current_time` | 
 | 88 |     time=`expr $now - $3` | 
 | 89 |     echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE | 
 | 90 | } | 
 | 91 |  | 
 | 92 | mail_on_failure() { | 
 | 93 |     if [ "$NUM_FAILURES" != "0" ]; then | 
 | 94 |         mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2 | 
 | 95 |     fi | 
 | 96 | } | 
 | 97 |  | 
 | 98 | ## setup | 
 | 99 | cd $DIR | 
 | 100 | mkdir -p build | 
 | 101 | rm -f $RESULT_FILE build/*.out | 
 | 102 | rm -rf $INSTALL_DIR | 
 | 103 |  | 
 | 104 | ## create results file | 
 | 105 | TITLE="Automated Python Build Results" | 
| Neal Norwitz | b896759 | 2006-01-16 04:37:22 +0000 | [diff] [blame] | 106 | echo "<html>" >> $RESULT_FILE | 
 | 107 | echo "  <head>" >> $RESULT_FILE | 
 | 108 | echo "    <title>$TITLE</title>" >> $RESULT_FILE | 
 | 109 | echo "    <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE | 
 | 110 | echo "  </head>" >> $RESULT_FILE | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 111 | echo "<body>" >> $RESULT_FILE | 
 | 112 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE | 
 | 113 | echo "<table>" >> $RESULT_FILE | 
 | 114 | echo "  <tr>" >> $RESULT_FILE | 
 | 115 | echo "    <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE | 
 | 116 | echo "  </tr><tr>" >> $RESULT_FILE | 
 | 117 | echo "    <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE | 
 | 118 | echo "  </tr><tr>" >> $RESULT_FILE | 
 | 119 | echo "    <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE | 
 | 120 | echo "  </tr>" >> $RESULT_FILE | 
 | 121 | echo "</table>" >> $RESULT_FILE | 
 | 122 | echo "<ul>" >> $RESULT_FILE | 
 | 123 |  | 
 | 124 | ## update, build, and test | 
 | 125 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` | 
 | 126 | F=svn-update.out | 
 | 127 | start=`current_time` | 
 | 128 | svn update >& build/$F | 
 | 129 | err=$? | 
 | 130 | update_status "Updating" "$F" $start | 
| Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 131 | if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 132 |     ## FIXME: we should check if this file has changed. | 
 | 133 |     ##  If it has changed, we should re-run the script to pick up changes. | 
 | 134 |     if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then | 
 | 135 |         exec $FULLPATHNAME $@ | 
 | 136 |     fi | 
 | 137 |  | 
 | 138 |     F=svn-stat.out | 
 | 139 |     start=`current_time` | 
 | 140 |     svn stat >& build/$F | 
 | 141 |     ## ignore some of the diffs | 
 | 142 |     NUM_DIFFS=`egrep -vc '^.      (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` | 
 | 143 |     update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start | 
 | 144 |  | 
 | 145 |     F=configure.out | 
 | 146 |     start=`current_time` | 
 | 147 |     ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F | 
 | 148 |     err=$? | 
 | 149 |     update_status "Configuring" "$F" $start | 
 | 150 |     if [ $err = 0 ]; then | 
 | 151 |         F=make.out | 
 | 152 |         start=`current_time` | 
 | 153 |         make >& build/$F | 
 | 154 |         err=$? | 
 | 155 |         warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` | 
 | 156 |         update_status "Building ($warnings warnings)" "$F" $start | 
 | 157 |         if [ $err = 0 ]; then | 
| Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 158 |             ## make install | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 159 |             F=make-install.out | 
 | 160 |             start=`current_time` | 
 | 161 |             make install >& build/$F | 
 | 162 |             update_status "Installing" "$F" $start | 
 | 163 |  | 
| Neal Norwitz | 9815f8b | 2006-07-26 04:00:18 +0000 | [diff] [blame] | 164 |             if [ ! -x $PYTHON ]; then | 
 | 165 |                 ln -s ${PYTHON}2.* $PYTHON | 
 | 166 |             fi | 
 | 167 |  | 
| Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 168 |             ## make and run basic tests | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 169 |             F=make-test.out | 
 | 170 |             start=`current_time` | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 171 |             $PYTHON $REGRTEST_ARGS >& build/$F | 
| Neal Norwitz | 7941552 | 2006-02-15 06:07:32 +0000 | [diff] [blame] | 172 |             NUM_FAILURES=`grep -ic " failed:" build/$F` | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 173 |             update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start | 
| Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 174 |             mail_on_failure "basics" build/$F | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 175 |  | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 176 |             F=make-test-opt.out | 
 | 177 |             start=`current_time` | 
 | 178 |             $PYTHON -O $REGRTEST_ARGS >& build/$F | 
 | 179 |             NUM_FAILURES=`grep -ic " failed:" build/$F` | 
 | 180 |             update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start | 
 | 181 |             mail_on_failure "opt" build/$F | 
 | 182 |  | 
| Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 183 |             ## run the tests looking for leaks | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 184 |             F=make-test-refleak.out | 
 | 185 |             start=`current_time` | 
| Neal Norwitz | 0f77da3 | 2006-04-17 01:48:41 +0000 | [diff] [blame] | 186 |             ## ensure that the reflog exists so the grep doesn't fail | 
 | 187 |             touch $REFLOG | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 188 |             $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F | 
| Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 189 |             NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG` | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 190 |             update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start | 
 | 191 |             mail_on_failure "refleak" $REFLOG | 
 | 192 |  | 
| Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 193 |             ## now try to run all the tests | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 194 |             F=make-testall.out | 
 | 195 |             start=`current_time` | 
| Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 196 |             ## skip curses when running from cron since there's no terminal | 
 | 197 |             ## skip sound since it's not setup on the PSF box (/dev/dsp) | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 198 |             $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F | 
| Neal Norwitz | 7941552 | 2006-02-15 06:07:32 +0000 | [diff] [blame] | 199 |             NUM_FAILURES=`grep -ic " failed:" build/$F` | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 200 |             update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start | 
| Neal Norwitz | d3a5867 | 2006-01-02 23:22:41 +0000 | [diff] [blame] | 201 |             mail_on_failure "all" build/$F | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 202 |         fi | 
 | 203 |     fi | 
 | 204 | fi | 
 | 205 |  | 
 | 206 |  | 
 | 207 | ## make doc | 
| Neal Norwitz | 524b59b | 2006-06-27 04:09:13 +0000 | [diff] [blame] | 208 | cd $DIR/Doc | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 209 | F="make-doc.out" | 
 | 210 | start=`current_time` | 
 | 211 | make >& ../build/$F | 
 | 212 | err=$? | 
 | 213 | update_status "Making doc" "$F" $start | 
 | 214 | if [ $err != 0 ]; then | 
 | 215 |     NUM_FAILURES=1 | 
 | 216 |     mail_on_failure "doc" ../build/$F | 
 | 217 | fi | 
 | 218 |  | 
 | 219 | echo "</ul>" >> $RESULT_FILE | 
 | 220 | echo "</body>" >> $RESULT_FILE | 
 | 221 | echo "</html>" >> $RESULT_FILE | 
 | 222 |  | 
 | 223 | ## copy results | 
| Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 224 | rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR | 
| Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 225 | cd ../build | 
 | 226 | rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ | 
| Neal Norwitz | 0a903ac | 2006-06-27 04:26:30 +0000 | [diff] [blame] | 227 |  |