summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-14 07:14:35 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-19 18:50:43 +0000
commit756203d490720deb53f7da4914d738b064b9e157 (patch)
tree40902830445cae983269158f5cf5b2b2d7740abc /uitest
parentef16c96a51809f97d66e7e22595388e54e974cf1 (diff)
make sure we are not leaving soffice around if python process crashes
Change-Id: Idac32c3d788714533ee760782d2b6a328262f3f8 Reviewed-on: https://gerrit.libreoffice.org/31996 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'uitest')
-rw-r--r--uitest/libreoffice/connection.py3
-rw-r--r--uitest/uitest/framework.py46
2 files changed, 37 insertions, 12 deletions
diff --git a/uitest/libreoffice/connection.py b/uitest/libreoffice/connection.py
index 1b0150bb6f79..c717632b3b23 100644
--- a/uitest/libreoffice/connection.py
+++ b/uitest/libreoffice/connection.py
@@ -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:
diff --git a/uitest/uitest/framework.py b/uitest/uitest/framework.py
index 7d4a78d4419b..f21d72bd9b12 100644
--- a/uitest/uitest/framework.py
+++ b/uitest/uitest/framework.py
@@ -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: