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 | |
| 57 | REFLOG="build/reflog.txt.out" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 58 | # These tests are not stable and sometimes report leaks; however, |
| 59 | # test_generators really leaks. Since test_generators probably won't |
| 60 | # be fixed real soon, disable warning about it for now. |
| 61 | # The entire leak report will be mailed if any test not in this list leaks. |
Neal Norwitz | 4dc4a84 | 2006-03-06 23:04:04 +0000 | [diff] [blame] | 62 | LEAKY_TESTS="test_(capi|cfgparser|charmapcodec|cmd_line|compiler|filecmp|generators|quopri|socket|threaded_import|threadedtempfile|threading|threading_local|urllib2)" |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 63 | |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 64 | # Change this flag to "yes" for old releases to just update/build the docs. |
| 65 | BUILD_DISABLED="no" |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 66 | |
| 67 | ## utility functions |
| 68 | current_time() { |
| 69 | date +%s |
| 70 | } |
| 71 | |
| 72 | update_status() { |
| 73 | now=`current_time` |
| 74 | time=`expr $now - $3` |
| 75 | echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE |
| 76 | } |
| 77 | |
| 78 | mail_on_failure() { |
| 79 | if [ "$NUM_FAILURES" != "0" ]; then |
| 80 | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2 |
| 81 | fi |
| 82 | } |
| 83 | |
| 84 | ## setup |
| 85 | cd $DIR |
| 86 | mkdir -p build |
| 87 | rm -f $RESULT_FILE build/*.out |
| 88 | rm -rf $INSTALL_DIR |
| 89 | |
| 90 | ## create results file |
| 91 | TITLE="Automated Python Build Results" |
Neal Norwitz | b896759 | 2006-01-16 04:37:22 +0000 | [diff] [blame] | 92 | echo "<html>" >> $RESULT_FILE |
| 93 | echo " <head>" >> $RESULT_FILE |
| 94 | echo " <title>$TITLE</title>" >> $RESULT_FILE |
| 95 | echo " <meta http-equiv=\"refresh\" content=\"43200\">" >> $RESULT_FILE |
| 96 | echo " </head>" >> $RESULT_FILE |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 97 | echo "<body>" >> $RESULT_FILE |
| 98 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE |
| 99 | echo "<table>" >> $RESULT_FILE |
| 100 | echo " <tr>" >> $RESULT_FILE |
| 101 | echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE |
| 102 | echo " </tr><tr>" >> $RESULT_FILE |
| 103 | echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE |
| 104 | echo " </tr><tr>" >> $RESULT_FILE |
| 105 | echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE |
| 106 | echo " </tr>" >> $RESULT_FILE |
| 107 | echo "</table>" >> $RESULT_FILE |
| 108 | echo "<ul>" >> $RESULT_FILE |
| 109 | |
| 110 | ## update, build, and test |
| 111 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` |
| 112 | F=svn-update.out |
| 113 | start=`current_time` |
| 114 | svn update >& build/$F |
| 115 | err=$? |
| 116 | update_status "Updating" "$F" $start |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 117 | if [ $err = 0 -a "$BUILD_DISABLED" != "yes" ]; then |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 118 | ## FIXME: we should check if this file has changed. |
| 119 | ## If it has changed, we should re-run the script to pick up changes. |
| 120 | if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then |
| 121 | exec $FULLPATHNAME $@ |
| 122 | fi |
| 123 | |
| 124 | F=svn-stat.out |
| 125 | start=`current_time` |
| 126 | svn stat >& build/$F |
| 127 | ## ignore some of the diffs |
| 128 | NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` |
| 129 | update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start |
| 130 | |
| 131 | F=configure.out |
| 132 | start=`current_time` |
| 133 | ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F |
| 134 | err=$? |
| 135 | update_status "Configuring" "$F" $start |
| 136 | if [ $err = 0 ]; then |
| 137 | F=make.out |
| 138 | start=`current_time` |
| 139 | make >& build/$F |
| 140 | err=$? |
| 141 | warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` |
| 142 | update_status "Building ($warnings warnings)" "$F" $start |
| 143 | if [ $err = 0 ]; then |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 144 | ## make install |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 145 | F=make-install.out |
| 146 | start=`current_time` |
| 147 | make install >& build/$F |
| 148 | update_status "Installing" "$F" $start |
| 149 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 150 | ## make and run basic tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 151 | F=make-test.out |
| 152 | start=`current_time` |
| 153 | make test >& build/$F |
Neal Norwitz | 7941552 | 2006-02-15 06:07:32 +0000 | [diff] [blame] | 154 | NUM_FAILURES=`grep -ic " failed:" build/$F` |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 155 | update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | a39f057 | 2006-01-03 00:33:50 +0000 | [diff] [blame] | 156 | ## FIXME: should mail since -uall below should find same problems |
Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 157 | mail_on_failure "basics" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 158 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 159 | ## run the tests looking for leaks |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 160 | F=make-test-refleak.out |
| 161 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 162 | ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network >& build/$F |
Neal Norwitz | f415d5f | 2006-02-19 18:48:19 +0000 | [diff] [blame] | 163 | NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG` |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 164 | update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start |
| 165 | mail_on_failure "refleak" $REFLOG |
| 166 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 167 | ## now try to run all the tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 168 | F=make-testall.out |
| 169 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 170 | ## skip curses when running from cron since there's no terminal |
| 171 | ## skip sound since it's not setup on the PSF box (/dev/dsp) |
| 172 | ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F |
Neal Norwitz | 7941552 | 2006-02-15 06:07:32 +0000 | [diff] [blame] | 173 | NUM_FAILURES=`grep -ic " failed:" build/$F` |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 174 | 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] | 175 | mail_on_failure "all" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 176 | fi |
| 177 | fi |
| 178 | fi |
| 179 | |
| 180 | |
| 181 | ## make doc |
| 182 | cd Doc |
| 183 | F="make-doc.out" |
| 184 | start=`current_time` |
| 185 | make >& ../build/$F |
| 186 | err=$? |
| 187 | update_status "Making doc" "$F" $start |
| 188 | if [ $err != 0 ]; then |
| 189 | NUM_FAILURES=1 |
| 190 | mail_on_failure "doc" ../build/$F |
| 191 | fi |
| 192 | |
| 193 | echo "</ul>" >> $RESULT_FILE |
| 194 | echo "</body>" >> $RESULT_FILE |
| 195 | echo "</html>" >> $RESULT_FILE |
| 196 | |
| 197 | ## copy results |
Neal Norwitz | 88b78d8 | 2006-02-14 08:14:16 +0000 | [diff] [blame] | 198 | rsync $RSYNC_OPTS html/* $REMOTE_SYSTEM:$REMOTE_DIR |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 199 | cd ../build |
| 200 | rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ |
| 201 | |