2 # Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License or as specified alternatively below. You may obtain a copy of
7 # the License at http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
14 # The Initial Developer of the Original Code is
15 # Yifan Jiang, SUSE <yfjiang@suse.com>
16 # Portions created by the Initial Developer are Copyright (C) 2011 the
17 # Initial Developer. All Rights Reserved.
19 # Major Contributor(s):
21 # Portions created by the Ted are Copyright (C) 2010 Ted. All Rights Reserved.
23 # For minor contributions see the git repository.
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 3 or later (the "GPLv3+"), or
27 # the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
28 # in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
29 # instead of those above.
31 # The tool is designed to enable test machine fully automatically run smoketest
32 # with both daily and pre release build located in dev-build.libreoffice.org.
34 # The tool is named as losmoketest for its purpose, meanwhile it help you to
35 # check, download and install the latest build. By the fact the installation is
36 # designed not to be different from manually doing these repeated work, the
37 # installed libreoffice build can also be good for manual test.
39 import sys
, os
, platform
41 import subprocess
, shutil
43 import urllib
, urllib2
44 import logging
, getopt
46 import ConfigParser
as configparser
# Python 3.0 change
50 # FIXME: make this configurable via options or autodetect it
54 install_dirname
="lo-dev"
55 branding_pack
="libo-dev"
56 basis_pack
="libobasis-dev"
59 #install_dirname="libreoffice" + build_version
60 #branding_pack="libreoffice"
61 #basis_pack="libobasis"
62 #ure_pack="libreoffice"
64 build_check_interval
= 5 #seconds
67 RPM_DISTRO_LIST
= ['SuSE', 'fedora', 'redhat', 'centos', 'mandrake', 'mandriva', 'yellowdog', 'turbolinux']
68 DEB_DISTRO_LIST
= ['debian', 'ubuntu', 'Ubuntu']
71 SERVER_URL
= "http://dev-builds.libreoffice.org"
74 root_dir
= os
.getcwd()
75 DOWNLOAD_DIR
= os
.path
.join(root_dir
, "_download")
76 USR_DIR
= os
.path
.join(root_dir
, "_libo_smoke_user")
77 LOCAL_BUILD_INFO_FILE
= "build.cfg"
79 ROOT_DIR_LIB
= os
.path
.join(root_dir
, 'lib')
80 ROOT_DIR_LIB32
= os
.path
.join(root_dir
, 'lib32')
81 ROOT_DIR_LIB64
= os
.path
.join(root_dir
, 'lib64')
82 ROOT_DIR_BIN32
= os
.path
.join(root_dir
, 'bin32')
83 ROOT_DIR_BIN64
= os
.path
.join(root_dir
, 'bin64')
85 CPPUNITTESTER
= os
.path
.join(root_dir
, 'cppunittester')
87 # INSTALL_DIR = os.path.join(root_dir, "_libo_smoke_installation")
88 INSTALL_DIR
= "" # Installation dir
91 if platform
.system() == "Linux":
92 SOFFICE_BIN
= INSTALL_DIR
+ os
.sep
+ "opt" + os
.sep
+ install_dirname
+ os
.sep
+ "program" + os
.sep
+ "soffice"
96 PR_RPM_X86_PATH
= "pre-releases/rpm/x86/"
97 PR_RPM_X86_64_PATH
= "pre-releases/rpm/x86_64/"
99 PR_DEB_X86_PATH
= "pre-releases/deb/x86/"
100 PR_DEB_X86_64_PATH
= "pre-releases/deb/x86_64/"
102 PR_MAC_X86_PATH
= "pre-releases/mac/x86/"
103 PR_MAC_PPC_PATH
= "pre-releases/mac/ppc/"
105 PR_WIN_X86_PATH
= "pre-releases/win/x86/"
108 DAILY_MASTER_RPM_X86_PATH
= "daily/Linux_x86_Release_Configuration/master/current"
109 DAILY_MASTER_RPM_X86_64_PATH
= "daily/Linux_x86_64_Release_Configuration/master/current"
111 DAILY_MASTER_DEB_X86_PATH
= "daily/Linux_x86_Release_Configuration/master/current"
112 DAILY_MASTER_DEB_X86_64_PATH
= "daily/Linux_x86_64_Release_Configuration/master/current" # No build yet
114 DAILY_MASTER_MAC_X86_PATH
= "daily/MacOSX_10.6.7_Intel_no-moz/master/current"
115 DAILY_MASTER_MAC_PPC_PATH
= "^$" # No build yet
117 DAILY_MASTER_WIN_X86_PATH
= "daily/Windows_Release_Configuration/master/current"
120 DAILY_BRANCH_RPM_X86_PATH
= "daily/Linux_x86_Release_Configuration/libreoffice-" + tag_version
+ "/current"
121 DAILY_BRANCH_RPM_X86_64_PATH
= "daily/Linux_x86_64_Release_Configuration/libreoffice-" + tag_version
+ "/current"
123 DAILY_BRANCH_DEB_X86_PATH
= "daily/Linux_x86_Release_Configuration/libreoffice-" + tag_version
+ "/current"
124 DAILY_BRANCH_DEB_X86_64_PATH
= "daily/Linux_x86_64_Release_Configuration/libreoffice-" + tag_version
+ "/current"
126 DAILY_BRANCH_MAC_X86_PATH
= "daily/MacOSX_10.6.7_Intel_no-moz/libreoffice-" + tag_version
+ "/current"
127 DAILY_BRANCH_MAC_PPC_PATH
= "^$" # No build yet
129 DAILY_BRANCH_WIN_X86_PATH
= "daily/Windows_Release_Configuration/libreoffice-" + tag_version
+ "/current"
135 s
= platform
.system()
136 arch_name
= platform
.machine()
138 if arch_name
in ['x86', 'i386', 'i586', 'i686']:
142 if platform
.dist()[0] in RPM_DISTRO_LIST
:
143 distro_name
= platform
.dist()[0]
145 elif platform
.dist()[0] in DEB_DISTRO_LIST
:
146 distro_name
= platform
.dist()[0]
149 distro_name
= platform
.dist()[0]
152 distro_name
= platform
.dist()[0]
155 return distro_name
, pck_name
, arch_name
157 def local_build_info(t
):
159 if not os
.path
.exists(LOCAL_BUILD_INFO_FILE
):
160 logger
.error("Can't find the file: " + LOCAL_BUILD_INFO_FILE
)
163 config
= configparser
.RawConfigParser()
164 config
.read(LOCAL_BUILD_INFO_FILE
)
167 build_name
= config
.get(t
, 'build_name').strip('\n')
168 build_time
= datetime
.datetime
.strptime(config
.get(t
, 'build_time').strip('\n'), '%d-%b-%Y %H:%M')
171 build_time
= datetime
.datetime
.min
173 return build_name
, build_time
175 def get_url_regexp(t
, package
, arch
):
177 return a url containing download links, i.e:
179 http://dev-builds.libreoffice.org/pre-releases/rpm/x86_64/
180 http://dev-builds.libreoffice.org/daily/Windows_Release_Configuration/libreoffice-3-4/current/
181 http://dev-builds.libreoffice.org/daily/Linux_x86_Release_Configuration/libreoffice-3-4/current/
183 meanwhile return a regexp object that matching corresponding downloadable
184 package and its timestamp '''
187 reg
= re
.compile('^$')
191 if t
== 'pre-releases':
192 if pck
== "rpm" and arc
== "x86":
193 url
= SERVER_URL
+ "/" + PR_RPM_X86_PATH
194 reg
= re
.compile('\<a\ href=\"(LibO_\d.*x86_install-rpm.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
195 elif pck
== "rpm" and arc
== "x86_64":
196 url
= SERVER_URL
+ "/" + PR_RPM_X86_64_PATH
197 reg
= 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}).*')
198 elif pck
== "deb" and arc
== "x86":
199 url
= SERVER_URL
+ "/" + PR_DEB_X86_PATH
200 reg
= re
.compile('\<a\ href=\"(LibO_\d.*x86_install-deb.*en-US.*\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
201 elif pck
== "deb" and arc
== "x86_64":
202 url
= SERVER_URL
+ "/" + PR_DEB_X86_64_PATH
203 reg
= 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}).*')
204 elif pck
== "exe" and arc
== "x86":
205 url
= SERVER_URL
+ "/" + PR_WIN_X86_PATH
206 reg
= re
.compile('\<a\ href=\"(LibO_\d.*Win_x86_install_multi.exe)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
207 elif pck
== "dmg" and arc
== "x86":
208 url
= SERVER_URL
+ "/" + PR_MAC_X86_PATH
209 reg
= re
.compile('\<a\ href=\"(LibO_\d.*MacOS_x86_install_en-US.dmg)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
210 elif pck
== "dmg" and arc
== "ppc":
211 url
= SERVER_URL
+ "/" + PR_MAC_PPC_PATH
212 reg
= re
.compile('\<a\ href=\"(LibO_\d.*MacOS_PPC_install_en-US.dmg)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
214 logger
.error("Unable to handle the system or arch!")
215 elif t
== 'daily_master':
216 if pck
== "rpm" and arc
== "x86":
217 url
= SERVER_URL
+ "/" + DAILY_MASTER_RPM_X86_PATH
218 reg
= 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}).*')
219 elif pck
== "rpm" and arc
== "x86_64":
220 url
= SERVER_URL
+ "/" + DAILY_MASTER_RPM_X86_64_PATH
221 reg
= 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}).*')
222 elif pck
== "deb" and arc
== "x86":
223 url
= SERVER_URL
+ "/" + DAILY_MASTER_DEB_X86_PATH
224 reg
= 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}).*')
225 elif pck
== "deb" and arc
== "x86_64":
226 url
= SERVER_URL
+ "/" + DAILY_MASTER_DEB_X86_64_PATH
227 reg
= re
.compile('^$') # No build yet
228 elif pck
== "exe" and arc
== "x86":
229 url
= SERVER_URL
+ "/" + DAILY_MASTER_WIN_X86_PATH
230 reg
= re
.compile('^$') # No build yet
231 elif pck
== "dmg" and arc
== "x86":
232 url
= SERVER_URL
+ "/" + DAILY_MASTER_MAC_X86_PATH
233 reg
= 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}).*')
234 elif pck
== "dmg" and arc
== "ppc":
235 url
= SERVER_URL
+ "/" + DAILY_MASTER_MAC_PPC_PATH
236 reg
= re
.compile('^$') # No build yet
238 logger
.error("Unable to handle the system or arch!")
239 elif t
== 'daily_branch':
240 if pck
== "rpm" and arc
== "x86":
241 url
= SERVER_URL
+ "/" + DAILY_BRANCH_RPM_X86_PATH
242 reg
= re
.compile('\<a\ href=\"(.*LibO_.*x86_install-rpm_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
243 elif pck
== "rpm" and arc
== "x86_64":
244 url
= SERVER_URL
+ "/" + DAILY_BRANCH_RPM_X86_64_PATH
245 reg
= 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}).*')
246 elif pck
== "deb" and arc
== "x86":
247 url
= SERVER_URL
+ "/" + DAILY_BRANCH_DEB_X86_PATH
248 reg
= re
.compile('\<a\ href=\"(.*LibO_.*x86_install-deb_en-US\.tar\.gz)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
249 elif pck
== "deb" and arc
== "x86_64":
250 url
= SERVER_URL
+ "/" + DAILY_BRANCH_DEB_X86_64_PATH
251 reg
= 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}).*')
252 elif pck
== "exe" and arc
== "x86":
253 url
= SERVER_URL
+ "/" + DAILY_BRANCH_WIN_X86_PATH
254 reg
= re
.compile('\<a\ href=\"(.*LibO_.*install_.*\.exe)\".*(\d{2}\-[a-zA-Z]{3}\-\d{4}).*(\d{2}:\d{2}).*')
255 elif pck
== "dmg" and arc
== "x86":
256 url
= SERVER_URL
+ "/" + DAILY_BRANCH_MAC_X86_PATH
257 reg
= re
.compile('^$') # No build yet
258 elif pck
== "dmg" and arc
== "ppc":
259 url
= SERVER_URL
+ "/" + DAILY_BRANCH_MAC_PPC_PATH
260 reg
= re
.compile('^$') # No build yet
262 logger
.error("Unable to handle the system or arch!")
264 logger
.error("Error build type! The build type has to be:\n pre-releases, daily_master, daily_branch")
268 def remote_build_info(url_reg
):
269 ''' Get the latest proper build info (build_name, build_time) from
277 f
= urllib2
.urlopen(url_reg
[0])
278 c
= ''.join(f
.readlines())
281 build_list
= r
.findall(c
)
284 build_time
= datetime
.datetime
.min
287 if datetime
.datetime
.strptime(b
[1] + ' ' + b
[2], '%d-%b-%Y %H:%M') > build_time
:
290 build_time
= datetime
.datetime
.strptime(b
[1] + ' ' + b
[2], '%d-%b-%Y %H:%M')
292 print "remote_build_info: wrong time date&format"
294 return build_name
, build_time
296 # return True when something was downloaded
297 def download(url_reg
, build_type
):
298 logger
.info('Checking new build ...')
301 remote_build
= remote_build_info(url_reg
)
302 local_build
= local_build_info(build_type
)
304 # print 'remote_build[1]=' + remote_build[1].isoformat()
305 # print 'local_build[1]=' + local_build[1].isoformat()
306 if remote_build
[1] > local_build
[1]:
307 logger
.info('Found New build: ' + remote_build
[0])
308 if fetch_build(url_reg
[0], remote_build
[0]):
309 set_build_config(build_type
, 'build_name', remote_build
[0])
310 set_build_config(build_type
, 'build_time', datetime
.datetime
.strftime(remote_build
[1], '%d-%b-%Y %H:%M'))
312 logger
.error('Download build failed!')
316 except urllib2
.URLError
, HTTPError
:
317 logger
.error('Error fetch remote build info.')
319 except KeyboardInterrupt:
328 def fetch_build(url
, filename
):
329 ''' Download a build from address url/filename '''
331 logger
.info("Downloading ... " + filename
)
333 u
= urllib2
.urlopen(url
+ '/' + filename
)
336 f
= open(DOWNLOAD_DIR
+ '/' + filename
, 'wb')
343 def set_build_config(section
, option
, value
):
345 config
= configparser
.RawConfigParser()
346 config
.readfp(open(LOCAL_BUILD_INFO_FILE
))
347 config
.set(section
, option
, value
)
348 with
open(LOCAL_BUILD_INFO_FILE
, 'wb') as cfgfile
:
349 config
.write(cfgfile
)
352 ''' Kill libreoffice processes and uninstall all previously installed
353 libreoffice packages '''
355 logger
.info("Uninstalling ...")
357 pck
= platform_info()[1]
360 cmd_query
= ["rpm", "-qa"]
361 cmd_filter
= ["grep", "-e", branding_pack
+build_version
, "-e", basis_pack
+build_version
, "-e", ure_pack
+build_version
]
363 P_query
= subprocess
.Popen(cmd_query
, stdout
= subprocess
.PIPE
)
364 P_filter
= subprocess
.Popen(cmd_filter
, stdin
= P_query
.stdout
, stdout
= subprocess
.PIPE
)
365 P_query
.stdout
.close() # protection when P_filter exit before P_query
366 str_filter
= P_filter
.communicate()[0]
369 logger
.warning("Nothing to uninstall")
372 cmd
= ["sudo", "rpm", "-e"] + str_filter
.split()
374 cmd_query
= ["dpkg", "--get-selections", branding_pack
+build_version
+"*", basis_pack
+build_version
+"*", ure_pack
+build_version
+"*"]
375 cmd_filter
= ["cut", "-f", "1"]
377 P_query
= subprocess
.Popen(cmd_query
, stdout
= subprocess
.PIPE
)
378 P_filter
= subprocess
.Popen(cmd_filter
, stdin
= P_query
.stdout
, stdout
= subprocess
.PIPE
)
379 P_query
.stdout
.close()
380 str_filter
= P_filter
.communicate()[0]
383 logger
.warning("Nothing to uninstall")
386 cmd
= ["sudo", "dpkg ", "-P"] + str_filter
.split()
392 logger
.warning("Non supported package system")
394 subprocess
.check_call(cmd
)
397 logger
.info("Initializing ...")
401 if not os
.path
.exists(DOWNLOAD_DIR
):
402 os
.mkdir(DOWNLOAD_DIR
)
404 if not os
.path
.exists(USR_DIR
):
407 # create set up links
409 if platform
.system() == "Linux":
410 # remove old symlinks if they exists
411 for p
in ROOT_DIR_LIB
, CPPUNITTESTER
:
412 if os
.path
.exists(p
) and os
.path
.islink(p
):
415 if platform_info()[2] == "x86":
416 os
.symlink(ROOT_DIR_LIB32
, ROOT_DIR_LIB
)
417 os
.symlink(os
.path
.join(ROOT_DIR_BIN32
, 'cppunittester'), CPPUNITTESTER
)
418 elif platform_info()[2] == "x86_64":
419 os
.symlink(ROOT_DIR_LIB64
, ROOT_DIR_LIB
)
420 os
.symlink(os
.path
.join(ROOT_DIR_BIN64
, 'cppunittester'), CPPUNITTESTER
)
424 elif platform
.system() == "Windows" and platform_info()[2] == "x86":
433 logger
.info("Cleaning up ...")
435 # clean up the extracted installer dir
436 for r
in os
.walk(DOWNLOAD_DIR
):
437 if r
[0] == DOWNLOAD_DIR
:
439 shutil
.rmtree(os
.path
.join(r
[0], d
))
441 def install(filename
):
442 ''' filename: local file path of tar.gz, dmg or exe. The script will
443 extract the package and then install it '''
445 logger
.info("Installing ... " + filename
)
447 def _is_not_filtered(s
):
448 ''' True if the package s is not intended to installed. '''
449 filter_pattern_list
= ['.*kde.*', '.*gnome.*', '.*desktop.*', '!.*\.rpm$', '!.*\.deb$']
450 for p
in filter_pattern_list
:
456 fn
, ext
= os
.path
.splitext(filename
)
461 installer_dir
= os
.path
.join(DOWNLOAD_DIR
, filename
.strip(ext
))
462 subprocess
.check_call([filename
, '/EXTRACTONLY=ON', '/S', '/D='+installer_dir
])
464 installer
= glob
.glob(os
.path
.join(installer_dir
, 'libreoffice*msi'))[0]
465 subprocess
.check_call(['msiexec', '-i', installer
, '-passive', 'ADDLOCAL=all'])
470 subprocess
.check_call(['tar', 'xzf', filename
, '-C', DOWNLOAD_DIR
])
472 # get a filtered install list
473 for root
, dirs
, files
in os
.walk(DOWNLOAD_DIR
):
474 if 'RPMS' in root
or 'DEBS' in root
:
475 pcklist
= pcklist
+ [os
.path
.join(root_dir
, root
, f
) for f
in files
]
476 pcklist
= filter(_is_not_filtered
, pcklist
)
479 if platform_info()[1] == 'rpm':
480 install_cmd
= ["sudo", "rpm", "-iv"] + pcklist
481 elif platform_info()[1] == 'deb':
482 install_cmd
= ["sudo", "dpkg", "-i"] + pcklist
484 logger
.error('Cannot generate install command')
487 subprocess
.check_call(install_cmd
)
490 logger
.info("Unrecognized file extension")
492 def verify_smoketest(headless
):
493 logger
.info("Testing ...")
495 s
= platform
.system()
502 os
.environ
['SAL_USE_VCLPLUGIN'] = "svp"
503 os
.environ
['LD_LIBRARY_PATH'] = ""
504 os
.environ
['LD_LIBRARY_PATH'] = ':'.join([os
.path
.join(root_dir
, 'lib'), INSTALL_DIR
+ '/opt/' + install_dirname
+ '/ure/lib', os
.environ
['LD_LIBRARY_PATH']])
507 "-env:UNO_SERVICES=file://"+ INSTALL_DIR
+ "/opt/" + install_dirname
+ "/ure/share/misc/services.rdb",
508 "-env:UNO_TYPES=" + os
.path
.join(os
.path
.join(root_dir
, 'lib'), "types.rdb"),
509 "-env:arg-soffice=path:" + SOFFICE_BIN
,
510 "-env:arg-user=" + USR_DIR
,
511 "-env:arg-env=" + os
.environ
['LD_LIBRARY_PATH'],
512 "-env:arg-testarg.smoketest.doc=" + os
.path
.join(root_dir
, "doc/smoketestdoc.sxw"),
514 os
.path
.join(root_dir
, "lib/unoexceptionprotector.so"), "unoexceptionprotector",
515 os
.path
.join(root_dir
, "lib/libsmoketest.so")
518 logger
.warning('The smoketest does not support this platform yet!')
521 subprocess
.check_call(cmd_cppu
)
522 logger
.info(" Smoketest PASSED")
524 logger
.error(" Smoketest FAILED")
529 print "\n[Usage]\n\n -f Force testing without asking \n\
530 -t Testing type pre-release/daily \n\
531 -l Download and test last builds in a loop \n\
532 -v Run smoketest verification directly \n\
533 -s Use the headless mode when running the tests \n\
534 -i Install the latest build in the DOWNLOAD directory \n\
535 -u Uninstall any existed libreoffice build \n\
536 -d Download the latest build for the given test type \n\
542 build_type
= "pre-releases"
544 package_type
= platform_info()[1]
545 arch_type
= platform_info()[2]
550 build_type
= "pre-releases"
552 # Handling options and arguments
554 opts
, args
= getopt
.getopt(sys
.argv
[1:], "dluihfvst:", ["download", "loop", "uninstall", "install", "help", "force", "verify", "headless", "type="])
555 except getopt
.GetoptError
, err
:
556 logger
.error(str(err
))
561 if ("-t" in o
) or ("--type" in o
):
563 elif o
in ("-s", "--headless"):
566 url_reg
= get_url_regexp(build_type
, package_type
, arch_type
)
569 if o
in ("-f", "--force"):
571 elif o
in ("-t", "--type"):
573 elif o
in ("-s", "--headless"):
575 elif o
in ("-h", "--help"):
578 elif o
in ("-v", "--verify"):
580 verify_smoketest(headless
)
582 elif o
in ("-i", "--install"):
585 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[0])
587 elif o
in ("-u", "--uninstall"):
590 elif o
in ("-d", "--download"):
591 download(url_reg
, build_type
)
593 elif o
in ("-l", "--loop"):
596 assert False, "Unhandled option: " + o
598 if interactive
== True:
599 key
= raw_input("The testing will OVERRIDE existed libreoffice, continue(y/N)? ")
600 if not (key
== "y" or key
== "Y" or key
== "yes"):
605 while loop
or first_run
:
606 if download(url_reg
, build_type
):
608 # FIXME: uninstall script fails but it need not break the whole game; so try it twice
612 logger
.error("Some errors happend during uninstall. Trying once again.")
615 install(DOWNLOAD_DIR
+ os
.sep
+ local_build_info(build_type
)[0])
616 verify_smoketest(headless
)
618 except KeyboardInterrupt:
624 time
.sleep(build_check_interval
)
629 if __name__
== '__main__':
632 logger
= logging
.getLogger('')
633 logger
.setLevel(logging
.DEBUG
)
635 fh
= logging
.FileHandler('losmoketest.log')
636 ch
= logging
.StreamHandler()
638 formatter
= logging
.Formatter('%(asctime)s - %(levelname)s - %(message)s')
639 ch
.setFormatter(formatter
)
640 fh
.setFormatter(formatter
)
642 logger
.addHandler(ch
)
643 logger
.addHandler(fh
)