blob: 5b7c702ec618bc21678553eb083ce41410b177dd [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)
23# BCEL_JAR jar file of the bcel jar from orbit
24# OTRE_LIB directory holding various otre jar files
25# ANT_PROFILE configure the ant process
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000026# X11 XVFB, XVNC or X11
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000027# NICE niceness value for nice -n ${NICE}
28# =============================================================================
29# OUTPUT: Variables passed to the toplevel ant script
30# -----------------------------------------------------------------------------
31## As Environment Variables:
32## ANT_OPTS configure Ant
33## As Ant Arguments (from ANT_PROFILE):
34## -verbose configure Ant
35## As Java Properties:
36## -Declipse-app.tgz path of eclipse SDK
37## -Declipse.tests.zip path of eclipse test framework
38## -Dbcel.jar path of bcel jar
39## -Dotre.lib directory to otre jars
40## -Ddo.build.all true|false: should OTDT and tests be built?
41## -Ddo.run.tests true|false: should test be run?
42# =============================================================================
43
44usage()
45{
46 echo "Usage:"
47 echo "$0 [-b|-nobuild]"
48 echo " -b: build OTDT only, no testing."
49 echo " -nobuild: don't build OTDT, directly invoke testing."
50}
51
52notifyTestRunFailure()
53{
54 echo "Running the test-cases failed!";
55 local subject="OT Testsuite: Failure!"
56 local message="See the attached log to fix the problems."
57 local cmdLogfiles="-a ${OT_SUITE_LOG}-tail.gz"
58
59 grep -q "\[java\] BUILD FAILED" "$OT_SUITE_LOG" && { subject="OT Testsuite: Compile/Build Failure!"; }
60 grep -q "svn.*connection timed out" "$OT_SUITE_LOG" && { subject="OT Testsuite: SVN timeout"; message="Nothing to fix, next run hopefully works"; }
61 tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz"
62 echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000063 cleanup
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000064 exit 1;
65}
66
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000067cleanup()
68{
69 if test $X11 = "XVNC"; then
70 vncserver -kill $VNC_DISPLAY
71 fi
72}
73
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000074_prefix=`dirname $0`
75_prefix=`readlink -f $_prefix`
76. "${_prefix}/otdt_prerequisites.sh"
77
78#LOCAL: log file:
79OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
80
81# LOCAL: the initial ant build file:
82BUILDFILE="${_prefix}/run.xml"
83
84#LOCAL: main ant target:
85MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
86
87#LOCAL: should OTDT and tests be built?
88DO_BUILD="true"
89
90#LOCAL: should the tests be run?
91DO_RUN="true"
92
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000093#LOCAL: Display to be used by VNC:
94VNC_DISPLAY=:23
95
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000096while test $# -gt 0; do
97 case "$1" in
98 -b)
99 MAIN_TARGET="ot-junit-build"
100 DO_RUN="false"
101 shift
102 ;;
103 -nobuild)
104 DO_BUILD="false"
105 shift
106 ;;
107 -x11)
108 X11=X11
109 shift
110 ;;
111 *)
112 echo "Unknown argument: $1"
113 usage
114 exit 1
115 esac
116
117done
118
119# start working:
120
121test -d "$TMPDIR" || mkdir -p "$TMPDIR"
122test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
123cd "$OT_TESTSUITE_DIR"
124
125# cleanup previous:
126if [ "$DO_BUILD" == "true" ]
127then
128 rm -rf build-root
129 rm -rf test-root
130 rm -rf updateSite
131 rm -rf updateSiteTests
132 rm -rf metadata
133fi
134
135# preload metadata for appending:
136if [ -f "${METADATA}/content.xml" ]
137then
138 mkdir -p metadata
139 cp ${METADATA}/*.xml metadata
140fi
141
142trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
143
144# Assemble the Ant call:
145ANT_OPTIONS="${ANT_PROFILE} \
146 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
147 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
148 -Dbcel.jar=${BCEL_JAR} \
149 -Dotre.lib=${OTRE_LIB} \
150 -Ddo.run.tests=${DO_RUN} \
151 -Ddo.build.all=${DO_BUILD}"
152
153ANT_OPTS="-Xmx1024m"
154export ANT_OPTS
155
156CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
157
158if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
159 echo "Running xvfb-run $CMD"
160
161 # make sure that xauth can be found
162 export PATH="$PATH:/usr/bin/X11"
163 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
164 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 +0000165elif test "$X11" = "XVNC"; then
166 echo "starting vncserver $VNC_DISPLAY"
167 vncserver $VNC_DISPLAY
168 DISPLAY=$VNC_DISPLAY
169 export DISPLAY
170 exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; }
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000171else
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000172 echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000173 echo "Running $CMD"
174 eval "$CMD" < /dev/null
175fi
176
177trap - INT
178
179