So I have done my penance for failing to set up 
a cron to run testing.  I've got routine testing
going every night on 2 boxes.  It seems solid.

I see that many others have done this as well - test.winehq.org
wine results are really looking good.

As promised, I'm attaching the script I'm using.

This is my crontab line:
06 02 * * 2-6 /home/jwhite/bin/winetestcron --repo /home/jwhite/w/wine/.git 
--tag jw-nv-32
e.g. run the script at 2:06 am Tuesdays through Saturdays.

I don't want this to be a general call for everyone
to run this script; rather, this might be a handy tool for
developers who are already running winetest to
save them a little hassle.

My script probably has only one materially useful
feature - it uses a trap to enforce a timeout.
The rest is all pretty easy/obvious stuff.

Also, I've only tested on Linux, not Mac.  Sorry :-(.

Cheers,

Jeremy
#!/bin/bash
#----------------------------------------------------
#   winetestcron
#       script to run the Wine tests in an unattended fashion
#   Intended to be run from cron.  If you run it in the
#   crontab of the user that is logged in to DISPLAY :0,
#   it should work.  Otherwise, you might want to do a
#   xauth extract /your/file in your .xsession, and an 
#   xauth merge /your/file in this script.
#----------------------------------------------------
function usage()
{
    echo -n "$0 --repo /path/to/your/.git/dir "
    echo  "[--tag tag-to-report] "
    echo  -n "               [--gecko gecko-path] "
    echo  "[--timeout secs] [--update-repo]"
    echo     "               [--configure extra-configure-args]"
    echo "repo is mandatory, must give the location of a .git directory, and "
    echo "will not be changed by default.  If you specify update-repo, then a "
    echo "git fetch will be done in your repository before running winetest. "
    echo "The working tree will not be changed in any case."
    echo "tag is the tag name to report; see common tags on test.winehq.org for 
guidance."
    echo "timeout sets an overall script timeout, in seconds.  Default is 
$TIMEOUT"
    echo "gecko specifies a path to the Gecko CAB file.  Default is 
$GECKO_LOCATION"
    echo "configure will pass through the options to ./configure"
}

function parse_args()
{
    GOPT=`getopt -o "" -l repo:,tag:,gecko:,timeout:,configure:,update-repo -- 
"$@"`
    GOPTERR=`getopt -o "" -l repo:,tag:,gecko:,timeout:,configure:,update-repo 
-- "$@" 2>&1`
    eval set -- "$GOPT"

    if [ $? != 0 -o "$GOPT" != "$GOPTERR" ] ; then
        usage
        exit 1
    fi

    while true ; do
        case "$1" in
            --repo)        export REFERENCE_GIT="$2"; shift 2;; 
            --tag)         export TAG="$2"; shift 2;;
            --gecko)       export GECKO_LOCATION="$2"; shift 2;;
            --configure)   export CONFIG_EXTRAS="$2"; shift 2;;
            --update-repo) export UPDATE_REPO="y"; shift;;
            --)            shift; break;;
            *)             echo "Error:  uknown option $@"; usage ; exit ;;
        esac
    done

    if [ $# -gt 0 ] ; then
        echo "Error:  Unexpected parameters $@"
        usage
        exit 1
    fi

    if [ ! -d "$REFERENCE_GIT" ] ; then
        echo "Error: --repo must point to the .git directory of a valid WineHQ 
clone."
        usage
        exit 1
    fi

}

function cleanup 
{
    "$TESTDIR/wine/server/wineserver" -k
    find /tmp -maxdepth 1 -type d -name 'winetest*' -ctime +2  -exec rm -rf {} 
\;
    exit
}

#---
# Set defaults
#----

export GECKO_LOCATION=/usr/share/wine/gecko/
export TIMEOUT=3600
export TAG=`echo -n \`whoami\`-\`uname -m\` | sed 's/_/-/g'`

#---
# Validate arguments
#----
parse_args "$@"


#---
# Get going...
#----

TESTDIR=`mktemp -d /tmp/winetest.XXXXXXXX`
TMPGITDIR="$TESTDIR/wine"

mkdir "$TESTDIR/gecko"
if [ -f "$GECKO_LOCATION/wine_gecko-1.0.0-x86.cab" ] ; then
    cp "$GECKO_LOCATION/wine_gecko-1.0.0-x86.cab" "$TESTDIR/gecko/"
else
    echo $GECKO_LOCATION/wine_gecko-1.0.0-x86.cab not found.  Bandwidth being 
wasted...
    (   cd "$TESTDIR/gecko" ; \
        wget -o "$TESTDIR/wget.log" 
http://downloads.sourceforge.net/wine/wine_gecko-1.0.0-x86.cab \
    )
fi

if [ "$UPDATE_REPO" = "y" ] ; then
    git "--git-dir=$REFERENCE_GIT" fetch origin
fi

git clone --reference "$REFERENCE_GIT" git://source.winehq.org/git/wine.git 
"$TMPGITDIR" >"$TESTDIR/clone.log" 2>&1

cd "$TMPGITDIR"
(./configure "$CONFIG_EXTRAS" && nice make ) > "$TESTDIR/build.log" 2>&1

export WINEPREFIX="$TESTDIR/.wine"
export PATH="$TMPGITDIR:$PATH"
export DISPLAY=:0
cd "$TESTDIR"

# Set a trap to cleanup when a child exits.  We either exit when
#   the Wine tests are complete, or the timeout happens; whichever
#   comes first
set -m
trap cleanup CHLD

# Run the actual tests
"$TMPGITDIR/wine" "$TMPGITDIR/programs/winetest/winetest.exe.so" -c -t "$TAG" 
>wine.log 2>&1 &

# Set a timer to force an exit after $TIMEOUT
sleep $TIMEOUT



Reply via email to