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. 31
      Tools/autotest/examples.py

31
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)
bob.kill() print("pre-kill retcode: %s" % str(retcode))
bob.wait() if retcode is not None:
if bob.returncode is None: raise ValueError("Process exited before I could kill it (%s)" % str(retcode))
raise ValueError("Unable to kill subprocess") bob.send_signal(signal.SIGTERM)
print("returncode: %u" % (bob.returncode)) time.sleep(1)
if bob.returncode != -9: retcode = bob.poll()
raise ValueError("Process exitted before I got to kill it (exit code=%u)" % bob.returncode) print("retcode: %s" % str(retcode))
print("returncode2: %u" % (bob.returncode)) 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()
retcode2 = bob.wait()
print("retcode2: %s" % str(retcode2))
elif retcode == -15:
print("process exited with -15, indicating it didn't catch the TERM signal and exit properly")
elif retcode != 0:
# note that process could exit with code 0 and we couldn't tell...
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