frame trace plus more logging
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/91c84327 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/91c84327 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/91c84327 Branch: refs/heads/fix Commit: 91c84327fbb5b778bd4a99c2c74a8efdb5415d43 Parents: f7c795b Author: Alan Conway <[email protected]> Authored: Tue Jan 26 16:17:30 2016 -0500 Committer: Alan Conway <[email protected]> Committed: Tue Jan 26 16:17:30 2016 -0500 ---------------------------------------------------------------------- examples/cpp/engine/example_test.py | 63 +++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/91c84327/examples/cpp/engine/example_test.py ---------------------------------------------------------------------- diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py index 7a0a523..6d438bc 100644 --- a/examples/cpp/engine/example_test.py +++ b/examples/cpp/engine/example_test.py @@ -26,7 +26,11 @@ from subprocess import Popen, PIPE, STDOUT from copy import copy import platform from os.path import dirname as dirname -from threading import Thread, Event +from threading import Thread +try: + from Queue import Queue, Empty +except: + from queue import Queue, Empty # FIXME aconway 2016-01-26: os.environ["PN_TRACE_FRM"] = "1" @@ -65,20 +69,32 @@ class ExampleTest(unittest.TestCase): @staticmethod def wait_line(io, pattern, timeout=5): - found = Event() - def find_line(): + print >>sys.stderr, "FIXME wait_line", pattern + try: + found = Queue() + out = "" + def find_line(): + try: + while True: + l = io.readline() + out += l + if re.search(pattern, l): + found.put(True) + break + except Exception, e: + found.put(False) + t = Thread(target = find_line) + t.daemon = True + t.start() try: - while True: - l = io.readline() - if re.search(pattern, l): - found.set() - break - except Exception, e: pass - t = Thread(target = find_line) - t.daemon = True - t.start() - if not found.wait(timeout): - raise Exception("Timed out waiting for '%s' in output" % pattern) + found.get(True, timeout) + except: + raise Exception("""Timed out waiting for '%s' in output +vvvvvvvvvvvvvvvv +%s +^^^^^^^^^^^^^^^^ +""" % (pattern, out)) + finally: print >>sys.stderr, "FIXME wait_line done" @staticmethod def pick_addr(): @@ -105,9 +121,9 @@ class ExampleTest(unittest.TestCase): raise Exception("Error running %s: %s", p.args, e) if p.returncode: raise Exception("""%s exit code %s - vvvvvvvvvvvvvvvv - %s - ^^^^^^^^^^^^^^^^ +vvvvvvvvvvvvvvvv +%s +^^^^^^^^^^^^^^^^ """ % (p.args, p.returncode, out)) if platform.system() == "Windows": # Just \n please @@ -134,13 +150,18 @@ class BrokerExampleTest(ExampleTest): @classmethod def setUpClass(cls): - if not getattr(cls, "broker", None): - cls.addr = cls.pick_addr() + "/examples" - cls.broker = Popen([cls.broker_exe, "-a", cls.addr], stdout=PIPE, stderr=sys.stderr) - cls.wait_line(cls.broker.stdout, "listening") + print >>sys.stderr, "FIXME setupclass", cls + try: + if not getattr(cls, "broker", None): + cls.addr = cls.pick_addr() + "/examples" + cls.broker = Popen([cls.broker_exe, "-a", cls.addr], stdout=PIPE, stderr=sys.stderr) + cls.wait_line(cls.broker.stdout, "listening") + finally: + print >>sys.stderr, "FIXME setupclass done", cls @classmethod def tearDownClass(cls): + print >>sys.stderr, "FIXME teardownclass", cls cls.broker.kill() cls.broker = None --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
