cmd.append(found)
else:
cmd.append(arg)
- cmd = " ".join(cmd)
- result = os.system(cmd)
- assert result == 0, "%r failed" % cmd
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = process.communicate()
+ if process.returncode:
+ print
+ header("Compile failed")
+ print "+", " ".join(cmd)
+ print stdout,
+ print stderr,
+ header("")
+ raise Exception("Compile failed!")
def unused_port():
# http://stackoverflow.com/questions/2838244/get-open-tcp-port-in-python/2838309#2838309
# This command needs to come before any config scripts on the command
# line, since they are executed in order.
- # Tell OpenOCD to bind to an unused port.
- cmd[1:1] = ["--command", "gdb_port %d" % 0]
+ cmd[1:1] = [
+ # Tell OpenOCD to bind gdb to an unused, ephemeral port.
+ "--command",
+ "gdb_port 0",
+ # Disable tcl and telnet servers, since they are unused and because
+ # the port numbers will conflict if multiple OpenOCD processes are
+ # running on the same server.
+ "--command",
+ "tcl_port disabled",
+ "--command",
+ "telnet_port disabled",
+ ]
logfile = open(Openocd.logname, "w")
logfile.write("+ %s\n" % " ".join(cmd))
except subprocess.CalledProcessError:
output = ""
matches = list(PORT_REGEX.finditer(output))
- matches = [m for m in matches if m.group('port') not in ('6666', '4444')]
+ matches = [m for m in matches
+ if m.group('port') not in ('6666', '4444')]
if len(matches) > 1:
print output
raise Exception(
help="Run only tests that are named here.")
def header(title, dash='-'):
- dashes = dash * (36 - len(title))
- before = dashes[:len(dashes)/2]
- after = dashes[len(dashes)/2:]
- print "%s[ %s ]%s" % (before, title, after)
+ if title:
+ dashes = dash * (36 - len(title))
+ before = dashes[:len(dashes)/2]
+ after = dashes[len(dashes)/2:]
+ print "%s[ %s ]%s" % (before, title, after)
+ else:
+ print dash * 40
class BaseTest(object):
compiled = {}