update dev300-m58
[ooovba.git] / solenv / bin / cwscheckapi
blob410d31b0a5045fcdfc89a80fcbe9d56b5822dead
1 #!/bin/bash
2 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: cwscheckapi,v $
11 # $Revision: 1.5 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
29 #***********************************************************************/
32 EXIT_SUCCESS=0
33 EXIT_FAILURE=1
34 EXIT_ERROR=2
35 EXIT_BUG=10
37 # report the given error parameter to cwstestresult if the is one.
38 # 0: no error send ok or parameter $2
39 # 1: failure
40 # 2...: incomplete
41 function reportError()
43 ERRORCODE=$1
44 if [ -e $SOLARENV/bin/cwstestresult.pl ]; then
45 if [ $ERRORCODE -eq 0 ]; then
46 PT_STATUS=${2:-ok} # use default 'ok' or $2
47 elif [ $ERRORCODE -eq 1 ]; then
48 PT_STATUS=failed
49 else
50 PT_STATUS=incomplete
53 if [ "$OSTYPE" == "cygwin" ]; then
54 CWSENV=Windows
55 elif [ "$OSTYPE" == "linux" ]; then
56 CWSENV=Linux
57 elif [ "$OSTYPE" == "solaris" ]; then
58 CWSENV=SolarisX86
59 else
60 CWSENV=Unknown
62 perl $SOLARENV/bin/cwstestresult.pl -c $CWS_WORK_STAMP -n CWSCheckAPI -p $CWSENV $PT_STATUS
63 else
64 echo "No cwstestresult.pl found."
68 usage() {
69 echo "Usage: $SCRIPTNAME [-m MODULE1[,MODULEn]] [-k] [-o] [-h] [-d] [-u] [-t] [-s] [-a]" >&2
70 echo "" >&2
71 echo "[-m] list of modules to test like: '-m sw,sc,sd' or '-m all' for all modules" >&2
72 echo "" >&2
73 echo "[-k] keep Office installation, otherwise it will be removed after test" >&2
74 echo "" >&2
75 echo "[-o] force OpenOffice.org installation instead of StarOffice" >&2
76 echo "" >&2
77 echo "[-d] debug installation and UnoAPI-Tests" >&2
78 # echo "" >&2
79 # echo "[-i] debug installation" >&2
80 echo "" >&2
81 echo "[-t] debug UnoAPI-Tests" >&2
82 echo "" >&2
83 echo "[-s] skip installation of Office" >&2
84 echo "" >&2
85 echo "[-a] NoCwsAttach: do not attach UnoAPI-Test result to EIS database" >&2
86 echo "" >&2
87 echo "[-u] UseInstalledOffice: do not install an office" >&2
88 echo "" >&2
89 echo "further informations: http://wiki.services.openoffice.org/wiki/Cwscheckapi" >&2
90 echo "" >&2
91 exit $EXIT_FAILURE
94 # we start cwscheckapi
95 reportError 0 running
97 if [ "$PROEXT" != ".pro" ]; then
98 echo "ERROR: cwscheckapi works only on pro-versions" >&2
99 reportError 2
100 exit $EXIT_FAILURE
103 if [ x${USER}x = xx ]; then
104 if [ x${LOGNAME}x = xx ]; then
105 echo "ERROR: could not determine username. Please export variable USER" >&2
106 reportError 2
107 exit $EXIT_FAILURE
108 else
109 USER=$LOGNAME
110 export USER
116 #DEBUG_I=false
117 DEBUG_T=false
118 INSTALL=true
119 ATTACH=true
120 MODULES="auto"
121 OOO=false
122 KEEPOFFICE=false
123 USE_INSTALLED_OFFICE=false
125 while getopts ':m:dkutsaho' OPTION ; do
126 case $OPTION in
128 # DEBUG_I=true
129 DEBUG_T=true
132 MODULES="$OPTARG"
135 KEEPOFFICE=true
138 OOO=true
140 # i)
141 # DEBUG_I=true
142 # ;;
144 DEBUG_T=true
147 INSTALL=false
150 ATTACH=false
153 USE_INSTALLED_OFFICE=true
154 INSTALL=false
155 KEEPOFFICE=true
156 echo "make sure your office is started with parameter -accept=pipe,name=$USER;urp;"
159 usage $EXIT_SUCCESS
162 echo "unkown option \"-$OPTARG\"." >&2
163 usage $EXIT_ERROR
166 echo "this is not possible...">&2
167 usage $EXIT_BUG
169 esac
170 done
172 shift `expr $OPTIND - 1`
174 if [ -d /export/home/$USER ]; then
175 CWSCHECKAPIPATH=/export/home/$USER/cwscheckapi
176 else
177 if [ -w /export/home ]; then
178 mkdir /export/home/$USER
179 CWSCHECKAPIPATH=/export/home/$USER/cwscheckapi
180 else
181 CWSCHECKAPIPATH=/tmp/$USER/cwscheckapi
185 # the following line is to cleanup old cwscheckapi-installations. It results form the first version of cwscheckapi
186 # The disk space on /tmp is limited. If a lot of users run cwscheckapi a lot of installed offices are in /tmp
187 # The new concept is to remove the offices after test. But old unused installations should be removed...
188 if [ $CWSCHECKAPIPATH != /tmp/$USER/cwscheckapi ]; then
189 rm -rf /tmp/$USER/cwscheckapi
192 LOCALINSTALLDIR=$CWSCHECKAPIPATH/office
193 LOCALUNPACKDIR=$CWSCHECKAPIPATH/unpack
194 export LOCALINSTALLDIR
195 export LOCALUNPACKDIR
197 unset FORCE2ARCHIVE
199 if [ $INSTALL = true ]; then
201 date 2>&1
203 # if [ $DEBUG_I = true ]; then
204 # echo "start installation: `date`"
205 # echo call "$SOLARENV/bin/installoffice.pl -cwscheckapi true -dest $LOCALINSTALLDIR -debug $DEBUG_I"
206 # fi
207 perl -w $SOLARENV/bin/installoffice.pl -cwscheckapi true -dest $LOCALINSTALLDIR -ooo $OOO -debug $DEBUG_I
209 EXITVAL=$?
211 if [ $EXITVAL -ne 0 ]; then
212 echo "ERROR: could not install office"
213 reportError 2
214 exit $EXITVAL
216 echo "`date` installation successfull, start testing...."
219 SOFFICE="soffice"
220 PS=":"
221 CYGWIN=""
223 SHELL="/bin/bash"
224 # cygwin:
225 if [ "$GUI" = "WNT" ]; then
226 SOFFICE="soffice.exe"
227 PS=";"
228 CYGWIN="-Cygwin true"
229 SHELL=$(which bash)
230 SHELL=$(cygpath -w $SHELL)
231 if [ ! -f $SHELL ]; then
232 echo "could not determine bash shell"
233 reportError 2
234 exit 1
238 # if [ $DEBUG_T = true ]; then
239 # echo find $LOCALINSTALLDIR -name $SOFFICE
240 # fi
242 if [ $USE_INSTALLED_OFFICE = false ]; then
244 OFFICEBIN=`find $LOCALINSTALLDIR -name $SOFFICE`
246 if [ ! -f "$OFFICEBIN" ]; then
247 echo "could not find 'soffice' in subfolders of $LOCALINSTALLDIR"
248 reportError 2
249 exit 1
252 if [ "$GUI" = "WNT" ]; then
253 # transform /tmp/... -> c:\tmp\...
254 OFFICEBIN=`cygpath -w $OFFICEBIN`
256 else
257 OFFICEBIN=$SOFFICE
258 echo "Use already installed and running office."
261 JARFOLDER=$SOLARVERSION/$INPATH/bin$UPDMINOREXT
262 SOLVER_LIB=$SOLARVERSION/$INPATH/lib$UPDMINOREXT
264 myCLASSPATH=${PS}${JARFOLDER}/ridl.jar${PS}\
265 ${JARFOLDER}/unoil.jar${PS}\
266 ${JARFOLDER}/jurt.jar${PS}\
267 ${JARFOLDER}/juh.jar${PS}\
268 ${JARFOLDER}/java_uno.jar
270 myCLASSPATH=$myCLASSPATH${PS}\
271 ${JARFOLDER}/OOoRunner.jar
273 myCLASSPATH=$myCLASSPATH${PS}\
274 /net/unoapi/export/unoapi/bin/mysql.jar${PS}\
275 $SOLVER_LIB
277 PARAM=""
278 if [ -n "$JAVAI" ]; then
279 JAVABIN=$JAVAI
280 elif [ -n "$JAVA_HOME" ]; then
281 if [ "$OS$CPUNAME$CPU" = SOLARISSPARCU ]; then
282 JAVABIN=$JAVA_HOME/bin/sparcv9/java
283 else
284 JAVABIN=$JAVA_HOME/bin/java
286 else
287 echo "please set environment variable JAVA_HOME"
288 reportError 2
289 exit 1
292 if [ -n "$WORK_STAMP" ]; then
293 if [ -n "$CWS_WORK_STAMP" ]; then
294 PARAM="$PARAM -Version cws_${CWS_WORK_STAMP}"
295 else
296 echo "######"
297 echo CAUTION! You are working on the MWS
298 echo "######"
299 PARAM="$PARAM -Version ${WORK_STAMP}_${UPDMINOR}"
303 PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -no-oosplash -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
304 PARAM="$PARAM -cs pipe,name=$USER"
305 PARAM="$PARAM -NoOffice true"
306 PARAM="$PARAM -SRC_ROOT $SRC_ROOT"
307 PARAM="$PARAM -COMP_ENV $OUTPATH"
308 PARAM="$PARAM -Shell $SHELL"
309 PARAM="$PARAM $CYGWIN"
310 PARAM="$PARAM -tb java_complex"
311 PARAM="$PARAM -TimeOut 90000"
312 PARAM="$PARAM -o complex.unoapi.CheckModuleAPI::module($MODULES)"
313 if [ $ATTACH = false ]; then
314 PARAM="$PARAM -nca true"
316 if [ $DEBUG_T = true ]; then
317 PARAM="$PARAM -debug true -log true"
320 # Sample command
321 # /so/env/Linux_JDK_1.5.0_06/bin/java
322 # -Xmx120m $XDEBUG
323 # -cp :/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/ridl.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/unoil.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/jurt.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/juh.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/java_uno.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/bin.m50/OOoRunner.jar:/net/unoapi/export/unoapi/bin/mysql.jar:/net/so-cwsserv02/export/cws/unoapi04/DEV300/unxlngi6.pro/lib.m50
324 # org.openoffice.Runner
325 # -Version cws_unoapi04
326 # -cmd '/tmp/ll93751/cwscheckapi/office/staroffice9/program/soffice -nofirststartwizard -accept=pipe,name=ll93751;urp; -norestore -nocrashreport -nolockcheck -enableautomation'
327 # -cs pipe,name=ll93751
328 # -NoOffice true
329 # -SRC_ROOT /net/so-cwsserv02/export/cws/unoapi04/DEV300/src.m50
330 # -COMP_ENV unxlngi6
331 # -Shell /bin/bash
332 # -tb java_complex
333 # -TimeOut 90000
334 # -o 'complex.unoapi.CheckModuleAPI::module(auto)'
336 # XDEBUG=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9003,suspend=y "
338 # set DEBUGAPI if you want to debug the checkapi
339 # DEBUGAPI=t
341 COMMAND="$JAVABIN -Xmx120m $XDEBUG -cp $myCLASSPATH org.openoffice.Runner $PARAM $*"
342 echo "$COMMAND"
344 LOGFILE=$CWSCHECKAPIPATH/cwscheckapi.log
345 $COMMAND | tee $LOGFILE
346 EXITVAL=$?
348 if [ $KEEPOFFICE = false ]; then
349 echo "remove office instrallation in $LOCALINSTALLDIR..."
350 rm -rf $LOCALINSTALLDIR
353 echo
354 echo A logfile could be found here: $LOGFILE
356 date 2>&1
358 # send the results via cwstestresult.pl to EIS
359 if [ $EXITVAL -eq 0 ]; then
360 reportError 0 ok
361 else
362 reportError 1