--- /dev/null
+Automatic Build and Test Utility
+================================
+
+The tools found in this directory may be used to automate periodic
+building and regression testing of Varnish.
+
+
+Cron-based Invocation
+---------------------
+
+Start by installing autobuild.sh, mksummary.pl, and summary.html into
+an empty directory and configure cron(8) to run this new copy of
+autobuild.sh periodically.
+
+autobuild.sh will start by looking up the most recent revision number
+on the Subversion server and compare this number to the revision
+number of the last autobuild, which is kept in a file called
+LAST_TESTED_REVISION.
+
+If the numbers are identical, autobuild.sh will exit and be done.
+
+If not, the new revision is checked out, configured, built, installed
+into a directory tree under /tmp, and finally, tested using the
+regression test framework.
+
+The test result is extracted and the summary file, index.html is
+updated with the new result.
+
+A web-server may be used to make index.html and the sub-directories
+(which are the working directories of the individual autobuild runs)
+available to the world.
+
+
+Manual Invocation
+-----------------
+
+autobuild.sh may also be invoked manually and takes an optional
+argument which will be interpreted as a Subversion revision number.
+This revision will then be processed in the same way as described
+above.
+
+
+Working Directories
+-------------------
+
+Each time autobuild.sh builds and tests a revision, a working
+directory is created inside the directory where autobuild.sh is
+located. This working directory is used to hold the checked-out
+revision as well as log files generated during building and testing.
+The name of the working directory indicates the time (UTC) of its
+creation.
+
+In addition to the checked-out revision residing in the sub-directory
+"trunk", the following files are stored in a working directory:
+
+ svn.log - output to STDOUT and STDERR during Subversion checkout
+ build.log - output to STDOUT and STDERR during configure, build, and install
+ regress.log - output to STDOUT and STDERR during regression testing
+ regress.bin - Varnish's storage cache file during regression testing
+ regress.html - HTML-formatted result of regression testing
+ regress.status - summary of regress.html, used by mksummary.pl
+
+
+Summary file
+------------
+
+Currently, the overall summary file, index.html, is generated from
+scratch based on the currently present working directories, every time
+autobuild.sh completes successfully. The summary file is generated by
+the Perl script called mksummary.pl, using summary.html as template.
--- /dev/null
+#!/bin/sh -e
+
+# Copyright (c) 2007 Linpro AS
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $Id$
+#
+
+# Change to same directory as this script is located.
+cd "`dirname "$0"`"
+
+if [ "$1" != "" ]; then
+ # Make and change to working directory.
+ DIR="`date -u +varnish-%Y%m%d-%H%M%SZ`"
+ mkdir "$DIR"
+ cd "$DIR"
+
+ # Check out from Subversion.
+ svn co -r "$1" http://varnish.projects.linpro.no/svn/trunk > svn.log 2>&1
+
+ # Use most recent revision of regression test framework.
+ svn update trunk/varnish-tools/regress >> svn.log 2>&1
+
+ # Make status file.
+ echo "revision: $1" > regress.status
+else
+ # What is the current revision?
+ CURR="`svn info http://varnish.projects.linpro.no/svn/trunk | grep 'Revision: ' | sed 's/Revision: //'`"
+
+ # Compare to last tested revision and exit if we already tested
+ # this revision.
+ if [ -e LAST_TESTED_REVISION ]; then
+ LAST="`cat LAST_TESTED_REVISION`"
+ if [ "$CURR" = "$LAST" ]; then
+ exit 0;
+ fi
+ fi
+
+ # Okay, new revision. Here we go...
+
+ # Make and change to working directory.
+ DIR="`date -u +varnish-%Y%m%d-%H%M%SZ`"
+ mkdir "$DIR"
+ cd "$DIR"
+
+ # Check out from Subversion.
+ svn co -r "$CURR" http://varnish.projects.linpro.no/svn/trunk > svn.log 2>&1
+
+ # Make status file.
+ echo "revision: $CURR" > regress.status
+
+ # Update last revision status file.
+ echo "$CURR" > ../LAST_TESTED_REVISION
+fi
+
+# Build.
+(
+ cd trunk/varnish-cache
+ ./autogen.sh
+ ./configure --enable-debugging-symbols --enable-developer-warnings --enable-dependency-tracking --prefix=/tmp/"$DIR"
+ make
+ make install
+) > build.log 2>&1
+
+# Run regression test framework.
+PATH=/tmp/"$DIR"/sbin:"$PATH" trunk/varnish-tools/regress/varnish-regress.pl > regress.html 2> regress.log
+
+# Update status file.
+grep -A 4 '<th class="name">Total</th>' regress.html \
+ | sed 's/.*class="\([^"]*\)">\([^<]*\)<.*/\1: \2/' \
+ | tail -n +2 >> regress.status
+
+cd ..
+
+# Make summary file.
+./mksummary.pl varnish-*Z > index.html.new
+mv -f index.html.new index.html
+
+exit 0
--- /dev/null
+#!/usr/bin/perl -w
+#-
+# Copyright (c) 2007 Linpro AS
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer
+# in this position and unchanged.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $Id$
+#
+
+use strict;
+
+use Template;
+
+my %cache = ();
+
+foreach my $dir (@ARGV) {
+ open(STATUS, $dir . '/regress.status') or next;
+ while (<STATUS>) {
+ my ($name, $value) = split(/: /);
+ chomp($value) if defined($value);
+ $cache{$dir}{$name} = $value;
+ }
+ close(STATUS);
+}
+
+my @tests = ();
+
+foreach my $dir (sort({ $b cmp $a } keys(%cache))) {
+ if ($dir =~ /^varnish-(\d\d\d\d)(\d\d)(\d\d)-(\d\d)(\d\d)(\d\d)Z$/) {
+ $cache{$dir}{'title'} = "$1-$2-$3 $4:$5:$6 UTC";
+ $cache{$dir}{'link'} = $dir;
+ push(@tests, $cache{$dir});
+ }
+}
+
+my $template = new Template('TAG_STYLE' => 'html');
+$template->process('summary.html', { 'tests' => \@tests });
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Varnish automatic build and test summary</title>
+ <meta name="svnid" content="$Id$"/>
+ <style type="text/css">
+table { border-collapse: collapse; border: none; }
+td, th { border: thin solid black; padding: 3pt; text-align: left; white-space: nowrap; }
+thead, tfoot { background-color: #eeeeff; }
+tr.pass { background-color: #eeffee; }
+tr.fail { background-color: #ffeeee; }
+.time { text-align: right; }
+ </style>
+ </head>
+ <body>
+ <h1 class="title">Varnish automatic build and test summary</h1>
+ <table>
+ <thead>
+ <tr>
+ <th>Build and test time</th>
+ <th>Revision</th>
+ <th class="tests">Tests</th>
+ <th class="pass">Pass</th>
+ <th class="fail">Fail</th>
+ <th class="time">Test duration</th>
+ <th></th>
+ </tr>
+ </thead>
+<!-- FOREACH test = tests -->
+<!-- IF test.fail == 0 -->
+ <tr class="pass">
+<!-- ELSE -->
+ <tr class="fail">
+<!-- END -->
+ <td><a href="<!-- test.link -->/regress.html"><!-- test.title --></a></td>
+ <td><!-- test.revision --></td>
+ <td class="count"><!-- test.count --></td>
+ <td class="pass"><!-- test.pass --></td>
+ <td class="fail"><!-- test.fail --></td>
+ <td class="time"><!-- test.time --></td>
+ <td><a href="<!-- test.link -->/">working directory</a></td>
+ </tr>
+<!-- END -->
+ </table>
+ </body>
+</html>