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" |
| 48 | #FAILURE_MAILTO="python-checkins@python.org" |
| 49 | #FAILURE_MAILTO="YOUR_ACCOUNT@gmail.com" |
| 50 | FAILURE_MAILTO="nnorwitz@gmail.com" |
| 51 | |
| 52 | REMOTE_SYSTEM="neal@dinsdale.python.org" |
| 53 | REMOTE_DIR="/data/ftp.python.org/pub/docs.python.org/dev/" |
| 54 | RESULT_FILE="$DIR/build/index.html" |
| 55 | INSTALL_DIR="/tmp/python-test/local" |
| 56 | RSYNC_OPTS="-aC -e ssh" |
| 57 | |
| 58 | REFLOG="build/reflog.txt.out" |
| 59 | |
| 60 | ## utility functions |
| 61 | current_time() { |
| 62 | date +%s |
| 63 | } |
| 64 | |
| 65 | update_status() { |
| 66 | now=`current_time` |
| 67 | time=`expr $now - $3` |
| 68 | echo "<li><a href=\"$2\">$1</a> <font size=\"-1\">($time seconds)</font></li>" >> $RESULT_FILE |
| 69 | } |
| 70 | |
| 71 | mail_on_failure() { |
| 72 | if [ "$NUM_FAILURES" != "0" ]; then |
| 73 | mutt -s "$FAILURE_SUBJECT $1 ($NUM_FAILURES)" $FAILURE_MAILTO < $2 |
| 74 | fi |
| 75 | } |
| 76 | |
| 77 | ## setup |
| 78 | cd $DIR |
| 79 | mkdir -p build |
| 80 | rm -f $RESULT_FILE build/*.out |
| 81 | rm -rf $INSTALL_DIR |
| 82 | |
| 83 | ## create results file |
| 84 | TITLE="Automated Python Build Results" |
| 85 | echo "<html><head><title>$TITLE</title></head>" >> $RESULT_FILE |
| 86 | echo "<body>" >> $RESULT_FILE |
| 87 | echo "<h2>Automated Python Build Results</h2>" >> $RESULT_FILE |
| 88 | echo "<table>" >> $RESULT_FILE |
| 89 | echo " <tr>" >> $RESULT_FILE |
| 90 | echo " <td>Built on:</td><td>`date`</td>" >> $RESULT_FILE |
| 91 | echo " </tr><tr>" >> $RESULT_FILE |
| 92 | echo " <td>Hostname:</td><td>`uname -n`</td>" >> $RESULT_FILE |
| 93 | echo " </tr><tr>" >> $RESULT_FILE |
| 94 | echo " <td>Platform:</td><td>`uname -srmpo`</td>" >> $RESULT_FILE |
| 95 | echo " </tr>" >> $RESULT_FILE |
| 96 | echo "</table>" >> $RESULT_FILE |
| 97 | echo "<ul>" >> $RESULT_FILE |
| 98 | |
| 99 | ## update, build, and test |
| 100 | ORIG_CHECKSUM=`cksum $FULLPATHNAME` |
| 101 | F=svn-update.out |
| 102 | start=`current_time` |
| 103 | svn update >& build/$F |
| 104 | err=$? |
| 105 | update_status "Updating" "$F" $start |
| 106 | if [ $err = 0 ]; then |
| 107 | ## FIXME: we should check if this file has changed. |
| 108 | ## If it has changed, we should re-run the script to pick up changes. |
| 109 | if [ "$ORIG_CHECKSUM" != "$ORIG_CHECKSUM" ]; then |
| 110 | exec $FULLPATHNAME $@ |
| 111 | fi |
| 112 | |
| 113 | F=svn-stat.out |
| 114 | start=`current_time` |
| 115 | svn stat >& build/$F |
| 116 | ## ignore some of the diffs |
| 117 | NUM_DIFFS=`egrep -vc '^. (@test|db_home|Lib/test/(regrtest\.py|db_home))$' build/$F` |
| 118 | update_status "svn stat ($NUM_DIFFS possibly important diffs)" "$F" $start |
| 119 | |
| 120 | F=configure.out |
| 121 | start=`current_time` |
| 122 | ./configure --prefix=$INSTALL_DIR --with-pydebug >& build/$F |
| 123 | err=$? |
| 124 | update_status "Configuring" "$F" $start |
| 125 | if [ $err = 0 ]; then |
| 126 | F=make.out |
| 127 | start=`current_time` |
| 128 | make >& build/$F |
| 129 | err=$? |
| 130 | warnings=`grep warning build/$F | egrep -vc "te?mpnam(_r|)' is dangerous,"` |
| 131 | update_status "Building ($warnings warnings)" "$F" $start |
| 132 | if [ $err = 0 ]; then |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 133 | ## make install |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 134 | F=make-install.out |
| 135 | start=`current_time` |
| 136 | make install >& build/$F |
| 137 | update_status "Installing" "$F" $start |
| 138 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 139 | ## make and run basic tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 140 | F=make-test.out |
| 141 | start=`current_time` |
| 142 | make test >& build/$F |
| 143 | NUM_FAILURES=`grep -ic fail build/$F` |
| 144 | update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start |
Neal Norwitz | a39f057 | 2006-01-03 00:33:50 +0000 | [diff] [blame] | 145 | ## FIXME: should mail since -uall below should find same problems |
Neal Norwitz | 02c408d | 2006-01-03 02:18:01 +0000 | [diff] [blame] | 146 | mail_on_failure "basics" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 147 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 148 | ## run the tests looking for leaks |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 149 | F=make-test-refleak.out |
| 150 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 151 | ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network >& build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 152 | NUM_FAILURES=`grep -ic leak $REFLOG` |
| 153 | update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start |
| 154 | mail_on_failure "refleak" $REFLOG |
| 155 | |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 156 | ## now try to run all the tests |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 157 | F=make-testall.out |
| 158 | start=`current_time` |
Neal Norwitz | d19a4d4 | 2006-01-02 22:10:10 +0000 | [diff] [blame] | 159 | ## skip curses when running from cron since there's no terminal |
| 160 | ## skip sound since it's not setup on the PSF box (/dev/dsp) |
| 161 | ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 162 | NUM_FAILURES=`grep -ic fail build/$F` |
| 163 | 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] | 164 | mail_on_failure "all" build/$F |
Neal Norwitz | 461aa5b | 2006-01-02 20:07:16 +0000 | [diff] [blame] | 165 | fi |
| 166 | fi |
| 167 | fi |
| 168 | |
| 169 | |
| 170 | ## make doc |
| 171 | cd Doc |
| 172 | F="make-doc.out" |
| 173 | start=`current_time` |
| 174 | make >& ../build/$F |
| 175 | err=$? |
| 176 | update_status "Making doc" "$F" $start |
| 177 | if [ $err != 0 ]; then |
| 178 | NUM_FAILURES=1 |
| 179 | mail_on_failure "doc" ../build/$F |
| 180 | fi |
| 181 | |
| 182 | echo "</ul>" >> $RESULT_FILE |
| 183 | echo "</body>" >> $RESULT_FILE |
| 184 | echo "</html>" >> $RESULT_FILE |
| 185 | |
| 186 | ## copy results |
| 187 | rsync $RSYNC_OPTS html/ $REMOTE_SYSTEM:$REMOTE_DIR |
| 188 | cd ../build |
| 189 | rsync $RSYNC_OPTS index.html *.out $REMOTE_SYSTEM:$REMOTE_DIR/results/ |
| 190 | |