blob: 6b142f64d98086904f91b0c88b8874f93e5cd2c5 [file] [log] [blame]
Stephan Herrmanndcd87c12010-04-25 10:59:27 +00001#! /bin/sh
2# Copyright (c) 2010 Stephan Herrmann.
3# All rights reserved. This program and the accompanying materials
4# are made available under the terms of the Eclipse Public License v1.0
5# which accompanies this distribution, and is available at
6# http://www.eclipse.org/legal/epl-v10.html
7#
8# Contributors:
9# Stephan Herrmann - initial API and implementation
10###############################################################################
11
12# =============================================================================
13# MAIN BUILD AND TEST SCRIPT FOR THE OBJECT TEAMS DEVELOPMENT TOOLING (OTDT)
14# =============================================================================
15# INPUT: Variables from otdt_prerequisites:
16# -----------------------------------------------------------------------------
17# TMPDIR for log output
18# OT_TESTSUITE_DIR root directory for building and testing
19# METADATA directory for metadata from previous builds
20# OT_RECIPIENT mail address for failure messages
21# ECLIPSE_SDK_TGZ archive file of the base eclipse SDK build (full path)
22# ECLIPSE_TESTLIB_ZIP archive file of the eclipse test framework (full path)
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000023# OTRE_LIB directory holding various otre jar files
24# ANT_PROFILE configure the ant process
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000025# X11 XVFB, XVNC or X11
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000026# NICE niceness value for nice -n ${NICE}
27# =============================================================================
28# OUTPUT: Variables passed to the toplevel ant script
29# -----------------------------------------------------------------------------
30## As Environment Variables:
31## ANT_OPTS configure Ant
32## As Ant Arguments (from ANT_PROFILE):
33## -verbose configure Ant
34## As Java Properties:
35## -Declipse-app.tgz path of eclipse SDK
36## -Declipse.tests.zip path of eclipse test framework
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000037## -Dotre.lib directory to otre jars
38## -Ddo.build.all true|false: should OTDT and tests be built?
39## -Ddo.run.tests true|false: should test be run?
40# =============================================================================
41
42usage()
43{
44 echo "Usage:"
45 echo "$0 [-b|-nobuild]"
46 echo " -b: build OTDT only, no testing."
47 echo " -nobuild: don't build OTDT, directly invoke testing."
48}
49
50notifyTestRunFailure()
51{
52 echo "Running the test-cases failed!";
53 local subject="OT Testsuite: Failure!"
54 local message="See the attached log to fix the problems."
55 local cmdLogfiles="-a ${OT_SUITE_LOG}-tail.gz"
56
57 grep -q "\[java\] BUILD FAILED" "$OT_SUITE_LOG" && { subject="OT Testsuite: Compile/Build Failure!"; }
58 grep -q "svn.*connection timed out" "$OT_SUITE_LOG" && { subject="OT Testsuite: SVN timeout"; message="Nothing to fix, next run hopefully works"; }
59 tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz"
60 echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000061 cleanup
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000062 exit 1;
63}
64
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000065cleanup()
66{
67 if test $X11 = "XVNC"; then
68 vncserver -kill $VNC_DISPLAY
69 fi
70}
71
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000072_prefix=`dirname $0`
73_prefix=`readlink -f $_prefix`
74. "${_prefix}/otdt_prerequisites.sh"
75
76#LOCAL: log file:
77OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
78
79# LOCAL: the initial ant build file:
80BUILDFILE="${_prefix}/run.xml"
81
82#LOCAL: main ant target:
83MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
84
85#LOCAL: should OTDT and tests be built?
86DO_BUILD="true"
87
88#LOCAL: should the tests be run?
89DO_RUN="true"
90
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000091#LOCAL: Display to be used by VNC:
92VNC_DISPLAY=:23
93
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000094while test $# -gt 0; do
95 case "$1" in
96 -b)
97 MAIN_TARGET="ot-junit-build"
98 DO_RUN="false"
99 shift
100 ;;
101 -nobuild)
102 DO_BUILD="false"
103 shift
104 ;;
105 -x11)
106 X11=X11
107 shift
108 ;;
109 *)
110 echo "Unknown argument: $1"
111 usage
112 exit 1
113 esac
114
115done
116
117# start working:
118
119test -d "$TMPDIR" || mkdir -p "$TMPDIR"
120test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
121cd "$OT_TESTSUITE_DIR"
122
123# cleanup previous:
124if [ "$DO_BUILD" == "true" ]
125then
126 rm -rf build-root
127 rm -rf test-root
128 rm -rf updateSite
129 rm -rf updateSiteTests
130 rm -rf metadata
131fi
132
133# preload metadata for appending:
134if [ -f "${METADATA}/content.xml" ]
135then
136 mkdir -p metadata
137 cp ${METADATA}/*.xml metadata
138fi
139
140trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
141
142# Assemble the Ant call:
143ANT_OPTIONS="${ANT_PROFILE} \
144 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
145 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000146 -Dotre.lib=${OTRE_LIB} \
147 -Ddo.run.tests=${DO_RUN} \
148 -Ddo.build.all=${DO_BUILD}"
149
150ANT_OPTS="-Xmx1024m"
151export ANT_OPTS
152
153CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
154
155if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
156 echo "Running xvfb-run $CMD"
157
158 # make sure that xauth can be found
159 export PATH="$PATH:/usr/bin/X11"
160 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
161 exec xvfb-run -n 10 -e xvfb.log --auto-servernum $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 || { notifyTestRunFailure; }
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000162elif test "$X11" = "XVNC"; then
163 echo "starting vncserver $VNC_DISPLAY"
164 vncserver $VNC_DISPLAY
165 DISPLAY=$VNC_DISPLAY
166 export DISPLAY
167 exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; }
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000168else
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000169 echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000170 echo "Running $CMD"
171 eval "$CMD" < /dev/null
172fi
173
174trap - INT
175
176