summaryrefslogtreecommitdiffhomepage
path: root/test/unit
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:15:20 +0300
committerAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:15:20 +0300
commitefb461c0e1dcd15577a6a072668990facc5533f6 (patch)
tree2acbe6645bc33426ab5dda5641982d527ad776c2 /test/unit
parentb5e3e22a46df6700415583002a15cc15eaac8514 (diff)
downloadunit-efb461c0e1dcd15577a6a072668990facc5533f6.tar.gz
unit-efb461c0e1dcd15577a6a072668990facc5533f6.tar.bz2
Tests: run_process() and stop_processes() introduced.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/main.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/main.py b/test/unit/main.py
index f5727726..094fdb0e 100644
--- a/test/unit/main.py
+++ b/test/unit/main.py
@@ -185,6 +185,8 @@ class TestUnit(unittest.TestCase):
if self._started:
self._stop()
+ self.stop_processes()
+
def _run(self):
self.unitd = self.pardir + '/build/unitd'
@@ -287,6 +289,26 @@ class TestUnit(unittest.TestCase):
if found:
print('skipped.')
+ def run_process(self, target):
+ if not hasattr(self, '_processes'):
+ self._processes = []
+
+ process = Process(target=target)
+ process.start()
+
+ self._processes.append(process)
+
+ def stop_processes(self):
+ if not hasattr(self, '_processes'):
+ return
+
+ for process in self._processes:
+ process.terminate()
+ process.join(timeout=5)
+
+ if process.is_alive():
+ self.fail('Fail to stop process')
+
def waitforfiles(self, *files):
for i in range(50):
wait = False