提交 5396527f 编写于 作者: D David S. Miller

Merge branch 'tdc-fixes'

Lucas Bates says:

====================
Prevent uncaught exceptions in tdc

This patch series addresses two potential bugs in tdc that can
cause exceptions to be raised in certain circumstances.  These
exceptions are generally not handled, so instead we will prevent
them from being raised.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -134,9 +134,9 @@ def exec_cmd(args, pm, stage, command): ...@@ -134,9 +134,9 @@ def exec_cmd(args, pm, stage, command):
(rawout, serr) = proc.communicate() (rawout, serr) = proc.communicate()
if proc.returncode != 0 and len(serr) > 0: if proc.returncode != 0 and len(serr) > 0:
foutput = serr.decode("utf-8") foutput = serr.decode("utf-8", errors="ignore")
else: else:
foutput = rawout.decode("utf-8") foutput = rawout.decode("utf-8", errors="ignore")
proc.stdout.close() proc.stdout.close()
proc.stderr.close() proc.stderr.close()
...@@ -169,6 +169,8 @@ def prepare_env(args, pm, stage, prefix, cmdlist, output = None): ...@@ -169,6 +169,8 @@ def prepare_env(args, pm, stage, prefix, cmdlist, output = None):
file=sys.stderr) file=sys.stderr)
print("\n{} *** Error message: \"{}\"".format(prefix, foutput), print("\n{} *** Error message: \"{}\"".format(prefix, foutput),
file=sys.stderr) file=sys.stderr)
print("returncode {}; expected {}".format(proc.returncode,
exit_codes))
print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr) print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr)
print("\n\n{} *** stdout ***".format(proc.stdout), file=sys.stderr) print("\n\n{} *** stdout ***".format(proc.stdout), file=sys.stderr)
print("\n\n{} *** stderr ***".format(proc.stderr), file=sys.stderr) print("\n\n{} *** stderr ***".format(proc.stderr), file=sys.stderr)
...@@ -195,12 +197,18 @@ def run_one_test(pm, args, index, tidx): ...@@ -195,12 +197,18 @@ def run_one_test(pm, args, index, tidx):
print('-----> execute stage') print('-----> execute stage')
pm.call_pre_execute() pm.call_pre_execute()
(p, procout) = exec_cmd(args, pm, 'execute', tidx["cmdUnderTest"]) (p, procout) = exec_cmd(args, pm, 'execute', tidx["cmdUnderTest"])
exit_code = p.returncode if p:
exit_code = p.returncode
else:
exit_code = None
pm.call_post_execute() pm.call_post_execute()
if (exit_code != int(tidx["expExitCode"])): if (exit_code is None or exit_code != int(tidx["expExitCode"])):
result = False result = False
print("exit:", exit_code, int(tidx["expExitCode"])) print("exit: {!r}".format(exit_code))
print("exit: {}".format(int(tidx["expExitCode"])))
#print("exit: {!r} {}".format(exit_code, int(tidx["expExitCode"])))
print(procout) print(procout)
else: else:
if args.verbose > 0: if args.verbose > 0:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册