Browse Source

autotest: make running examples in autotest more reliable

c415-sdk
Peter Barker 5 years ago committed by Peter Barker
parent
commit
e3cc580dbc
  1. 29
      Tools/autotest/examples.py

29
Tools/autotest/examples.py

@ -1,6 +1,7 @@
from __future__ import print_function from __future__ import print_function
import os import os
import signal
import subprocess import subprocess
import time import time
@ -15,15 +16,29 @@ def run_example(filepath, valgrind=False, gdb=False):
cmd.append(filepath) cmd.append(filepath)
print("Running: (%s)" % str(cmd)) print("Running: (%s)" % str(cmd))
bob = subprocess.Popen(cmd, stdin=None, close_fds=True) bob = subprocess.Popen(cmd, stdin=None, close_fds=True)
retcode = bob.poll()
time.sleep(10) time.sleep(10)
print("pre-kill retcode: %s" % str(retcode))
if retcode is not None:
raise ValueError("Process exited before I could kill it (%s)" % str(retcode))
bob.send_signal(signal.SIGTERM)
time.sleep(1)
retcode = bob.poll()
print("retcode: %s" % str(retcode))
if retcode is None:
# if we get this far then we're not going to get a gcda file
# out of this process for coverage analysis; it has to exit
# normally, and it hasn't responded to a TERM.
bob.kill() bob.kill()
bob.wait() retcode2 = bob.wait()
if bob.returncode is None: print("retcode2: %s" % str(retcode2))
raise ValueError("Unable to kill subprocess") elif retcode == -15:
print("returncode: %u" % (bob.returncode)) print("process exited with -15, indicating it didn't catch the TERM signal and exit properly")
if bob.returncode != -9: elif retcode != 0:
raise ValueError("Process exitted before I got to kill it (exit code=%u)" % bob.returncode) # note that process could exit with code 0 and we couldn't tell...
print("returncode2: %u" % (bob.returncode)) raise ValueError("Process exitted with non-zero exitcode %s" % str(retcode))
print("Ran: (%s)" % str(cmd))
def run_examples(debug=False, valgrind=False, gdb=False): def run_examples(debug=False, valgrind=False, gdb=False):
dirpath = util.reltopdir(os.path.join('build', 'linux', 'examples')) dirpath = util.reltopdir(os.path.join('build', 'linux', 'examples'))

Loading…
Cancel
Save