Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6cecf4a authored by Brenda J. Butler's avatar Brenda J. Butler Committed by David S. Miller
Browse files

tc-testing: tdc.py: Guard against lack of returncode in executed command



Add some defensive coding in case one of the subprocesses created by tdc
returns nothing. If no object is returned from exec_cmd, then tdc will
halt with an unhandled exception.

Signed-off-by: default avatarBrenda J. Butler <bjb@mojatatu.com>
Signed-off-by: default avatarLucas Bates <lucasb@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5aaf6428
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ def prepare_env(args, pm, stage, prefix, cmdlist, output = None):
                  file=sys.stderr)
            print("\n{} *** Error message: \"{}\"".format(prefix, foutput),
                  file=sys.stderr)
            print("returncode {}; expected {}".format(proc.returncode,
                                                      exit_codes))
            print("\n{} *** Aborting test run.".format(prefix), file=sys.stderr)
            print("\n\n{} *** stdout ***".format(proc.stdout), 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):
        print('-----> execute stage')
    pm.call_pre_execute()
    (p, procout) = exec_cmd(args, pm, 'execute', tidx["cmdUnderTest"])
    if p:
        exit_code = p.returncode
    else:
        exit_code = None

    pm.call_post_execute()

    if (exit_code != int(tidx["expExitCode"])):
    if (exit_code is None or exit_code != int(tidx["expExitCode"])):
        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)
    else:
        if args.verbose > 0: