Kaydet (Commit) 756203d4 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

make sure we are not leaving soffice around if python process crashes

Change-Id: Idac32c3d788714533ee760782d2b6a328262f3f8
Reviewed-on: https://gerrit.libreoffice.org/31996Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst ef16c96a
......@@ -161,5 +161,8 @@ class PersistentConnection:
self.connection.tearDown()
finally:
self.connection = None
def kill(self):
if self.connection and self.connection.soffice:
self.connection.soffice.kill()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
......@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
import signal
import unittest
import time
......@@ -19,6 +20,7 @@ class UITestCase(unittest.TestCase):
self.opts = opts
def setUp(self):
self.setSignalHandler()
self.connection = PersistentConnection(self.opts)
self.connection.setUp()
self.xContext = self.connection.getContext()
......@@ -29,17 +31,37 @@ class UITestCase(unittest.TestCase):
self.startTime = time.time()
def tearDown(self):
t = time.time() - self.startTime
print("Execution time for %s: %.3f" % (self.id(), t))
if self.xContext is not None:
desktop = self.ui_test.get_desktop()
components = desktop.getComponents()
for component in components:
try:
component.close(False)
except Exception as e:
print(e)
self.connection.tearDown()
try:
t = time.time() - self.startTime
print("Execution time for %s: %.3f" % (self.id(), t))
if self.xContext is not None:
desktop = self.ui_test.get_desktop()
components = desktop.getComponents()
for component in components:
try:
component.close(False)
except Exception as e:
print(e)
self.connection.tearDown()
finally:
self.resetSignalHandler()
self.connection.kill()
def signalHandler(self, signum, frame):
if self.connection:
self.connection.kill()
def setSignalHandler(self):
signal.signal(signal.SIGABRT, self.signalHandler)
signal.signal(signal.SIGSEGV, self.signalHandler)
signal.signal(signal.SIGTERM, self.signalHandler)
signal.signal(signal.SIGILL, self.signalHandler)
def resetSignalHandler(self):
signal.signal(signal.SIGABRT, signal.SIG_IGN)
signal.signal(signal.SIGSEGV, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN)
signal.signal(signal.SIGILL, signal.SIG_IGN)
# vim: set shiftwidth=4 softtabstop=4 expandtab:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment