Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # Copyright (c) 2010 Stephan Herrmann. |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 3 | # This program and the accompanying materials |
| 4 | # are made available under the terms of the Eclipse Public License 2.0 |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 5 | # which accompanies this distribution, and is available at |
Stephan Herrmann | 3570538 | 2020-03-03 21:42:19 +0100 | [diff] [blame] | 6 | # https://www.eclipse.org/legal/epl-2.0/ |
| 7 | # |
| 8 | # SPDX-License-Identifier: EPL-2.0 |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 9 | # |
| 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 Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 20 | # TEST_TMPDIR for temp test files |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 21 | # 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 Herrmann | af43e4a | 2013-04-29 23:19:56 +0200 | [diff] [blame] | 24 | # SDK_QUALIFIER build qualifier of the base eclipse SDK |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 25 | # 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 Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 27 | # PUBLISHED_UPDATES directory of previously published plugins&features |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 28 | # ANT_PROFILE configure the ant process |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 29 | # X11 XVFB, XVNC or X11 |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 30 | # 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 Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 41 | ## -Dpublished.updates path to previously published things |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 42 | ## -Ddo.build.all true|false: should OTDT and tests be built? |
| 43 | ## -Ddo.run.tests true|false: should test be run? |
| 44 | # ============================================================================= |
| 45 | |
| 46 | usage() |
| 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 | |
| 54 | notifyTestRunFailure() |
| 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 Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 62 | tail -1000 "$OT_SUITE_LOG" | gzip -f - > "${OT_SUITE_LOG}-tail.gz" |
| 63 | echo -e "$message" | mutt -s "$subject" $cmdLogfiles $OT_RECIPIENT |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 64 | cleanup |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 65 | exit 1; |
| 66 | } |
| 67 | |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 68 | cleanup() |
| 69 | { |
| 70 | if test $X11 = "XVNC"; then |
| 71 | vncserver -kill $VNC_DISPLAY |
| 72 | fi |
| 73 | } |
| 74 | |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 75 | _prefix=`dirname $0` |
| 76 | _prefix=`readlink -f $_prefix` |
| 77 | . "${_prefix}/otdt_prerequisites.sh" |
| 78 | |
| 79 | #LOCAL: log file: |
| 80 | OT_SUITE_LOG=$TMPDIR/ot-testsuite.log |
| 81 | |
| 82 | # LOCAL: the initial ant build file: |
| 83 | BUILDFILE="${_prefix}/run.xml" |
| 84 | |
| 85 | #LOCAL: main ant target: |
| 86 | MAIN_TARGET=${MAIN_TARGET:="ot-junit-all"} |
| 87 | |
| 88 | #LOCAL: should OTDT and tests be built? |
| 89 | DO_BUILD="true" |
| 90 | |
| 91 | #LOCAL: should the tests be run? |
| 92 | DO_RUN="true" |
| 93 | |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 94 | #LOCAL: Display to be used by VNC: |
| 95 | VNC_DISPLAY=:23 |
| 96 | |
Stephan Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 97 | |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 98 | while 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 Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 113 | -tmp) |
| 114 | shift |
| 115 | TEST_TMPDIR="$1" |
| 116 | shift |
| 117 | ;; |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 118 | *) |
| 119 | echo "Unknown argument: $1" |
| 120 | usage |
| 121 | exit 1 |
| 122 | esac |
| 123 | |
| 124 | done |
| 125 | |
| 126 | # start working: |
| 127 | |
| 128 | test -d "$TMPDIR" || mkdir -p "$TMPDIR" |
| 129 | test -d "$OT_TESTSUITE_DIR" || mkdir -p "$OT_TESTSUITE_DIR" |
| 130 | cd "$OT_TESTSUITE_DIR" |
| 131 | |
| 132 | # cleanup previous: |
| 133 | if [ "$DO_BUILD" == "true" ] |
| 134 | then |
| 135 | rm -rf build-root |
| 136 | rm -rf test-root |
| 137 | rm -rf updateSite |
Stephan Herrmann | 9d8848c | 2016-02-16 22:53:31 +0100 | [diff] [blame] | 138 | rm -rf updateSiteTests |
| 139 | rm -rf updateSiteCompiler |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 140 | rm -rf metadata |
Stephan Herrmann | b6718c1 | 2016-11-01 13:13:07 +0100 | [diff] [blame] | 141 | else |
| 142 | rm -f test-root/eclipse/results/* |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 143 | fi |
| 144 | |
| 145 | # preload metadata for appending: |
| 146 | if [ -f "${METADATA}/content.xml" ] |
| 147 | then |
| 148 | mkdir -p metadata |
| 149 | cp ${METADATA}/*.xml metadata |
| 150 | fi |
| 151 | |
| 152 | trap "echo Aborting by SIGTERM; cleanup; exit 130" INT |
| 153 | |
| 154 | # Assemble the Ant call: |
| 155 | ANT_OPTIONS="${ANT_PROFILE} \ |
| 156 | -Declipse-app.tgz=${ECLIPSE_SDK_TGZ} \ |
| 157 | -Declipse.tests.zip=${ECLIPSE_TESTLIB_ZIP} \ |
Stephan Herrmann | af43e4a | 2013-04-29 23:19:56 +0200 | [diff] [blame] | 158 | -Declipse.sdk.qualifier=${SDK_QUALIFIER} \ |
Stephan Herrmann | 8372dc2 | 2010-06-03 22:41:05 +0000 | [diff] [blame] | 159 | -Dpublished.updates=${PUBLISHED_UPDATES} \ |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 160 | -Ddo.run.tests=${DO_RUN} \ |
Stephan Herrmann | 56428e9 | 2013-02-23 12:29:56 +0100 | [diff] [blame] | 161 | -Ddo.build.all=${DO_BUILD} \ |
Stephan Herrmann | 358ac0f | 2016-11-01 00:29:19 +0100 | [diff] [blame] | 162 | -Dtest.tmpDir=${TEST_TMPDIR} \ |
Stephan Herrmann | cf1ce3f | 2016-11-01 01:04:19 +0100 | [diff] [blame] | 163 | -DfetchCacheLocation=${FETCH_CACHE_LOCATION} \ |
Stephan Herrmann | e8ce6eb | 2016-11-01 01:01:55 +0100 | [diff] [blame] | 164 | -Dmap.file.path=${MAP_FILE_PATH}" |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 165 | |
| 166 | ANT_OPTS="-Xmx1024m" |
| 167 | export ANT_OPTS |
| 168 | |
| 169 | CMD="nice -n ${NICE} ant -f ${BUILDFILE} ${ANT_OPTIONS} ${MAIN_TARGET}" |
| 170 | |
| 171 | if 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 Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 178 | elif 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 Herrmann | 8296dc6 | 2011-05-01 16:28:05 +0000 | [diff] [blame] | 184 | echo "Cleaning up after successful run..." |
| 185 | /bin/rm -rf ${OT_TESTSUITE_DIR}/build-root/eclipse |
Stephan Herrmann | dcd87c1 | 2010-04-25 10:59:27 +0000 | [diff] [blame] | 186 | else |
Stephan Herrmann | 80ce6fa | 2010-05-18 12:16:47 +0000 | [diff] [blame] | 187 | 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] | 188 | echo "Running $CMD" |
| 189 | eval "$CMD" < /dev/null |
| 190 | fi |
| 191 | |
| 192 | trap - INT |
| 193 | |
| 194 | |