blob: 0f25c4b098a85c28baf5dbe2ba05c8db8fc1cd85 [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
Stephan Herrmann56428e92013-02-23 12:29:56 +010018# TEST_TMPDIR for temp test files
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000019# OT_TESTSUITE_DIR root directory for building and testing
20# METADATA directory for metadata from previous builds
21# OT_RECIPIENT mail address for failure messages
Stephan Herrmannaf43e4a2013-04-29 23:19:56 +020022# SDK_QUALIFIER build qualifier of the base eclipse SDK
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000023# ECLIPSE_SDK_TGZ archive file of the base eclipse SDK build (full path)
24# ECLIPSE_TESTLIB_ZIP archive file of the eclipse test framework (full path)
Stephan Herrmann8372dc22010-06-03 22:41:05 +000025# PUBLISHED_UPDATES directory of previously published plugins&features
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000026# ANT_PROFILE configure the ant process
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000027# X11 XVFB, XVNC or X11
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000028# NICE niceness value for nice -n ${NICE}
29# =============================================================================
30# OUTPUT: Variables passed to the toplevel ant script
31# -----------------------------------------------------------------------------
32## As Environment Variables:
33## ANT_OPTS configure Ant
34## As Ant Arguments (from ANT_PROFILE):
35## -verbose configure Ant
36## As Java Properties:
37## -Declipse-app.tgz path of eclipse SDK
38## -Declipse.tests.zip path of eclipse test framework
Stephan Herrmann8372dc22010-06-03 22:41:05 +000039## -Dpublished.updates path to previously published things
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000040## -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!"; }
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000060 tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz"
61 echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000062 cleanup
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000063 exit 1;
64}
65
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000066cleanup()
67{
68 if test $X11 = "XVNC"; then
69 vncserver -kill $VNC_DISPLAY
70 fi
71}
72
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000073_prefix=`dirname $0`
74_prefix=`readlink -f $_prefix`
75. "${_prefix}/otdt_prerequisites.sh"
76
77#LOCAL: log file:
78OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
79
80# LOCAL: the initial ant build file:
81BUILDFILE="${_prefix}/run.xml"
82
83#LOCAL: main ant target:
84MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
85
86#LOCAL: should OTDT and tests be built?
87DO_BUILD="true"
88
89#LOCAL: should the tests be run?
90DO_RUN="true"
91
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000092#LOCAL: Display to be used by VNC:
93VNC_DISPLAY=:23
94
Stephan Herrmann56428e92013-02-23 12:29:56 +010095
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 ;;
Stephan Herrmann56428e92013-02-23 12:29:56 +0100111 -tmp)
112 shift
113 TEST_TMPDIR="$1"
114 shift
115 ;;
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000116 *)
117 echo "Unknown argument: $1"
118 usage
119 exit 1
120 esac
121
122done
123
124# start working:
125
126test -d "$TMPDIR" || mkdir -p "$TMPDIR"
127test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
128cd "$OT_TESTSUITE_DIR"
129
130# cleanup previous:
131if [ "$DO_BUILD" == "true" ]
132then
133 rm -rf build-root
134 rm -rf test-root
135 rm -rf updateSite
Stephan Herrmann9d8848c2016-02-16 22:53:31 +0100136 rm -rf updateSiteTests
137 rm -rf updateSiteCompiler
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000138 rm -rf metadata
139fi
140
141# preload metadata for appending:
142if [ -f "${METADATA}/content.xml" ]
143then
144 mkdir -p metadata
145 cp ${METADATA}/*.xml metadata
146fi
147
148trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
149
150# Assemble the Ant call:
151ANT_OPTIONS="${ANT_PROFILE} \
152 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
153 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
Stephan Herrmannaf43e4a2013-04-29 23:19:56 +0200154 -Declipse.sdk.qualifier=${SDK_QUALIFIER} \
Stephan Herrmann8372dc22010-06-03 22:41:05 +0000155 -Dpublished.updates=${PUBLISHED_UPDATES} \
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000156 -Ddo.run.tests=${DO_RUN} \
Stephan Herrmann56428e92013-02-23 12:29:56 +0100157 -Ddo.build.all=${DO_BUILD} \
158 -Dtest.tmpDir=${TEST_TMPDIR}"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000159
160ANT_OPTS="-Xmx1024m"
161export ANT_OPTS
162
163CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
164
165if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
166 echo "Running xvfb-run $CMD"
167
168 # make sure that xauth can be found
169 export PATH="$PATH:/usr/bin/X11"
170 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
171 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 +0000172elif test "$X11" = "XVNC"; then
173 echo "starting vncserver $VNC_DISPLAY"
174 vncserver $VNC_DISPLAY
175 DISPLAY=$VNC_DISPLAY
176 export DISPLAY
177 exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; }
Stephan Herrmann8296dc62011-05-01 16:28:05 +0000178 echo "Cleaning up after successful run..."
179 /bin/rm -rf ${OT_TESTSUITE_DIR}/build-root/eclipse
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000180else
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000181 echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000182 echo "Running $CMD"
183 eval "$CMD" < /dev/null
184fi
185
186trap - INT
187
188