Update ooo320-m1
[ooovba.git] / testautomation / tools / run_tests / run_tests.sh
blob4195a9abbea27680f18ede6e6da560e37b675810
1 #!/bin/bash
2 #*************************************************************************
3 #*
4 #* OpenOffice.org - a multi-platform office productivity suite
5 #*
6 #* $RCSfile: run_tests.sh,v $
7 #*
8 #* $Revision: 1.2 $
9 #*
10 #* last change: $Author: andreschnabel $ $Date: 2008/09/05 16:56:19 $
12 #* The Contents of this file are made available subject to
13 #* the terms of GNU Lesser General Public License Version 2.1.
16 #* GNU Lesser General Public License Version 2.1
17 #* =============================================
18 #* Copyright 2005 by Sun Microsystems, Inc.
19 #* 901 San Antonio Road, Palo Alto, CA 94303, USA
21 #* This library is free software; you can redistribute it and/or
22 #* modify it under the terms of the GNU Lesser General Public
23 #* License version 2.1, as published by the Free Software Foundation.
25 #* This library is distributed in the hope that it will be useful,
26 #* but WITHOUT ANY WARRANTY; without even the implied warranty of
27 #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 #* Lesser General Public License for more details.
30 #* You should have received a copy of the GNU Lesser General Public
31 #* License along with this library; if not, write to the Free Software
32 #* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #* MA 02111-1307 USA
35 #########################################################################
37 # Owner : andreschnabel@openoffice.org
39 # short description : run several testscripts on unix
40 # list of scripts to run is read from stdin
41 # this script has been derived from former ooo_releasetests.sh
43 #########################################################################
46 # set location of testscripts (the 'qatesttool' directory)
47 # if this is empty, we try to parse $HOME/.testtoolrc
48 sLocation=""
50 # set location of TestTool
51 # (full path including executable 'testtool')
52 # if this is empty, we try to parse $HOME/.testtoolrc and use OOoProgramdir
53 # on Mac this is VCLTestTool.app/Contents/MacOS/testtool.bin
54 #sTestTool="/Users/sca/qa/testtool/VCLTestTool.app/Contents/MacOS/testtool.bin"
55 sTestTool=""
57 #------------------------------------------------------------------------
58 #--- internally used functions ---
59 #------------------------------------------------------------------------
60 function GetValueFromSection ()
61 # call with NameOfValue Section file
63 $AWK -v sVarName="$1" -v sSectionName="$2" \
64 'BEGIN { bInSection = 0}
65 { if ( index ($0 ,"[" sSectionName "]") > 0 )
66 bInSection = 1
67 else if ( (bInSection == 1) && (substr ($0,1,1) == "[") )
68 bInSection = 0
69 if ( (bInSection == 1) && (index ($0 , sVarName "=") == 1)) {
70 sub(/\r$/,"")
71 print substr ($0,index ($0 ,"=") + 1)
73 }' < "$3"
76 #------------------------------------------------------------------------
77 #--- the main script starts here ---
78 #------------------------------------------------------------------------
80 #platform specific settings
81 case `uname -s` in
82 Darwin)
83 testtoolrc="$HOME/Library/Application Support/.testtoolrc"
84 KILLOFFICEALL="/usr/bin/killall -9 soffice.bin"
85 AWK=awk
87 SunOS)
88 testtoolrc="$HOME/.testtoolrc"
89 KILLOFFICEALL="pkill -9 soffice.bin"
90 AWK=nawk
93 testtoolrc="$HOME/.testtoolrc"
94 KILLOFFICEALL="pkill -9 soffice.bin"
95 AWK=awk
97 esac
99 # if sLocation is not set manuall try to get the location form testtoolrc
100 if [ -z "$sLocation" ]
101 then
102 # first read the profile
103 sProfile=`GetValueFromSection CurrentProfile Misc "$testtoolrc"`
104 # then read the BaseDir for the profile
105 sLocation=`GetValueFromSection BaseDir "$sProfile" "$testtoolrc"`
106 sLocation="$sLocation/"
109 # set location of close-office file
110 # (see cvs)
111 sExitOfficeBas="${sLocation}global/tools/closeoffice.bas"
112 sResetOfficeBas="${sLocation}global/tools/resetoffice.bas"
114 # if sTestTool is not set manuall try to get the location form testtoolrc
115 if [ -z "$sTestTool" ]
116 then
117 sTestTool=`GetValueFromSection Current OOoProgramDir "$testtoolrc"`
118 sTestTool="$sTestTool/basis-link/program/testtool.bin"
123 echo "****************************************************"
124 echo "************ STARTING ************"
125 echo "****************************************************"
127 # check if there is a virtual display available
129 echo "DISPLAY is set to: " $DISPLAY
130 echo "My name is: " $USER
132 # test if location exists
133 if [ -d "$sLocation" ]
134 then
135 echo "using scripts from $sLocation"
136 else
137 echo "test scripts not found at $sLocation"
138 echo "Please set sLocation in this script"
139 exit 1
142 # test if testtool.bin exists
143 if [ -f "$sTestTool" ]
144 then
145 echo "using testtool from $sTestTool"
146 else
147 echo "testtool not found at $sTestTool"
148 echo "Please set sTestTool in this script"
149 exit 1
154 while read x ;
156 echo "Running soffices' processes: "
157 # kill office, if exists
158 `$KILLOFFICEALL`
160 echo "****************************************************"
161 x=`echo "$x"|sed s/[[:blank:]]*$//` #cut all trailing blanks
162 sTest="$sLocation$x"
163 if [ -f "$sTest" ]; then
165 # two pass logic - first pass is the real test, second pass is reset office, third is closeoffice
166 for z in "1" "2";
168 echo "running <$sTest>"
169 "$sTestTool" -run "$sTest" &
170 sleep 5
171 echo " "
173 ######### save the PID from the last Background job
174 testtoolpid=$!
175 echo "PID of Testtool: " $testtoolpid
177 if [ `ps -A | grep -v "grep" | grep $testtoolpid | wc -l` -gt 0 ] ; then
178 echo " Successfully started"
179 else
180 echo " There might be something wrong with starting the Testtool!"
183 ######### wait until Testtool has finished & closed
184 while [ `ps -A | grep -v "grep" | grep $testtoolpid | wc -l` -gt 0 ] ;
186 sleep 5
187 i=$((i+5))
188 done
190 ####### for the second run use the office reset script!
191 case $z in
192 "1") sTest="$sResetOfficeBas";;
193 esac
194 done
195 else
196 echo "Error: file <$sTest> not found"
198 done
200 echo "Duration:" $((i/60)) "min" $((i%60)) "sec "
202 echo "****************************************************"
203 echo "************ FINISHED ************"
204 echo "****************************************************"