Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 1 | #! /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 Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 18 | # TEST_TMPDIR for temp test files |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 19 | # 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 Herrmann | af43e4a | 2013-04-29 23:19:56 +0200 | [diff] [blame] | 22 | # SDK_QUALIFIER build qualifier of the base eclipse SDK |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 23 | # 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 Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 25 | # PUBLISHED_UPDATES directory of previously published plugins&features |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 26 | # ANT_PROFILE configure the ant process |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 27 | # X11 XVFB, XVNC or X11 |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 28 | # 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 Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 39 | ## -Dpublished.updates path to previously published things |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 40 | ## -Ddo.build.all true|false: should OTDT and tests be built? |
| 41 | ## -Ddo.run.tests true|false: should test be run? |
| 42 | # ============================================================================= |
| 43 | |
| 44 | usage() |
| 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 | |
| 52 | notifyTestRunFailure() |
| 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 Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 60 | tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz" |
| 61 | echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 62 | cleanup |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 63 | exit 1; |
| 64 | } |
| 65 | |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 66 | cleanup() |
| 67 | { |
| 68 | if test $X11 = "XVNC"; then |
| 69 | vncserver -kill $VNC_DISPLAY |
| 70 | fi |
| 71 | } |
| 72 | |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 73 | _prefix=`dirname $0` |
| 74 | _prefix=`readlink -f $_prefix` |
| 75 | . "${_prefix}/otdt_prerequisites.sh" |
| 76 | |
| 77 | #LOCAL: log file: |
| 78 | OT_SUITE_LOG=$TMPDIR/ot-testsuite.log |
| 79 | |
| 80 | # LOCAL: the initial ant build file: |
| 81 | BUILDFILE="${_prefix}/run.xml" |
| 82 | |
| 83 | #LOCAL: main ant target: |
| 84 | MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"} |
| 85 | |
| 86 | #LOCAL: should OTDT and tests be built? |
| 87 | DO_BUILD="true" |
| 88 | |
| 89 | #LOCAL: should the tests be run? |
| 90 | DO_RUN="true" |
| 91 | |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 92 | #LOCAL: Display to be used by VNC: |
| 93 | VNC_DISPLAY=:23 |
| 94 | |
Stephan Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 95 | |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 96 | while 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 Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 111 | -tmp) |
| 112 | shift |
| 113 | TEST_TMPDIR="$1" |
| 114 | shift |
| 115 | ;; |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 116 | *) |
| 117 | echo "Unknown argument: $1" |
| 118 | usage |
| 119 | exit 1 |
| 120 | esac |
| 121 | |
| 122 | done |
| 123 | |
| 124 | # start working: |
| 125 | |
| 126 | test -d "$TMPDIR" || mkdir -p "$TMPDIR" |
| 127 | test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR" |
| 128 | cd "$OT_TESTSUITE_DIR" |
| 129 | |
| 130 | # cleanup previous: |
| 131 | if [ "$DO_BUILD" == "true" ] |
| 132 | then |
| 133 | rm -rf build-root |
| 134 | rm -rf test-root |
| 135 | rm -rf updateSite |
Stephan Herrmann | 9d8848c | 2016-02-16 22:53:31 +0100 | [diff] [blame] | 136 | rm -rf updateSiteTests |
| 137 | rm -rf updateSiteCompiler |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 138 | rm -rf metadata |
| 139 | fi |
| 140 | |
| 141 | # preload metadata for appending: |
| 142 | if [ -f "${METADATA}/content.xml" ] |
| 143 | then |
| 144 | mkdir -p metadata |
| 145 | cp ${METADATA}/*.xml metadata |
| 146 | fi |
| 147 | |
| 148 | trap "echo Aborting by SIGTERM; cleanup; exit 130" INT |
| 149 | |
| 150 | # Assemble the Ant call: |
| 151 | ANT_OPTIONS="${ANT_PROFILE} \ |
| 152 | -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \ |
| 153 | -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \ |
Stephan Herrmann | af43e4a | 2013-04-29 23:19:56 +0200 | [diff] [blame] | 154 | -Declipse.sdk.qualifier=${SDK_QUALIFIER} \ |
Stephan Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 155 | -Dpublished.updates=${PUBLISHED_UPDATES} \ |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 156 | -Ddo.run.tests=${DO_RUN} \ |
Stephan Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 157 | -Ddo.build.all=${DO_BUILD} \ |
Stephan Herrmann | 358ac0f | 2016-11-01 00:29:19 +0100 | [diff] [blame] | 158 | -Dtest.tmpDir=${TEST_TMPDIR} \ |
Stephan Herrmann | e8ce6eb | 2016-11-01 01:01:55 +0100 | [diff] [blame^] | 159 | -DfetchCacheLocation=${FETCH_CACHE_LOCATION} |
| 160 | -Dmap.file.path=${MAP_FILE_PATH}" |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 161 | |
| 162 | ANT_OPTS="-Xmx1024m" |
| 163 | export ANT_OPTS |
| 164 | |
| 165 | CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}" |
| 166 | |
| 167 | if test "$X11" = "XVFB" && test `which xvfb-run` > /dev/null; then |
| 168 | echo "Running xvfb-run $CMD" |
| 169 | |
| 170 | # make sure that xauth can be found |
| 171 | export PATH="$PATH:/usr/bin/X11" |
| 172 | # try to start with DISPLAY=10 instead of default 99 -- seems to not work everywhere |
| 173 | exec xvfb-run -n 10 -e xvfb.log --auto-servernum $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 || { notifyTestRunFailure; } |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 174 | elif test "$X11" = "XVNC"; then |
| 175 | echo "starting vncserver $VNC_DISPLAY" |
| 176 | vncserver $VNC_DISPLAY |
| 177 | DISPLAY=$VNC_DISPLAY |
| 178 | export DISPLAY |
| 179 | exec $CMD < /dev/null > ${OT_SUITE_LOG} 2>&1 && { cleanup; } || { notifyTestRunFailure; } |
Stephan Herrmann | 8296dc6 | 2011-05-01 16:28:05 +0000 | [diff] [blame] | 180 | echo "Cleaning up after successful run..." |
| 181 | /bin/rm -rf ${OT_TESTSUITE_DIR}/build-root/eclipse |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 182 | else |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 183 | echo "##### You don't have xvfb nor vnc, the GUI tests will appear on your display... ####" |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 184 | echo "Running $CMD" |
| 185 | eval "$CMD" < /dev/null |
| 186 | fi |
| 187 | |
| 188 | trap - INT |
| 189 | |
| 190 | |