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

wip test to confirm terminating nxdtest terminates running test program

parent 2fdb6067
Pipeline #18740 failed with stage
in 0 seconds
......@@ -19,17 +19,19 @@
# verify general functionality
import subprocess
import sys
import re
import signal
import time
from os.path import dirname
from os.path import dirname, exists
from golang import chan, select, default, func, defer
from golang import context, sync
import psutil
import pytest
from nxdtest import main
import nxdtest
@pytest.fixture
......@@ -46,7 +48,7 @@ def run_nxdtest(tmpdir):
sys_argv = sys.argv
sys.argv = argv
try:
main()
nxdtest.main()
finally:
sys.argv = sys_argv
......@@ -230,3 +232,29 @@ TestCase('TEST1', ['%s', '%s'])
with open(pidfile) as f:
pid = int(f.read())
assert not psutil.pid_exists(pid)
@pytest.mark.timeout(timeout=10)
@pytest.mark.parametrize('signal_number', [signal.SIGINT, signal.SIGTERM])
def test_interrupted_test(run_nxdtest, capsys, tmp_path, tmpdir, signal_number):
slow = "%s/testprog/slow" % (dirname(__file__),)
pidfile = str(tmp_path / 'slow.pid')
with tmpdir.as_cwd():
with open('.nxdtest', 'w') as f:
f.write(
"""\
TestCase('TEST1', ['%s', '%s'])
""" % (slow, pidfile))
nxdtest_process = subprocess.Popen([sys.executable, '%s/__init__.py' % dirname(nxdtest.__file__)])
# wait for process to start
for _ in range(10):
if exists(pidfile):
break
time.sleep(.5)
nxdtest_process.send_signal(signal_number)
nxdtest_process.wait()
with open(pidfile) as f:
pid = int(f.read())
assert not psutil.pid_exists(pid)
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