3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # The tool is designed to enable test machine fully automatically run smoketest
11 # with both daily and pre release build located in dev-build.libreoffice.org.
13 # The tool is named as losmoketest for its purpose, meanwhile it help you to
14 # check, download and install the latest build. By the fact the installation is
15 # designed not to be different from manually doing these repeated work, the
16 # installed libreoffice build can also be good for manual test.
18 import sys
, os
, platform
20 import subprocess
, shutil
22 import urllib
, urllib2
23 import logging
, getopt
25 import ConfigParser
as configparser
# Python 3.0 change
29 # FIXME: make this configurable via options or autodetect it
34 basis_pack
="lodevbasis"
36 #branding_pack="libreoffice"
37 #basis_pack="libobasis"
39 # possible program files of libreoffice, put all platform paths are
40 # expected in this list
42 "/opt/lodev" + build_version
, \
43 "/opt/libreoffice" + build_version
, \
44 "/usr/lib/libreoffice", \
45 "/usr/lib64/libreoffice", \
46 "C:\program file\libreoffice", \
49 build_check_interval
= 5 #seconds
52 RPM_DISTRO_LIST
= ['SuSE', 'fedora', 'redhat', 'centos', 'mandrake', 'mandriva', 'yellowdog', 'turbolinux']
53 DEB_DISTRO_LIST
= ['debian', 'ubuntu', 'Ubuntu']
56 SERVER_URL
= "http://dev-builds.libreoffice.org"
59 root_dir
= os
.getcwd()
60 DOWNLOAD_DIR
= os
.path
.join(root_dir
, "_download")
61 USR_DIR
= os
.path
.join(root_dir
, "_libo_smoke_user")
62 LOCAL_BUILD_INFO_FILE
= os
.path
.join(root_dir
, "build.cfg")
64 # INSTALL_DIR = os.path.join(root_dir, "_libo_smoke_installation")
65 INSTALL_DIR
= "" # Installation dir
68 if platform
.system() == "Linux":
69 SOFFICE_BIN
= "soffice"
70 LOSMOKETEST_BIN
= "losmoketest"
71 elif platform
.system() == "Windows":
72 SOFFICE_BIN
= "soffice.exe"
73 LOSMOKETEST_BIN
= "losmoketest"
75 SOFFICE_BIN
= "soffice"
76 LOSMOKETEST_BIN
= "losmoketest"
80 PR_RPM_X86_PATH
= "pre-releases/rpm/x86/"
81 PR_RPM_X86_64_PATH
= "pre-releases/rpm/x86_64/"
83 PR_DEB_X86_PATH
= "pre-releases/deb/x86/"
84 PR_DEB_X86_64_PATH
= "pre-releases/deb/x86_64/"
86 PR_MAC_X86_PATH
= "pre-releases/mac/x86/"
87 PR_MAC_PPC_PATH
= "pre-releases/mac/ppc/"
89 PR_WIN_X86_PATH
= "pre-releases/win/x86/"
92 DAILY_MASTER_RPM_X86_PATH
= "daily/Linux-x86_10-Release_Configuration/master/current"
93 DAILY_MASTER_RPM_X86_64_PATH
= "daily/Linux-x86_64_11-Release_Configuration/master/current"
95 DAILY_MASTER_DEB_X86_PATH
= "daily/Linux-x86_10-Release_Configuration/master/current"
96 DAILY_MASTER_DEB_X86_64_PATH
= "daily/Linux-x86_64_11-Release_Configuration/master/current"
98 DAILY_MASTER_MAC_X86_PATH
= "daily/MacOSX-Intel@3-OSX_10.6.0-gcc_4.0.1/master/current"
99 DAILY_MASTER_MAC_PPC_PATH
= "daily/MacOSX-PPC@12-OSX_10.5.0-gcc_4.0.1/master/current" # No build yet
101 DAILY_MASTER_WIN_X86_PATH
= "daily/Win-x86@7-MinGW/master/current" # cross compling build
104 DAILY_BRANCH_RPM_X86_PATH
= "daily/Linux-x86_10-Release_Configuration/libreoffice-" + tag_version
+ "/current"
105 DAILY_BRANCH_RPM_X86_64_PATH
= "daily/Linux-x86_64_11-Release_Configuration/libreoffice-" + tag_version
+ "/current"
107 DAILY_BRANCH_DEB_X86_PATH
= "daily/Linux-x86_10-Release_Configuration/libreoffice-" + tag_version
+ "/current"
108 DAILY_BRANCH_DEB_X86_64_PATH
= "daily/Linux-x86_64_11-Release_Configuration/libreoffice-" + tag_version
+ "/current"
110 DAILY_BRANCH_MAC_X86_PATH
= "daily/MacOSX-Intel@3-OSX_10.6.0-gcc_4.0.1/libreoffice-" + tag_version
+ "/current"
111 DAILY_BRANCH_MAC_PPC_PATH
= "daily/MacOSX-PPC@12-OSX_10.5.0-gcc_4.0.1/libreoffice-" + tag_version
+ "/current"
113 DAILY_BRANCH_WIN_X86_PATH
= "daily/Win-x86@7-MinGW/libreoffice-" + tag_version
+ "/current"
119 s
= platform
.system()
120 arch_name
= platform
.machine()
122 if arch_name
in ['x86', 'i386', 'i586', 'i686']:
126 if platform
.dist()[0] in RPM_DISTRO_LIST
:
127 distro_name
= platform
.dist()[0]
129 elif platform
.dist()[0] in DEB_DISTRO_LIST
:
130 distro_name
= platform
.dist()[0]
133 distro_name
= platform
.dist()[0]
136 distro_name
= platform
.dist()[0]
139 return distro_name
, pck_name
, arch_name
141 def local_build_info(t
):
143 if not os
.path
.exists(LOCAL_BUILD_INFO_FILE
):
144 logger
.error("Can't find the file: " + LOCAL_BUILD_INFO_FILE
)
147 config
= configparser
.RawConfigParser()
148 config
.read(LOCAL_BUILD_INFO_FILE
)
151 build_name
= config
.get(t
, 'build_name').strip('\n')
152 build_time
= datetime
.datetime
.strptime(config
.get(t
, 'build_time').strip('\n'), '%d-%b-%Y %H:%M')
155 build_time
= datetime
.datetime
.min
158 testpack_name
= config
.get(t
, 'testpack_name').strip('\n')
159 testpack_build_time
= datetime
.datetime
.strptime(config
.get(t
, 'testpack_build_time').strip('\n'), '%d-%b-%Y %H:%M')
162 testpack_build_time
= datetime
.datetime
.min
164 return build_name
, build_time
, testpack_name
, testpack_build_time
166 def get_url_regexp(t
, package
, arch
):
168 return a url containing download links, i.e:
170 http://dev-builds.libreoffice.org/pre-releases/rpm/x86_64/
171 http://dev-builds.libreoffice.org/daily/Windows_Release_Configuration/libreoffice-3-4/current/
172 http://dev-builds.libreoffice.org/daily/Linux_x86_Release_Configuration/libreoffice-3-4/current/
174 meanwhile return a regexp object that matching corresponding downloadable
175 package and its timestamp '''
178 reg_lo
= re
.compile('^$')
179 reg_tst
= re
.compile('^$')
183 if t
== 'pre-releases':
184 if pck
== "rpm" and arc
== "x86":
185 url
= SERVER_URL
+ "/" + PR_RPM_X86_PATH
186 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*x86_install-rpm.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
187 reg_tst
= re
.compile('\<a\ href=\"(LibO-Test.*.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
188 elif pck
== "rpm" and arc
== "x86_64":
189 url
= SERVER_URL
+ "/" + PR_RPM_X86_64_PATH
190 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*x86-64_install-rpm.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
191 reg_tst
= re
.compile('\<a\ href=\"(LibO-Test.*.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
192 elif pck
== "deb" and arc
== "x86":
193 url
= SERVER_URL
+ "/" + PR_DEB_X86_PATH
194 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*x86_install-deb.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
195 elif pck
== "deb" and arc
== "x86_64":
196 url
= SERVER_URL
+ "/" + PR_DEB_X86_64_PATH
197 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*x86-64_install-deb.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
198 elif pck
== "exe" and arc
== "x86":
199 url
= SERVER_URL
+ "/" + PR_WIN_X86_PATH
200 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*Win_x86_install_multi.exe)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
201 elif pck
== "dmg" and arc
== "x86":
202 url
= SERVER_URL
+ "/" + PR_MAC_X86_PATH
203 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*MacOS_x86_install_en-US.dmg)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
204 elif pck
== "dmg" and arc
== "ppc":
205 url
= SERVER_URL
+ "/" + PR_MAC_PPC_PATH
206 reg_lo
= re
.compile('\<a\ href=\"(LibO_\d.*MacOS_PPC_install_en-US.dmg)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
208 logger
.error("Unable to handle the system or arch!")
209 elif t
== 'daily_master':
210 if pck
== "rpm" and arc
== "x86":
211 url
= SERVER_URL
+ "/" + DAILY_MASTER_RPM_X86_PATH
212 reg_lo
= re
.compile('\<a\ href=\"(master\~\d.*LibO-Dev_.*x86_install-rpm_en-US.tar.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
213 elif pck
== "rpm" and arc
== "x86_64":
214 url
= SERVER_URL
+ "/" + DAILY_MASTER_RPM_X86_64_PATH
215 reg_lo
= re
.compile('\<a\ href=\"(master\~\d.*LibO-Dev_.*x86-64_install-rpm_en-US.tar.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
216 elif pck
== "deb" and arc
== "x86":
217 url
= SERVER_URL
+ "/" + DAILY_MASTER_DEB_X86_PATH
218 reg_lo
= re
.compile('\<a\ href=\"(master\~\d.*LibO-Dev_.*x86_install-deb_en-US.tar.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
219 elif pck
== "deb" and arc
== "x86_64":
220 url
= SERVER_URL
+ "/" + DAILY_MASTER_DEB_X86_64_PATH
221 reg_lo
= re
.compile('^$') # No build yet
222 elif pck
== "exe" and arc
== "x86":
223 url
= SERVER_URL
+ "/" + DAILY_MASTER_WIN_X86_PATH
224 reg_lo
= re
.compile('^$') # No build yet
225 elif pck
== "dmg" and arc
== "x86":
226 url
= SERVER_URL
+ "/" + DAILY_MASTER_MAC_X86_PATH
227 reg_lo
= re
.compile('\<a\ href=\"(master\~\d.*LibO-Dev_.*x86_install_en-US.dmg)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
228 elif pck
== "dmg" and arc
== "ppc":
229 url
= SERVER_URL
+ "/" + DAILY_MASTER_MAC_PPC_PATH
230 reg_lo
= re
.compile('^$') # No build yet
232 logger
.error("Unable to handle the system or arch!")
233 elif t
== 'daily_branch':
234 if pck
== "rpm" and arc
== "x86":
235 url
= SERVER_URL
+ "/" + DAILY_BRANCH_RPM_X86_PATH
236 reg_lo
= re
.compile('\<a\ href=\"(.*LibO_.*x86_install-rpm_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
237 elif pck
== "rpm" and arc
== "x86_64":
238 url
= SERVER_URL
+ "/" + DAILY_BRANCH_RPM_X86_64_PATH
239 reg_lo
= re
.compile('\<a\ href=\"(.*LibO_.*x86-64_install-rpm_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
240 elif pck
== "deb" and arc
== "x86":
241 url
= SERVER_URL
+ "/" + DAILY_BRANCH_DEB_X86_PATH
242 reg_lo
= re
.compile('\<a\ href=\"(.*LibO_.*x86_install-deb_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
243 elif pck
== "deb" and arc
== "x86_64":
244 url
= SERVER_URL
+ "/" + DAILY_BRANCH_DEB_X86_64_PATH
245 reg_lo
= re
.compile('\<a\ href=\"(.*LibO_.*x86-64_install-deb_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
246 elif pck
== "exe" and arc
== "x86":
247 url
= SERVER_URL
+ "/" + DAILY_BRANCH_WIN_X86_PATH
248 reg_lo
= re
.compile('\<a\ href=\"(.*LibO_.*install_.*\.exe)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
249 elif pck
== "dmg" and arc
== "x86":
250 url
= SERVER_URL
+ "/" + DAILY_BRANCH_MAC_X86_PATH
251 reg_lo
= re
.compile('^$') # No build yet
252 elif pck
== "dmg" and arc
== "ppc":
253 url
= SERVER_URL
+ "/" + DAILY_BRANCH_MAC_PPC_PATH
254 reg_lo
= re
.compile('^$') # No build yet
256 logger
.error("Unable to handle the system or arch!")
258 logger
.error("Error build type! The build type has to be:\n pre-releases, daily_master, daily_branch")
260 return url
, reg_lo
, reg_tst
262 def remote_build_info(url_reg
):
263 ''' Get the latest proper build info (build_name, build_time) from
272 f
= urllib2
.urlopen(url_reg
[0])
273 c
= ''.join(f
.readlines())
276 build_list
= r
.findall(c
)
277 test_list
= r_t
.findall(c
)
280 build_time
= datetime
.datetime
.min
281 testpack_build_time
= datetime
.datetime
.min
286 if datetime
.datetime
.strptime(b
[1] + ' ' + b
[2], '%d-%b-%Y %H:%M') > build_time
:
289 build_time
= datetime
.datetime
.strptime(b
[1] + ' ' + b
[2], '%d-%b-%Y %H:%M')
291 print "remote_build_info: wrong time date&format"
294 if datetime
.datetime
.strptime(t
[1] + ' ' + t
[2], '%d-%b-%Y %H:%M') > testpack_build_time
:
297 testpack_build_time
= datetime
.datetime
.strptime(t
[1] + ' ' + t
[2], '%d-%b-%Y %H:%M')
299 print "remote_build_info: wrong time date&format"
301 return build_name
, build_time
, testpack_name
, testpack_build_time
303 # return True when something was downloaded
304 def download(url_reg
, build_type
):
305 logger
.info('Checking new build ...')
308 remote_build
= remote_build_info(url_reg
)
309 local_build
= local_build_info(build_type
)
311 if remote_build
[1] > local_build
[1]:
312 logger
.info('Found New LO build: ' + remote_build
[0])
313 if fetch_build(url_reg
[0], remote_build
[0]):
314 set_build_config(build_type
, 'build_name', remote_build
[0])
315 set_build_config(build_type
, 'build_time', datetime
.datetime
.strftime(remote_build
[1], '%d-%b-%Y %H:%M'))
317 logger
.error('Download libreoffice build failed!')
319 if remote_build
[3] > local_build
[3] and (remote_build
[1] - remote_build
[3]) < datetime
.timedelta(hours
=1):
320 logger
.info('Found a relevant smoketest package: ' + remote_build
[2])
321 if fetch_build(url_reg
[0], remote_build
[2]):
322 set_build_config(build_type
, 'testpack_name', remote_build
[2])
323 set_build_config(build_type
, 'testpack_build_time', datetime
.datetime
.strftime(remote_build
[3], '%d-%b-%Y %H:%M'))
326 logger
.warning("Failed to find corresponding smoketest package")
328 except urllib2
.URLError
, HTTPError
:
329 logger
.error('Error fetch remote build info.')
331 except KeyboardInterrupt:
334 logger
.error('Error fetch remote build info.')
339 def fetch_build(url
, filename
):
340 ''' Download a build from address url/filename '''
342 logger
.info("Downloading ... " + filename
)
344 u
= urllib2
.urlopen(url
+ '/' + filename
)
347 f
= open(DOWNLOAD_DIR
+ '/' + filename
, 'wb')
350 except urllib2
.HTTPError
, e
:
351 print "HTTP Error:",e
.code
, url
352 except urllib2
.URLError
, e
:
353 print "URL Error:",e
.reason
, url
357 def set_build_config(section
, option
, value
):
359 config
= configparser
.RawConfigParser()
360 config
.readfp(open(LOCAL_BUILD_INFO_FILE
))
361 config
.set(section
, option
, value
)
362 with
open(LOCAL_BUILD_INFO_FILE
, 'wb') as cfgfile
:
363 config
.write(cfgfile
)
365 def uninstall(build_type
):
366 ''' Kill libreoffice processes and uninstall all previously installed
367 libreoffice packages '''
369 if build_type
== "pre-releases":
370 branding_pack
="libreoffice"
371 basis_pack
="libobasis"
373 logger
.info("Uninstalling ...")
375 pck
= platform_info()[1]
378 cmd_query
= ["rpm", "-qa"]
379 cmd_filter
= ["grep", \
380 "-e", branding_pack
+build_version
, \
381 "-e", basis_pack
+build_version
, \
384 P_query
= subprocess
.Popen(cmd_query
, stdout
= subprocess
.PIPE
)
385 P_filter
= subprocess
.Popen(cmd_filter
, stdin
= P_query
.stdout
, stdout
= subprocess
.PIPE
)
386 P_query
.stdout
.close() # protection when P_filter exit before P_query
387 str_filter
= P_filter
.communicate()[0]
390 logger
.warning("Nothing to uninstall")
393 cmd
= ["sudo", "rpm", "-e"] + str_filter
.split()
395 cmd_query
= ["dpkg", "--get-selections", branding_pack
+build_version
+"*", basis_pack
+build_version
+"*"]
396 cmd_filter
= ["cut", "-f", "1"]
398 P_query
= subprocess
.Popen(cmd_query
, stdout
= subprocess
.PIPE
)
399 P_filter
= subprocess
.Popen(cmd_filter
, stdin
= P_query
.stdout
, stdout
= subprocess
.PIPE
)
400 P_query
.stdout
.close()
401 str_filter
= P_filter
.communicate()[0]
404 logger
.warning("Nothing to uninstall")
407 cmd
= ["sudo", "dpkg ", "-P"] + str_filter
.split()
413 logger
.warning("Non supported package system")
415 subprocess
.check_call(cmd
)
418 logger
.info("Initializing ...")
422 if not os
.path
.exists(DOWNLOAD_DIR
):
423 os
.mkdir(DOWNLOAD_DIR
)
425 if not os
.path
.exists(USR_DIR
):
428 if not os
.path
.exists(LOCAL_BUILD_INFO_FILE
):
430 init_build_cfg
= '[daily_branch]' + os
.linesep\
431 + 'build_name =' + os
.linesep\
432 + 'build_time =' + os
.linesep\
433 + 'testpack_name =' + os
.linesep\
434 + 'testpack_build_time =' + os
.linesep\
435 + '[daily_master]' + os
.linesep\
436 + 'build_name =' + os
.linesep\
437 + 'build_time =' + os
.linesep\
438 + 'testpack_name =' + os
.linesep\
439 + 'testpack_build_time =' + os
.linesep\
440 + '[pre-releases]' + os
.linesep\
441 + 'build_name =' + os
.linesep\
442 + 'build_time =' + os
.linesep \
443 + 'testpack_name =' + os
.linesep\
444 + 'testpack_build_time =' + os
.linesep
446 with
open(LOCAL_BUILD_INFO_FILE
, 'w+') as f
:
447 f
.write(init_build_cfg
)
451 logger
.info("Cleaning up ...")
453 # clean up the extracted installer dir
454 for r
in os
.walk(DOWNLOAD_DIR
):
455 if r
[0] == DOWNLOAD_DIR
:
457 shutil
.rmtree(os
.path
.join(r
[0], d
))
459 def install(filename
):
460 ''' filename: local file path of tar.gz, dmg or exe. The script will
461 extract the package and then install it '''
463 logger
.info("Installing ... " + filename
)
465 def _is_not_filtered(s
):
466 ''' True if the package s is not intended to installed. '''
467 filter_pattern_list
= ['.*kde.*', '.*gnome.*', '.*desktop.*', '!.*\.rpm$', '!.*\.deb$']
468 for p
in filter_pattern_list
:
474 fn
, ext
= os
.path
.splitext(filename
)
479 installer_dir
= os
.path
.join(DOWNLOAD_DIR
, filename
.strip(ext
))
480 subprocess
.check_call([filename
, '/EXTRACTONLY=ON', '/S', '/D='+installer_dir
])
482 installer
= glob
.glob(os
.path
.join(installer_dir
, 'libreoffice*msi'))[0]
483 subprocess
.check_call(['msiexec', '-i', installer
, '-passive', 'ADDLOCAL=all'])
488 subprocess
.check_call(['tar', 'xzf', filename
, '-C', DOWNLOAD_DIR
])
490 # get a filtered install list
491 for root
, dirs
, files
in os
.walk(DOWNLOAD_DIR
):
492 if 'RPMS' in root
or 'DEBS' in root
:
493 pcklist
= pcklist
+ [os
.path
.join(root_dir
, root
, f
) for f
in files
]
494 install_pcklist
= filter(_is_not_filtered
, pcklist
)
497 if platform_info()[1] == 'rpm':
498 install_cmd
= ["sudo", "rpm", "-iv"] + install_pcklist
499 clean_tmp_cmd
= ["sudo", "rm", "-f"] + pcklist
500 elif platform_info()[1] == 'deb':
501 install_cmd
= ["sudo", "dpkg", "-i"] + install_pcklist
503 logger
.error('Cannot generate install command')
506 subprocess
.check_call(install_cmd
)
507 subprocess
.check_call(clean_tmp_cmd
)
510 logger
.info("Unrecognized file extension")
512 def verify_smoketest(headless
):
513 logger
.info("Testing ...")
515 s
= platform
.system()
520 lo_testable_paths
= filter(lambda p
: \
521 os
.path
.exists(p
+ os
.sep
+ "program" + os
.sep
+ LOSMOKETEST_BIN
) and \
522 os
.path
.exists(p
+ os
.sep
+ "program" + os
.sep
+ SOFFICE_BIN
), \
525 if not lo_testable_paths
:
526 logger
.error("Not found any Libreoffice or Test packages!")
529 cmd_smoketests
= [ p
+ os
.sep
+ "program" + os
.sep
+ LOSMOKETEST_BIN
for p
in lo_testable_paths
]
531 if len(lo_testable_paths
) > 1:
532 logger
.info("++More than one testable build is found, test them one by one.")
534 # subprocess.call(cmd_smoketest);
535 for c
in cmd_smoketests
:
536 pattern
= re
.compile(LOSMOKETEST_BIN
+ "$")
537 logger
.info(" Test Binary: " + pattern
.sub(SOFFICE_BIN
, c
))
542 print "\n[Usage]\n\n -f Force testing without asking \n\
543 -t Testing type pre-release/daily \n\
544 -l Download and test last builds in a loop \n\
545 -v Run smoketest verification directly \n\
546 -s Use the headless mode when running the tests \n\
547 -i Install the latest build in the DOWNLOAD directory \n\
548 -u Uninstall any existed libreoffice build \n\
549 -d Download the latest build for the given test type \n\
555 build_type
= "pre-releases"
557 package_type
= platform_info()[1]
558 arch_type
= platform_info()[2]
563 build_type
= "pre-releases"
565 # Handling options and arguments
567 opts
, args
= getopt
.getopt(sys
.argv
[1:], "dluihfvst:", ["download", "loop", "uninstall", "install", "help", "force", "verify", "headless", "type="])
568 except getopt
.GetoptError
, err
:
569 logger
.error(str(err
))
574 if ("-t" in o
) or ("--type" in o
):
576 elif o
in ("-s", "--headless"):
579 url_reg
= get_url_regexp(build_type
, package_type
, arch_type
)
582 if o
in ("-f", "--force"):
584 elif o
in ("-t", "--type"):
586 elif o
in ("-s", "--headless"):
588 elif o
in ("-h", "--help"):
591 elif o
in ("-v", "--verify"):
593 verify_smoketest(headless
)
595 elif o
in ("-i", "--install"):
597 uninstall(build_type
)
598 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[0])
599 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[2])
601 elif o
in ("-u", "--uninstall"):
602 uninstall(build_type
)
604 elif o
in ("-d", "--download"):
606 download(url_reg
, build_type
)
608 elif o
in ("-l", "--loop"):
611 assert False, "Unhandled option: " + o
613 if interactive
== True:
614 key
= raw_input("The testing will OVERRIDE existed libreoffice, continue(y/N)? ")
615 if not (key
== "y" or key
== "Y" or key
== "yes"):
620 while loop
or first_run
:
621 if download(url_reg
, build_type
):
623 # FIXME: uninstall script fails but it need not break the whole game; so try it twice
625 uninstall(build_type
)
627 logger
.error("Some errors happened during uninstall. Trying once again.")
628 uninstall(build_type
)
630 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[0])
631 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[2])
632 verify_smoketest(headless
)
634 except KeyboardInterrupt:
639 logger
.warning("No new build found.")
641 time
.sleep(build_check_interval
)
646 if __name__
== '__main__':
649 logger
= logging
.getLogger('')
650 logger
.setLevel(logging
.DEBUG
)
652 fh
= logging
.FileHandler(os
.path
.basename(__file__
) + '.log')
653 ch
= logging
.StreamHandler()
655 formatter
= logging
.Formatter('%(asctime)s - %(levelname)s - %(message)s')
656 ch
.setFormatter(formatter
)
657 fh
.setFormatter(formatter
)
659 logger
.addHandler(ch
)
660 logger
.addHandler(fh
)