All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] Prevent uncaught exceptions in tdc
@ 2018-11-16 22:37 Lucas Bates
  2018-11-16 22:37 ` [PATCH net 1/2] tc-testing: tdc.py: ignore errors when decoding stdout/stderr Lucas Bates
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Bates @ 2018-11-16 22:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, xiyou.wangcong, jiri, kernel, Lucas Bates

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.

Brenda J. Butler (1):
  tc-testing: tdc.py: Guard against lack of returncode in executed
    command

Lucas Bates (1):
  tc-testing: tdc.py: ignore errors when decoding stdout/stderr

 tools/testing/selftests/tc-testing/tdc.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] tc-testing: tdc.py: ignore errors when decoding stdout/stderr
  2018-11-16 22:37 [PATCH net 0/2] Prevent uncaught exceptions in tdc Lucas Bates
@ 2018-11-16 22:37 ` Lucas Bates
  2018-11-16 22:37 ` [PATCH net 2/2] tc-testing: tdc.py: Guard against lack of returncode in executed command Lucas Bates
  2018-11-18  5:55 ` [PATCH net 0/2] Prevent uncaught exceptions in tdc David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Bates @ 2018-11-16 22:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, xiyou.wangcong, jiri, kernel, Lucas Bates

Prevent exceptions from being raised while decoding output
from an executed command. There is no impact on tdc's
execution and the verify command phase would fail the pattern
match.

Signed-off-by: Lucas Bates <lucasb@mojatatu.com>
---
 tools/testing/selftests/tc-testing/tdc.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index 87a04a8..9b3f414 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -134,9 +134,9 @@ def exec_cmd(args, pm, stage, command):
     (rawout, serr) = proc.communicate()
 
     if proc.returncode != 0 and len(serr) > 0:
-        foutput = serr.decode("utf-8")
+        foutput = serr.decode("utf-8", errors="ignore")
     else:
-        foutput = rawout.decode("utf-8")
+        foutput = rawout.decode("utf-8", errors="ignore")
 
     proc.stdout.close()
     proc.stderr.close()
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] tc-testing: tdc.py: Guard against lack of returncode in executed command
  2018-11-16 22:37 [PATCH net 0/2] Prevent uncaught exceptions in tdc Lucas Bates
  2018-11-16 22:37 ` [PATCH net 1/2] tc-testing: tdc.py: ignore errors when decoding stdout/stderr Lucas Bates
@ 2018-11-16 22:37 ` Lucas Bates
  2018-11-18  5:55 ` [PATCH net 0/2] Prevent uncaught exceptions in tdc David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Bates @ 2018-11-16 22:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, xiyou.wangcong, jiri, kernel, Brenda J. Butler, Lucas Bates

From: "Brenda J. Butler" <bjb@mojatatu.com>

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: Brenda J. Butler <bjb@mojatatu.com>
Signed-off-by: Lucas Bates <lucasb@mojatatu.com>
---
 tools/testing/selftests/tc-testing/tdc.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tdc.py b/tools/testing/selftests/tc-testing/tdc.py
index 9b3f414..7607ba3 100755
--- a/tools/testing/selftests/tc-testing/tdc.py
+++ b/tools/testing/selftests/tc-testing/tdc.py
@@ -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"])
-    exit_code = p.returncode
+    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:
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] Prevent uncaught exceptions in tdc
  2018-11-16 22:37 [PATCH net 0/2] Prevent uncaught exceptions in tdc Lucas Bates
  2018-11-16 22:37 ` [PATCH net 1/2] tc-testing: tdc.py: ignore errors when decoding stdout/stderr Lucas Bates
  2018-11-16 22:37 ` [PATCH net 2/2] tc-testing: tdc.py: Guard against lack of returncode in executed command Lucas Bates
@ 2018-11-18  5:55 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-11-18  5:55 UTC (permalink / raw)
  To: lucasb; +Cc: netdev, xiyou.wangcong, jiri, kernel

From: Lucas Bates <lucasb@mojatatu.com>
Date: Fri, 16 Nov 2018 17:37:54 -0500

> 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.

Series applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-18 16:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 22:37 [PATCH net 0/2] Prevent uncaught exceptions in tdc Lucas Bates
2018-11-16 22:37 ` [PATCH net 1/2] tc-testing: tdc.py: ignore errors when decoding stdout/stderr Lucas Bates
2018-11-16 22:37 ` [PATCH net 2/2] tc-testing: tdc.py: Guard against lack of returncode in executed command Lucas Bates
2018-11-18  5:55 ` [PATCH net 0/2] Prevent uncaught exceptions in tdc David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.