Initial import of ORISYS arm workstation
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class ParentExitTest(TestCase):
|
||||
def test_backend_shuts_down_when_ui_owner_exits(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
path=Path(directory)/'service.sock'
|
||||
source='''import os,subprocess,sys,time
|
||||
p=subprocess.Popen([sys.executable,'-m','station.control_service','--socket',sys.argv[1],'--offline','--parent-pid',str(os.getpid())],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
|
||||
print(p.pid,flush=True)
|
||||
end=time.monotonic()+8
|
||||
while not os.path.exists(sys.argv[1]) and p.poll() is None and time.monotonic()<end:time.sleep(.02)
|
||||
assert os.path.exists(sys.argv[1])
|
||||
'''
|
||||
parent=subprocess.run([sys.executable,'-c',source,str(path)],capture_output=True,text=True,timeout=12)
|
||||
self.assertEqual(parent.returncode,0,parent.stderr)
|
||||
end=time.monotonic()+8
|
||||
while path.exists() and time.monotonic()<end: time.sleep(.1)
|
||||
if path.exists():
|
||||
os.kill(int(parent.stdout.strip()),15)
|
||||
self.fail('orphan backend did not stop')
|
||||
Reference in New Issue
Block a user