blob: 2990695fb3a6cf975ddf6b1668a7ee74b73c6ef7 [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
26# X11 XVFB or X11
27# 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
63 exit 1;
64}
65
66_prefix=`dirname $0`
67_prefix=`readlink -f $_prefix`
68. "${_prefix}/otdt_prerequisites.sh"
69
70#LOCAL: log file:
71OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
72
73# LOCAL: the initial ant build file:
74BUILDFILE="${_prefix}/run.xml"
75
76#LOCAL: main ant target:
77MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
78
79#LOCAL: should OTDT and tests be built?
80DO_BUILD="true"
81
82#LOCAL: should the tests be run?
83DO_RUN="true"
84
85while test $# -gt 0; do
86 case "$1" in
87 -b)
88 MAIN_TARGET="ot-junit-build"
89 DO_RUN="false"
90 shift
91 ;;
92 -nobuild)
93 DO_BUILD="false"
94 shift
95 ;;
96 -x11)
97 X11=X11
98 shift
99 ;;
100 *)
101 echo "Unknown argument: $1"
102 usage
103 exit 1
104 esac
105
106done
107
108# start working:
109
110test -d "$TMPDIR" || mkdir -p "$TMPDIR"
111test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
112cd "$OT_TESTSUITE_DIR"
113
114# cleanup previous:
115if [ "$DO_BUILD" == "true" ]
116then
117 rm -rf build-root
118 rm -rf test-root
119 rm -rf updateSite
120 rm -rf updateSiteTests
121 rm -rf metadata
122fi
123
124# preload metadata for appending:
125if [ -f "${METADATA}/content.xml" ]
126then
127 mkdir -p metadata
128 cp ${METADATA}/*.xml metadata
129fi
130
131trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
132
133# Assemble the Ant call:
134ANT_OPTIONS="${ANT_PROFILE} \
135 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
136 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
137 -Dbcel.jar=${BCEL_JAR} \
138 -Dotre.lib=${OTRE_LIB} \
139 -Ddo.run.tests=${DO_RUN} \
140 -Ddo.build.all=${DO_BUILD}"
141
142ANT_OPTS="-Xmx1024m"
143export ANT_OPTS
144
145CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
146
147if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
148 echo "Running xvfb-run $CMD"
149
150 # make sure that xauth can be found
151 export PATH="$PATH:/usr/bin/X11"
152 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
153 exec xvfb-run -n 10 -e xvfb.log --auto-servernum $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 || { notifyTestRunFailure; }
154else
155 echo "##### You don't have xvfb-run, the GUI tests will appear on your display... ####"
156 echo "Running $CMD"
157 eval "$CMD" < /dev/null
158fi
159
160trap - INT
161
162