Commit ff896d2e authored by Jérome Perrin's avatar Jérome Perrin

proctitle

parent 574aafdb
import os
import shutil
import subprocess
import tempfile
import unittest
import sys
import time
from erp5.util.testnode.ProcessManager import ProcessManager
class TestProcessManagerKillAll(unittest.TestCase):
def setUp(self):
self.path = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.path)
self.script = os.path.join(self.path, 'script')
with open(self.script, 'w') as f:
f.write('#!/bin/sh\nsleep 30')
os.chmod(self.script, 0o700)
self.pm = ProcessManager()
self.start_time = time.time()
def tearDown(self):
self.assertLess(time.time() - self.start_time, 29)
def test_killall_script_in_path(self):
process = subprocess.Popen([self.script])
self.pm.killall(self.path)
process.communicate()
self.assertTrue(process.poll())
def test_killall_another_path(self):
process = subprocess.Popen([self.script])
self.pm.killall("another path")
self.assertIsNone(process.poll())
process.kill()
process.communicate()
process.wait()
def test_killall_proctitle(self):
with open(self.script, 'w') as f:
f.write('''if 1:
import setproctitle
''')
process = subprocess.Popen([sys.executable, self.script])
self.pm.killall("another path")
self.assertIsNone(process.poll())
process.kill()
process.communicate()
process.wait()
...@@ -57,6 +57,13 @@ setup(name=name, ...@@ -57,6 +57,13 @@ setup(name=name,
'benchmark': benchmark_install_require_list, 'benchmark': benchmark_install_require_list,
'benchmark-report': [name+'[benchmark]', 'matplotlib', 'numpy'], 'benchmark-report': [name+'[benchmark]', 'matplotlib', 'numpy'],
'zodbanalyse': ['ZODB'], 'zodbanalyse': ['ZODB'],
'test': [
'mock; python_version < "3"',
'psutil >= 0.5.0',
'setproctitle',
'slapos.core',
'xml_marshaller',
]
}, },
zip_safe=True, zip_safe=True,
packages=package_list, packages=package_list,
...@@ -75,13 +82,6 @@ setup(name=name, ...@@ -75,13 +82,6 @@ setup(name=name,
'web_checker_utility = erp5.util.webchecker:web_checker_utility' 'web_checker_utility = erp5.util.webchecker:web_checker_utility'
], ],
}, },
test_suite='erp5.tests',
tests_require=[
'slapos.core',
'xml_marshaller',
'psutil >= 0.5.0',
'mock; python_version < "3"',
],
) )
# cleanup garbage # cleanup garbage
......
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