← Back to team overview

ubuntu-server-iso-testing-dev team mailing list archive

[Merge] lp:~jibel/ubuntu-server-iso-testing/wubi into lp:ubuntu-server-iso-testing

 

Jean-Baptiste Lallement has proposed merging lp:~jibel/ubuntu-server-iso-testing/wubi into lp:ubuntu-server-iso-testing.

Requested reviews:
  Ubuntu Server Iso Testing Developers (ubuntu-server-iso-testing-dev)

For more details, see:
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/wubi/+merge/69132

There is very little interaction with other pieces of USIT as most of the work is done on Windows side.
If anyone is interested in reviewing this I'll be happy to discuss with him, otherwise I'll go ahead and merge.

There are still a few bits of documentation missing like how to deploy the Jenkins script and add other flavors (support is there but untested)

A piece of code related to logging need to be moved from wubi-test.sh to the master script but that is not critical.
-- 
https://code.launchpad.net/~jibel/ubuntu-server-iso-testing/wubi/+merge/69132
Your team Ubuntu Server Iso Testing Developers is requested to review the proposed merge of lp:~jibel/ubuntu-server-iso-testing/wubi into lp:ubuntu-server-iso-testing.
=== added directory 'wubi'
=== added file 'wubi/README'
--- wubi/README	1970-01-01 00:00:00 +0000
+++ wubi/README	2011-07-25 16:56:01 +0000
@@ -0,0 +1,118 @@
+= Introduction =
+This document describes automated wubi testing
+
+= Setup =
+The test is installed on the Windows side.
+The general process is:
+1. Trigger the test if
+  - A new version of wubi is available
+  or
+  - A new Ubuntu Desktop ISO (i386|mad64) is available
+  
+2. Download Wubi if needed
+3. Download the required ISO if needed.
+4. Run Wubi
+5. Reboot and install Ubuntu
+6. Reboot to Ubuntu, run the tests and report the results
+7. Restore the system and boot back to Windows for next run.
+
+Directory Structure
+./bin    
+./bin/functions                                                       General purpose functions
+./bin/run-test.sh                                                     Main test script
+./data                                                                Data Directory
+./data/custom-installation                                            Contains the scripts to be run by casper
+./data/custom-installation/packages                                   Packages in this directory are installed on the target
+./data/custom-installation/target-override                            Content is copied as-is to target
+./data/custom-installation/target-override/etc
+./data/custom-installation/target-override/etc/rc.local               Setup the target and launch the tests
+./data/custom-installation/target-override/usr
+./data/custom-installation/target-override/usr/local
+./data/custom-installation/target-override/usr/local/bin
+./data/custom-installation/target-override/usr/local/bin/run_test     The test runner
+./data/custom-installation/target-override/usr/local/tests            Contains the tests to run on target
+./data/iso                                                            Download directory (ISOs and wubi.exe) Wubi and the ISO must be in the same directory to use --isopath
+./data/wubi.list                                                      The expected content of DRIVE/ubuntu on the host after wubi installation. Used to check the integrity of the installation
+./log                                                                 Log directory
+./results                                                             Results to push to jenkins
+
+
+= Run Test Script =
+== Preliminary steps ==
+On the test system:
+- Download ISO 
+- Download wubi.exe
+Both tasks should be done by a separate jenkins task (as we do for the other iso tests)
+
+== Step 1: Windows side ==
+Execute run-test.sh with the name of the ISO or the architecture to test.
+Without argument it will install the latest ISO for the architecture the test runs on.
+wubi.exe and the ISO must be in the same directory (TODO: File a bug)
+
+=== wubi-test.sh ===
+1. Uninstall Wubi if a previous installation exists
+2. Install Wubi non-interactively with the ISO passed on the command line or download a new iso if required.
+3. Copy the testing material from ./data/custom-installation to C:/ubuntu/install/custom-installation 
+    This files will be copied to /root/custom-installatio on the target.
+4. Restart system and proceed with step 2
+== Step 2: Ubuntu site ==
+1. Boots directly to linux
+2. Installs Ubuntu
+    At the end of the installation the content of /root/custom-installation is copied to /target/
+    rc.local will start the tests on next reboot.
+3. Reboot to Ubuntu
+4. Run rc.local script:
+   4.1 Install the prerequisites and setup the system for the test
+   4.2 Execute /usr/local/bin/run_test which will run the tests in /usr/local/tests/ (python unittests)
+   4.3 Write the results to the run directory in xUnit format
+
+= Master Script - run-test.sh =
+ * For each $RELEASE $FLAVOR $ARCH
+   * If test has not started:
+     * Trigger remote build on phad
+     * sync logs
+     * Sync the image
+     * Extract wubi.exe
+     * chmod +x wubi.exe
+     * sync logs
+     * run test phase 1 (sync logs before reboot)
+   * else if phase 2 as not started
+     * run test phase 2 (sync logs before reboot)
+   * else
+     * sync the log on more time excepted result.xml
+     * sync result.xml
+* List of tests to run in $RUNDIR/job.list
+* Maintain job state in a file in $RUNDIR/job.state
+
+= Integration with Jenkins =
+ * Trigger a remote build on run start.
+ * Jenkins job
+   * Wait until timeout is reached or job is completed
+   * Job is completed if a specific file is on the Jenkins slave (wazn)
+ * Wubi job
+   * At start, trigger the remote job
+   * At each step of the test, sync the current run directory to wazn
+   * At the end of the run do a last sync + copy a flag to indicate the end of the run
+
+= General Notes =
+== Resources ==
+https://wiki.ubuntu.com/WubiGuide
+https://launchpad.net/ubuntu/+spec/foundations-o-wubi
+https://launchpad.net/wubi
+=== Remote Access to the Wubi machine ===
+  How to run the OpenSSH SSHD server on Windows using Cygwin
+Install the following Cygwin packages (rerun setup if necessary -- you can    add packages after you have already installed Cygwin).
+  
+ Admin --> cygrunsrv
+    Net --> openssh
+Open a new bash shell window and run the SSH configure stuff.
+  
+ssh-host-config -y
+This step will create necessary configuration files, a priviledge separation    user and necessary directories.
+When prompted with "CYGWIN=" type for following:
+  
+tty ntsec
+Now you are ready to start the service.
+  
+cygrunsrv -S sshd
+

=== added directory 'wubi/bin'
=== added file 'wubi/bin/Wubi Test.bat'
--- wubi/bin/Wubi Test.bat	1970-01-01 00:00:00 +0000
+++ wubi/bin/Wubi Test.bat	2011-07-25 16:56:01 +0000
@@ -0,0 +1,6 @@
+@echo off
+
+C:
+chdir C:\cygwin\home\ubuntu\wubitest
+
+\cygwin\bin\bash.exe --login -c "cd ~/wubitest/; ./bin/test-wubi.sh -r --isopath=data/iso/oneiric-desktop-amd64.iso "

=== added file 'wubi/bin/bcdedit.exe'
Binary files wubi/bin/bcdedit.exe	1970-01-01 00:00:00 +0000 and wubi/bin/bcdedit.exe	2011-07-25 16:56:01 +0000 differ
=== added file 'wubi/bin/config'
--- wubi/bin/config	1970-01-01 00:00:00 +0000
+++ wubi/bin/config	2011-07-25 16:56:01 +0000
@@ -0,0 +1,8 @@
+# Wubi Testing configuration file
+#
+# Must be valid shell script
+JENKINS_MASTER="phad"
+JENKINS_SLAVE="wazn"
+JENKINS_TOKEN="aHidyaw7gratFen9"
+JENKINS_URL="localhost:8080"
+

=== added file 'wubi/bin/functions'
--- wubi/bin/functions	1970-01-01 00:00:00 +0000
+++ wubi/bin/functions	2011-07-25 16:56:01 +0000
@@ -0,0 +1,39 @@
+# #!/bin/sh
+#
+# Utility functions
+
+log_msg() {
+    printf "$(date '+%F %X'): $@"
+}
+
+log_info_msg() {
+    log_msg "Info: $@\n"
+}
+
+log_success_msg() {
+    log_msg "Success: $@\n"
+}
+
+log_failure_msg() {
+    log_msg "Failure: $@\n"
+}
+
+log_warning_msg() {
+    log_msg "Warning: $@\n"
+}
+
+log_begin_msg() {
+    log_msg "Begin: $@ ... "
+}
+
+log_end_msg() {
+    printf "done.\n"
+}
+
+log_start_job() {
+    log_msg "Starting Job: $@\n"
+}
+
+log_end_job() {
+    log_msg "Job Finished: $@\n"
+}

=== added file 'wubi/bin/poll-wubi-results.sh'
--- wubi/bin/poll-wubi-results.sh	1970-01-01 00:00:00 +0000
+++ wubi/bin/poll-wubi-results.sh	2011-07-25 16:56:01 +0000
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# This job wait for wubi test to finish
+# It is triggered remotely by a remote build call from the wubi host
+# 
+# An xml file in RESULTPATH is the condition to end the job
+# Otherwise it ends at when TIMEOUT is reached.
+#
+echo "Test Start"
+env
+
+START=$(date +%s)
+TIMEOUT=30
+SLEEPTIME=5
+
+BASERESULTDIR=/tmp/${FLAVOR}_${RELEASE}_${ARCH}_${PRESEED}
+TESTRESULTDIR=test-results
+RESULTPATH=$WORKSPACE/$BUILD_NUMBER
+
+mkdir -p $RESULTPATH
+mkdir -p $BASERESULTDIR
+
+while true; do
+    NOW=$(date +%s)
+
+    rsync -r $BASERESULTDIR/$TESTRESULTDIR $RESULTPATH
+
+    if ls $RESULTPATH/$TESTRESULTDIR/ | grep -q 'xml$'; then
+        echo "Results found"
+        break
+    fi
+    if [ $(( $NOW - $START )) -gt $TIMEOUT ]; then
+        echo "Time out!"
+        break
+    fi
+    sleep $SLEEPTIME
+done
+
+echo "Test End"

=== added file 'wubi/bin/run-test.sh'
--- wubi/bin/run-test.sh	1970-01-01 00:00:00 +0000
+++ wubi/bin/run-test.sh	2011-07-25 16:56:01 +0000
@@ -0,0 +1,168 @@
+#/bin/sh
+# Copyright (C) 2011, Canonical Ltd (http://www.canonical.com/)
+#
+# Automated Wubi installation testing
+# 
+# This software is free software: you can redistribute it 
+# and/or modify it under the terms of the GNU General Public License 
+# as published by the Free Software Foundation, either version 3 of 
+# the License, or (at your option) any later version.
+# 
+# This software is distributed in the hope that it will 
+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this software.  If not, see <http://www.gnu.org/licenses/>.
+# 
+
+JOBNAME="Wubi Test"
+
+BASEDIR="$(dirname $0)/.."
+BINDIR="$BASEDIR/bin"
+DATADIR="$BASEDIR/data"
+CUSTOMDIR="$DATADIR/custom-installation"
+RUNDIR=$BASEDIR/run
+LOGFILE=$RUNDIR/latest/$(basename $0 .sh).log
+STATEFILE=$RUNDIR/job.state
+STATE=""
+
+. $BINDIR/functions
+. $BINDIR/config
+
+WUBIEXE="wubi.exe"
+
+# Default Values
+FLAVOR="ubuntu"
+RELEASE="oneiric"
+ARCH="i386"
+TEST="default"
+VARIANT="desktop" # Always desktop for Wubi
+
+# Default values are overridden by those in statefile
+# if a job is already running
+# Then args passed on commandline
+[ -f "$STATEFILE" ] && . $STATEFILE
+
+usage() {
+	cat<<EOF
+Usage: $(basename $0) [OPTIONS...]
+
+  -f, --flavor FLAVOR      Select specific flavor to test ($FLAVOR)
+  -r, --release RELEASE    Select release to test ($RELEASE)
+  -a, --arch ARCH          Select architecture to test ($ARCH)
+  -t, --test TEST          Select test to run ($TEST)
+  -h, --help               This help
+EOF
+	exit 1
+}
+
+run_test () {
+    # Run the test
+    log_info_msg "Running test for $1"
+    #$BINDIR/wubi-test.sh -r --isopath=$1
+}
+
+write_state() {
+    STATE=$1
+    cat<<EOF>${STATEFILE}
+RELEASE=$RELEASE
+FLAVOR=$FLAVOR
+ARCH=$ARCH
+TEST=$TEST
+LOGFILE=$LOGFILE
+STATE=$1
+EOF
+
+}
+
+TEMP=$(getopt -o f:r:a:t:h --long help,flavor:,release:,arch:,test: -- "$@")
+eval set -- "$TEMP"
+
+while true ; do
+    case "$1" in
+        -h|--help) 
+            usage;;
+        -f|--flavor)
+            FLAVOR=$2
+            shift 2;;
+        -r|--release) 
+            RELEASE=$2
+            shift 2 ;;
+        -a|--arch) 
+            ARCH=$2
+            shift 2 ;;
+        -t|--test)
+            TEST=$2
+            shift 2 ;;
+        --) shift ; break ;;
+        *) usage;;
+    esac
+done
+
+
+exec 2>&1
+
+log_info_msg "Log saved to $LOGFILE"
+
+exec 1>>$LOGFILE
+
+log_start_job "$JOBNAME"
+trap "log_end_job \"$JOBNAME\"" EXIT QUIT
+
+JENKINS_JOB=${FLAVOR}_${VARIANT}-${ARCH}_wubi-${TEST}
+ISODIR=$DATADIR/iso/${FLAVOR}
+
+FLAVORPART="${FLAVOR}/"
+[  $FLAVOR == "ubuntu" ] && FLAVORPART=""
+
+ISONAME="${RELEASE}-${VARIANT}-${ARCH}.iso"
+ISOPATH=$ISODIR/$ISONAME
+ZSYNCURL=http://cdimage.ubuntu.com/${FLAVORPART}daily-live/current/${ISONAME}.zsync
+
+if [ ! -f "$STATEFILE" ]; then
+    log_info_msg "State file $STATEFILE not found. Starting new job"
+    # No state file, create a new job
+    # Start remote jenkins task
+    write_state "start-build"
+    JOBURL="http://${JENKINS_URL}/job/$JENKINS_JOB/buildWithParameters?token=$JENKINS_TOKEN";
+    log_info_msg "Starting remote build $JOBURL"
+    ssh $JENKINS_MASTER wget '$JOBURL' -o /dev/null
+
+    # Write state change
+    # Sync result to notify start
+    # Download image from cdimage.u.c
+    write_state "sync"
+    mkdir -p $ISODIR
+    cd $ISODIR
+    log_info_msg "Syncing $ZSYNCURL to $ISODIR"
+    zsync $ZSYNCURL
+
+    # Extract wubi.exe
+    log_info_msg "Extracting $WUBIEXE from $ISONAME"
+    bsdtar.exe xf $ISONAME $WUBIEXE
+    cd -
+
+    write_state "running"
+
+    log_info_msg "Starting Stage 1"
+    # This command will restart the system, so nothing can be done after this.
+    run_test $ISOPATH
+elif [ "$STATE" == "running" ]; then
+    log_info_msg "Starting Stage 2"
+    write_state "report"
+    run_test $ISOPATH
+elif [ "$STATE" == "report" ]; then
+    log_info_msg "Syncing results"
+    # Last step report slave and remove state file for next run
+    # Sync the files
+    rsync -avz --del run/latest/ $JENKINS_SLAVE:~/test-results
+    rm $STATEFILE
+else
+    log_warning_msg "Unknown state: $STATE"
+    log_warning_msg "Aborting!"
+    exit 1
+fi
+
+log_end_msg 

=== added file 'wubi/bin/ubuntu.ico'
Binary files wubi/bin/ubuntu.ico	1970-01-01 00:00:00 +0000 and wubi/bin/ubuntu.ico	2011-07-25 16:56:01 +0000 differ
=== added file 'wubi/bin/wubi-test.sh'
--- wubi/bin/wubi-test.sh	1970-01-01 00:00:00 +0000
+++ wubi/bin/wubi-test.sh	2011-07-25 16:56:01 +0000
@@ -0,0 +1,223 @@
+#/bin/sh
+# Copyright (C) 2011, Canonical Ltd (http://www.canonical.com/)
+#
+# Automated Wubi installation testing
+# 
+# This software is free software: you can redistribute it 
+# and/or modify it under the terms of the GNU General Public License 
+# as published by the Free Software Foundation, either version 3 of 
+# the License, or (at your option) any later version.
+# 
+# This software is distributed in the hope that it will 
+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this software.  If not, see <http://www.gnu.org/licenses/>.
+# 
+
+# TODO: 
+#  - Verify that Windows stage is complete and write results somewhere (Use unittest ?)
+#    - The following files are on C:/ : wubildr and wubildr.mbr
+#    - TARGET_DRIVE/ubuntu is a directory
+#    - Verify the content of $TARGET_DRIVE/ubuntu
+#  - Add other releases
+
+
+JOBNAME="Wubi Test"
+
+BASEDIR="$(dirname $0)/.."
+BINDIR="$BASEDIR/bin"
+DATADIR="$BASEDIR/data"
+CUSTOMDIR="$DATADIR/custom-installation"
+RUNDIR=$BASEDIR/run
+LOGFILE=$RUNDIR/latest/$(basename $0 .sh).log
+
+. $BINDIR/functions
+
+DRIVE="c"
+I386=""
+ISOPATH=""
+REBOOT=""
+USERNAME="ubuntu"
+PASSWORD="ubuntu"
+WUBIEXE="$DATADIR/iso/wubi.exe"
+
+TIMEOUT=3600 # Wubi run asynchronously. Need to wait to it to finish and download takes time
+
+usage() {
+	cat<<EOF
+Usage: $(basename $0) [OPTIONS...]
+
+  -d, --drive=TARGET_DRIVE Target drive (Default ${DRIVE}:)
+  -i, --isopath=FILE       Use specified ISO (Downloaded if unspecified)
+  -r, --reboot             Reboot after installation
+  -x, --32bit              Force installation of 32bit version
+  -h, --help               This help
+EOF
+	exit 1
+}
+
+get_bootid() {
+    # Return Window's bootid for the boot entry with 'name'
+
+    name=$1
+    if [ -z "$name" ]; then
+        return
+    fi
+    bootid=$( $BINDIR/bcdedit.exe |grep -B3 "$name" |grep identifier|awk '{print $2}' )
+    echo $bootid
+}
+
+TEMP=$(getopt -o hd:i:rx --long help,drive:,reboot,isopath:,32bit -- "$@")
+eval set -- "$TEMP"
+
+while true ; do
+    case "$1" in
+        -h|--help) 
+            usage;;
+        -d|--drive) 
+            DRIVE=$2
+            shift 2 ;;
+        -i|--isopath) 
+            ISOPATH=$2
+            shift 2 ;;
+        -r|--reboot)
+            REBOOT="Y"
+            shift;;
+        -x|--32bit)
+            I386="--32bit"
+            shift;;
+        --) shift ; break ;;
+        *) usage;;
+    esac
+done
+
+
+exec 2>&1
+
+if [ -f "$RUNDIR/latest/stage2" ]; then
+    exec 1>>$LOGFILE
+    log_start_job "$JOBNAME : Stage 2"
+
+    # Just grep 'buntu' to catch derivatives as well
+    # It will be used to set default boot entry for stage 2 of the test
+    bootid=$(get_bootid "buntu")
+
+    if [ -z "$bootid" ]; then
+        log_failure_msg "Boot entry for Ubuntu not found. Aborting."
+        exit 3
+    fi
+
+    log_info_msg "Setting $bootid entry as default for next reboot"
+    $BINDIR/bcdedit.exe /bootsequence $bootid
+
+    if [ "$REBOOT" == "Y" ]; then
+        # Reboot
+        log_info_msg "Rebooting"
+        shutdown.exe /r /f /t 5 
+    fi
+    log_end_msg 
+    exit 0
+fi
+
+if [ -d $RUNDIR/latest ]; then
+    log_begin_msg "Backup previous log dir to $RUNDIR/$(date '+%Y%m%d-%H%M%S')"
+    mv $RUNDIR/latest $RUNDIR/$(date '+%Y%m%d-%H%M%S')
+    log_end_msg
+fi
+mkdir -p $RUNDIR/latest
+
+log_info_msg "Log saved to $LOGFILE"
+
+exec 1>>$LOGFILE
+
+log_start_job "$JOBNAME"
+trap "log_end_job \"$JOBNAME\"" EXIT QUIT
+
+if [ ! -x "$WUBIEXE" ]; then
+    log_failure_msg "'$WUBIEXE' not found"
+    exit 1
+fi
+
+#WUBIARGS="--password=$PASSWORD --username=$USERNAME --noninteractive --skipmd5check --log-file=$WUBILOG"
+WUBIARGS="--password=$PASSWORD --username=$USERNAME --noninteractive --skipmd5check"
+if [ ! -z "$ISOPATH" ]; then
+    if [ ! -f "$ISOPATH" ]; then
+        log_failure_msg "File doesn't exist '$ISOPATH'"
+        exit 1
+    fi
+
+    MIMETYPE=$( file -bi "$ISOPATH" )
+    if ! echo "$MIMETYPE" | grep -q iso9660; then
+        log_failure_msg "'$ISOPATH' is not a valid ISO (mimetype: $MIMETYPE)"
+        exit 1
+    fi
+
+    # If an image and 32bit are specified on the command line then check that the image is not 64bit
+    if basename "$ISOPATH" | grep -q "amd64"; then
+        if [ ! -z "$I386" ]; then
+            log_failure_msg "You forced installation of 32bit version but the image is 64bit" 
+            exit 1
+        fi
+    else
+        I386="--32bit"
+    fi
+fi
+
+if [ ! -z "$ISOPATH" ]; then
+    ISOPATH="--isopath=$ISOPATH"
+fi
+
+WUBIARGS="$WUBIARGS $I386 $ISOPATH"
+
+log_begin_msg "Uninstalling previous install"
+$WUBIEXE --uninstall --noninteractive
+
+# Take some breath
+sleep 5
+log_end_msg
+
+log_info_msg "Running $(basename $WUBIEXE) $WUBIARGS"
+$WUBIEXE $WUBIARGS
+
+STARTTIME=$(date +%s)
+while true; do
+    currtime=$(date +%s)
+    timediff=$(( $currtime - $STARTTIME ))
+
+    if [ $timediff -gt $TIMEOUT ]; then
+        log_failure_msg "Wubi still running after $TIMEOUT seconds. Aborting!"
+        exit 2
+    fi
+    if ! ps -W | grep -q "pyrun.exe"; then
+        log_info_msg "Wubi installation done (took ${timediff}s)"
+        break
+    fi
+    log_info_msg "Waiting for wubi to finish. running for ${timediff}s"
+    sleep 1
+done
+
+TARGET_CUSTOMDIR=/cygdrive/${DRIVE}/ubuntu/install/custom-installation
+
+# Load casper custome-installation directory with tests
+log_begin_msg "Copying $(basename $CUSTOMDIR) to $TARGET_CUSTOMDIR"
+cp -af $CUSTOMDIR/* $TARGET_CUSTOMDIR || true
+log_end_msg
+
+log_begin_msg "Saving Wubi log file"
+mv /tmp/wubi*.log $RUNDIR/latest/
+log_end_msg
+
+log_begin_msg "Preparing for stage 2"
+touch $RUNDIR/latest/stage2
+log_end_msg
+
+if [ "$REBOOT" == "Y" ]; then
+    # Reboot
+    log_info_msg "Rebooting"
+    shutdown.exe /r /f /t 5 
+fi
+
+log_end_msg 

=== added directory 'wubi/data'
=== added directory 'wubi/data/custom-installation'
=== added directory 'wubi/data/custom-installation/packages'
=== added directory 'wubi/data/custom-installation/target-override'
=== added directory 'wubi/data/custom-installation/target-override/etc'
=== added file 'wubi/data/custom-installation/target-override/etc/rc.local'
--- wubi/data/custom-installation/target-override/etc/rc.local	1970-01-01 00:00:00 +0000
+++ wubi/data/custom-installation/target-override/etc/rc.local	2011-07-25 16:56:01 +0000
@@ -0,0 +1,24 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+#
+# By default this script does nothing.
+
+JOBNAME="wubitest"
+logger -t $JOBNAME "Installing prerequisites"
+apt-get install -y openssh-server python-couchdb subunit python-subunit python-junitxml|logger -t $JOBNAME
+
+RUNTEST=/usr/local/bin/run_test
+if [ -x "$RUNTEST" ]; then
+    logger -t $JOBNAME "Starting $RUNTEST"
+    sudo $RUNTEST|logger -t $JOBNAME
+else
+    logger -t $JOBNAME "Error: File not found '$RUNTEST'"
+fi

=== added directory 'wubi/data/custom-installation/target-override/usr'
=== added directory 'wubi/data/custom-installation/target-override/usr/local'
=== added directory 'wubi/data/custom-installation/target-override/usr/local/bin'
=== added file 'wubi/data/custom-installation/target-override/usr/local/bin/run_test'
--- wubi/data/custom-installation/target-override/usr/local/bin/run_test	1970-01-01 00:00:00 +0000
+++ wubi/data/custom-installation/target-override/usr/local/bin/run_test	2011-07-25 16:56:01 +0000
@@ -0,0 +1,56 @@
+#!/bin/sh
+# 
+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
+#
+# This file is part of ubuntu-server-iso-testing.
+# 
+# ubuntu-server-iso-testing is free software: you can redistribute it 
+# and/or modify it under the terms of the GNU General Public License 
+# as published by the Free Software Foundation, either version 3 of 
+# the License, or (at your option) any later version.
+# 
+# ubuntu-server-iso-testing is distributed in the hope that it will 
+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with ubuntu-server-iso-testing.  If not, see 
+# <http://www.gnu.org/licenses/>.
+# 
+
+# This script must be executed with admin privileges
+
+BASEDIR=$(dirname $0)/..
+TESTDIR=$BASEDIR/tests
+
+# Don't hardcode this, it will break if wubi is not installed on C:
+LOGDIR=/host/cygwin/home/ubuntu/wubitest/run/latest
+if [ ! -d "$LOGDIR" ]; then
+    echo "Logdir not found. Aborting!"
+    exit 1
+fi
+
+cd $TESTDIR
+for t in test_*.py; do
+    tbasename=$(basename $t .py)
+    echo "Running test: $tbasename"
+    python -m subunit.run $tbasename | subunit2junitxml > $LOGDIR/results.${tbasename}.log
+done
+cd -
+
+# Save the installer file
+echo "Saving log files"
+cp -r /var/log/installer $LOGDIR/
+dmesg > $LOGDIR/dmesg
+cp /var/log/syslog $LOGDIR
+
+# Stage 2 is done
+rm $LOGDIR/stage2
+
+# Send the results to Jenkins
+
+# Poweroff or reboot to windows
+reboot
+
+

=== added directory 'wubi/data/custom-installation/target-override/usr/local/tests'
=== added file 'wubi/data/custom-installation/target-override/usr/local/tests/test_default.py'
--- wubi/data/custom-installation/target-override/usr/local/tests/test_default.py	1970-01-01 00:00:00 +0000
+++ wubi/data/custom-installation/target-override/usr/local/tests/test_default.py	2011-07-25 16:56:01 +0000
@@ -0,0 +1,108 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2010, Canonical Ltd (http://www.canonical.com/)
+#
+# This file is part of ubuntu-server-iso-testing.
+#
+# ubuntu-server-iso-testing is free software: you can redistribute it
+# and/or modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# ubuntu-server-iso-testing is distributed in the hope that it will
+# be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ubuntu-server-iso-testing.  If not, see
+# <http://www.gnu.org/licenses/>.
+#
+
+import logging
+import os.path
+import unittest
+import lsb_release
+import subprocess
+
+logging.basicConfig(level=logging.INFO)
+
+def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.PIPE, stdin = None):
+    '''Try to execute given command (array) and return its stdout, or return
+    a textual error if it failed.'''
+
+    try:
+        sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True)
+    except OSError, e:
+        return [127, str(e)]
+
+    out, outerr = sp.communicate(input)
+    # Handle redirection of stdout
+    if out == None:
+        out = ''
+    # Handle redirection of stderr
+    if outerr == None:
+        outerr = ''
+    return [sp.returncode,out+outerr]
+
+class DefaultTest(unittest.TestCase):
+
+    mount_point = "/host"
+    wubidir = os.path.join(mount_point, 'ubuntu')
+    distinfo = lsb_release.get_distro_information()
+    pkg_test = 'hello' # Example package used by the apt test
+
+    def test_01_host_is_mounted(self):
+        self.assertTrue(os.path.ismount(self.mount_point))
+
+    def test_02_read_write(self):
+        t_fh = open(os.path.join(self.mount_point, 'Temp', 'a'), 'w')
+        self.assertNotEqual(t_fh, None)
+        self.assertEqual(t_fh.write('a'), None)
+        self.assertEqual(t_fh.close(), None)
+
+    def test_03_wubi_dir_structure(self):
+        wubi_filelist = (
+            '/host/ubuntu/',
+            '/host/ubuntu/disks',
+            '/host/ubuntu/disks/boot',
+            '/host/ubuntu/disks/boot/grub',
+            '/host/ubuntu/disks/root.disk',
+            '/host/ubuntu/disks/swap.disk',
+            '/host/ubuntu/install',
+            '/host/ubuntu/Ubuntu.ico',
+            '/host/ubuntu/uninstall-wubi.exe',
+            '/host/ubuntu/winboot',
+            '/host/ubuntu/winboot/wubildr',
+            '/host/ubuntu/winboot/wubildr-bootstrap.cfg',
+            '/host/ubuntu/winboot/wubildr.cfg',
+            '/host/ubuntu/winboot/wubildr.mbr',
+            '/host/ubuntu/winboot/wubildr.tar'
+        )
+
+        for f in wubi_filelist:
+            self.assertTrue(os.path.exists(f), "File not found: '%s'" % f)
+
+    def test_04_apt_update(self):
+        '''apt-get update'''
+        rc, report = cmd(['apt-get', 'update'])
+        expected = 0
+        result = 'Got exit code %d, expected %d\n' % (rc, expected)
+        self.assertEquals(expected, rc, result + report)
+
+    def test_05_apt_install_remove(self):
+        '''apt-get install'''
+        rc, report = cmd(['apt-get', 'install', '-y', self.pkg_test])
+        expected = 0
+        result = 'Got exit code %d, expected %d\n' % (rc, expected)
+        self.assertEquals(expected, rc, result + report)
+
+        rc, report = cmd(['apt-get', 'remove', '-y', '--purge', self.pkg_test])
+        expected = 0
+        result = 'Got exit code %d, expected %d\n' % (rc, expected)
+        self.assertEquals(expected, rc, result + report)
+
+
+if __name__ == '__main__':
+    unittest.main()
+

=== added directory 'wubi/data/iso'
=== added directory 'wubi/run'

Follow ups