blob: 342e787fbbe942f156f680da0f6c1bcd34170633 [file] [log] [blame]
Stephan Herrmanndcd87c12010-04-25 10:59:27 +00001#! /bin/sh
2# Copyright (c) 2010 Stephan Herrmann.
Stephan Herrmann35705382020-03-03 21:42:19 +01003# This program and the accompanying materials
4# are made available under the terms of the Eclipse Public License 2.0
Stephan Herrmanndcd87c12010-04-25 10:59:27 +00005# which accompanies this distribution, and is available at
Stephan Herrmann35705382020-03-03 21:42:19 +01006# https://www.eclipse.org/legal/epl-2.0/
7#
8# SPDX-License-Identifier: EPL-2.0
Stephan Herrmanndcd87c12010-04-25 10:59:27 +00009#
10# Contributors:
11# Stephan Herrmann - initial API and implementation
12###############################################################################
13
14# =============================================================================
15# MAIN BUILD AND TEST SCRIPT FOR THE OBJECT TEAMS DEVELOPMENT TOOLING (OTDT)
16# =============================================================================
17# INPUT: Variables from otdt_prerequisites:
18# -----------------------------------------------------------------------------
19# TMPDIR for log output
Stephan Herrmann56428e92013-02-23 12:29:56 +010020# TEST_TMPDIR for temp test files
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000021# OT_TESTSUITE_DIR root directory for building and testing
22# METADATA directory for metadata from previous builds
23# OT_RECIPIENT mail address for failure messages
Stephan Herrmannaf43e4a2013-04-29 23:19:56 +020024# SDK_QUALIFIER build qualifier of the base eclipse SDK
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000025# ECLIPSE_SDK_TGZ archive file of the base eclipse SDK build (full path)
26# ECLIPSE_TESTLIB_ZIP archive file of the eclipse test framework (full path)
Stephan Herrmann8372dc22010-06-03 22:41:05 +000027# PUBLISHED_UPDATES directory of previously published plugins&features
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000028# ANT_PROFILE configure the ant process
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000029# X11 XVFB, XVNC or X11
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000030# NICE niceness value for nice -n ${NICE}
31# =============================================================================
32# OUTPUT: Variables passed to the toplevel ant script
33# -----------------------------------------------------------------------------
34## As Environment Variables:
35## ANT_OPTS configure Ant
36## As Ant Arguments (from ANT_PROFILE):
37## -verbose configure Ant
38## As Java Properties:
39## -Declipse-app.tgz path of eclipse SDK
40## -Declipse.tests.zip path of eclipse test framework
Stephan Herrmann8372dc22010-06-03 22:41:05 +000041## -Dpublished.updates path to previously published things
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000042## -Ddo.build.all true|false: should OTDT and tests be built?
43## -Ddo.run.tests true|false: should test be run?
44# =============================================================================
45
46usage()
47{
48 echo "Usage:"
49 echo "$0 [-b|-nobuild]"
50 echo " -b: build OTDT only, no testing."
51 echo " -nobuild: don't build OTDT, directly invoke testing."
52}
53
54notifyTestRunFailure()
55{
56 echo "Running the test-cases failed!";
57 local subject="OT Testsuite: Failure!"
58 local message="See the attached log to fix the problems."
59 local cmdLogfiles="-a ${OT_SUITE_LOG}-tail.gz"
60
61 grep -q "\[java\] BUILD FAILED" "$OT_SUITE_LOG" && { subject="OT Testsuite: Compile/Build Failure!"; }
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000062 tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz"
63 echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000064 cleanup
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000065 exit 1;
66}
67
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000068cleanup()
69{
70 if test $X11 = "XVNC"; then
71 vncserver -kill $VNC_DISPLAY
72 fi
73}
74
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000075_prefix=`dirname $0`
76_prefix=`readlink -f $_prefix`
77. "${_prefix}/otdt_prerequisites.sh"
78
79#LOCAL: log file:
80OT_SUITE_LOG=$TMPDIR/ot-testsuite.log
81
82# LOCAL: the initial ant build file:
83BUILDFILE="${_prefix}/run.xml"
84
85#LOCAL: main ant target:
86MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"}
87
88#LOCAL: should OTDT and tests be built?
89DO_BUILD="true"
90
91#LOCAL: should the tests be run?
92DO_RUN="true"
93
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +000094#LOCAL: Display to be used by VNC:
95VNC_DISPLAY=:23
96
Stephan Herrmann56428e92013-02-23 12:29:56 +010097
Stephan Herrmanndcd87c12010-04-25 10:59:27 +000098while test $# -gt 0; do
99 case "$1" in
100 -b)
101 MAIN_TARGET="ot-junit-build"
102 DO_RUN="false"
103 shift
104 ;;
105 -nobuild)
106 DO_BUILD="false"
107 shift
108 ;;
109 -x11)
110 X11=X11
111 shift
112 ;;
Stephan Herrmann56428e92013-02-23 12:29:56 +0100113 -tmp)
114 shift
115 TEST_TMPDIR="$1"
116 shift
117 ;;
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000118 *)
119 echo "Unknown argument: $1"
120 usage
121 exit 1
122 esac
123
124done
125
126# start working:
127
128test -d "$TMPDIR" || mkdir -p "$TMPDIR"
129test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR"
130cd "$OT_TESTSUITE_DIR"
131
132# cleanup previous:
133if [ "$DO_BUILD" == "true" ]
134then
135 rm -rf build-root
136 rm -rf test-root
137 rm -rf updateSite
Stephan Herrmann9d8848c2016-02-16 22:53:31 +0100138 rm -rf updateSiteTests
139 rm -rf updateSiteCompiler
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000140 rm -rf metadata
Stephan Herrmannb6718c12016-11-01 13:13:07 +0100141else
142 rm -f test-root/eclipse/results/*
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000143fi
144
145# preload metadata for appending:
146if [ -f "${METADATA}/content.xml" ]
147then
148 mkdir -p metadata
149 cp ${METADATA}/*.xml metadata
150fi
151
152trap "echo Aborting by SIGTERM; cleanup; exit 130" INT
153
154# Assemble the Ant call:
155ANT_OPTIONS="${ANT_PROFILE} \
156 -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \
157 -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \
Stephan Herrmannaf43e4a2013-04-29 23:19:56 +0200158 -Declipse.sdk.qualifier=${SDK_QUALIFIER} \
Stephan Herrmann8372dc22010-06-03 22:41:05 +0000159 -Dpublished.updates=${PUBLISHED_UPDATES} \
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000160 -Ddo.run.tests=${DO_RUN} \
Stephan Herrmann56428e92013-02-23 12:29:56 +0100161 -Ddo.build.all=${DO_BUILD} \
Stephan Herrmann358ac0f2016-11-01 00:29:19 +0100162 -Dtest.tmpDir=${TEST_TMPDIR} \
Stephan Herrmanncf1ce3f2016-11-01 01:04:19 +0100163 -DfetchCacheLocation=${FETCH_CACHE_LOCATION} \
Stephan Herrmanne8ce6eb2016-11-01 01:01:55 +0100164 -Dmap.file.path=${MAP_FILE_PATH}"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000165
166ANT_OPTS="-Xmx1024m"
167export ANT_OPTS
168
169CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}"
170
171if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then
172 echo "Running xvfb-run $CMD"
173
174 # make sure that xauth can be found
175 export PATH="$PATH:/usr/bin/X11"
176 # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere
177 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 +0000178elif test "$X11" = "XVNC"; then
179 echo "starting vncserver $VNC_DISPLAY"
180 vncserver $VNC_DISPLAY
181 DISPLAY=$VNC_DISPLAY
182 export DISPLAY
183 exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; }
Stephan Herrmann8296dc62011-05-01 16:28:05 +0000184 echo "Cleaning up after successful run..."
185 /bin/rm -rf ${OT_TESTSUITE_DIR}/build-root/eclipse
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000186else
Stephan Herrmann80ce6fa2010-05-18 12:16:47 +0000187 echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####"
Stephan Herrmanndcd87c12010-04-25 10:59:27 +0000188 echo "Running $CMD"
189 eval "$CMD" < /dev/null
190fi
191
192trap - INT
193
194