blob: 8c88991ee3ee99e6c865c09cc00977d38abb3e0a [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
Stephan Herrmannb6718c12016-11-01 13:13:07 +0100139else
140 rm -f test-root/eclipse/results/*
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000141fi
142
143# preload metadata for appending:
144if [ -f "${METADATA}/content.xml" ]
145then
146 mkdir -p metadata
147 cp ${METADATA}/*.xml metadata
148fi
149
150trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
151
152# Assemble the Ant call:
153ANT_OPTIONS="${ANT_PROFILE} \
154 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
155 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
Stephan Herrmannaf43e4a2013-04-29 23:19:56 +0200156 -Declipse.sdk.qualifier=${SDK_QUALIFIER} \
Stephan Herrmann8372dc22010-06-03 22:41:05 +0000157 -Dpublished.updates=${PUBLISHED_UPDATES} \
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000158 -Ddo.run.tests=${DO_RUN} \
Stephan Herrmann56428e92013-02-23 12:29:56 +0100159 -Ddo.build.all=${DO_BUILD} \
Stephan Herrmann358ac0f2016-11-01 00:29:19 +0100160 -Dtest.tmpDir=${TEST_TMPDIR} \
Stephan Herrmanncf1ce3f2016-11-01 01:04:19 +0100161 -DfetchCacheLocation=${FETCH_CACHE_LOCATION} \
Stephan Herrmanne8ce6eb2016-11-01 01:01:55 +0100162 -Dmap.file.path=${MAP_FILE_PATH}"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000163
164ANT_OPTS="-Xmx1024m"
165export ANT_OPTS
166
167CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
168
169if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
170 echo "Running xvfb-run $CMD"
171
172 # make sure that xauth can be found
173 export PATH="$PATH:/usr/bin/X11"
174 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
175 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 +0000176elif test "$X11" = "XVNC"; then
177 echo "starting vncserver $VNC_DISPLAY"
178 vncserver $VNC_DISPLAY
179 DISPLAY=$VNC_DISPLAY
180 export DISPLAY
181 exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; }
Stephan Herrmann8296dc62011-05-01 16:28:05 +0000182 echo "Cleaning up after successful run..."
183 /bin/rm -rf ${OT_TESTSUITE_DIR}/build-root/eclipse
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000184else
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000185 echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000186 echo "Running $CMD"
187 eval "$CMD" < /dev/null
188fi
189
190trap - INT
191
192