summaryrefslogtreecommitdiff
path: root/uitest
diff options
context:
space:
mode:
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: