You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2016/01/27 00:45:08 UTC

[1/8] qpid-proton git commit: PROTON-1062: c++: Fix error message code in io.cpp.

Repository: qpid-proton
Updated Branches:
  refs/heads/fix [created] 6cee4cac3


PROTON-1062: c++: Fix error message code in io.cpp.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/68f7d3cd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/68f7d3cd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/68f7d3cd

Branch: refs/heads/fix
Commit: 68f7d3cd51512a6fa33c67456337296a9c0f4657
Parents: 5ec9013
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 13:19:17 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 13:48:16 2016 -0500

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/posix/io.cpp | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/68f7d3cd/proton-c/bindings/cpp/src/posix/io.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/posix/io.cpp b/proton-c/bindings/cpp/src/posix/io.cpp
index 2fef3ea..6532995 100644
--- a/proton-c/bindings/cpp/src/posix/io.cpp
+++ b/proton-c/bindings/cpp/src/posix/io.cpp
@@ -34,22 +34,14 @@ namespace io {
 const descriptor INVALID_DESCRIPTOR = -1;
 
 std::string error_str() {
-#ifdef USE_STRERROR_R
-    char buf[256];
-    strerror_r(errno, buf, sizeof(buf));
-    return buf;
-#elifdef USE_STRERROR_S
-    char buf[256];
-    strerror_s(buf, sizeof(buf), errno);
-    return buf;
-#elifdef USE_OLD_STRERROR
-    char buf[256];
-    strncpy(buf, strerror(errno), sizeof(buf));
-    return buf;
+    char buf[512] = "Unknown error";
+#ifdef _GNU_SOURCE
+    // GNU strerror_r returns the message
+    return ::strerror_r(errno, buf, sizeof(buf));
 #else
-    std::ostringstream os;
-    os <<  "system error (" << errno << ")";
-    return os.str();
+    // POSIX strerror_r doesn't return the buffer
+    ::strerror_r(errno, buf, sizeof(buf));
+    return std::string(buf)
 #endif
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[4/8] qpid-proton git commit: WI: print tests 3

Posted by ac...@apache.org.
WI: print tests 3


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e494040d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e494040d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e494040d

Branch: refs/heads/fix
Commit: e494040d665a835a2e35da3ffcfa47b740811f00
Parents: 3682984
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 15:14:44 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 15:14:44 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/example_test.py | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e494040d/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index b3b9c72..d815bbc 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -28,6 +28,9 @@ import platform
 from os.path import dirname as dirname
 from threading import Thread, Event
 
+# FIXME aconway 2016-01-26:
+os.environ["PN_TRACE_FRM"] = "0"
+
 class ExampleTest(unittest.TestCase):
     """Base class for tests that run example programs and verify their output."""
 
@@ -36,12 +39,17 @@ class ExampleTest(unittest.TestCase):
         self.procs = []
 
     def tearDown(self):
-        print >>sys.stderr, "FIXME tearDown", self.id()
-        for p in self.procs:
-            try:
-                print >>sys.stderr, "FIXME kill", p.args
-                p.kill()
-            except: pass
+        try:
+            print >>sys.stderr, "FIXME tearDown", self.id()
+            for p in self.procs:
+                try:
+                    print >>sys.stderr, "FIXME kill", id(p), p.args
+                    p.kill()
+                except Exception, e:
+                    print >>sys.stderr, "FIXME kill ex ", id(p), e
+                    pass
+        finally:
+            print >>sys.stderr, "FIXME tearDown done"
 
     def cmdline(self, *args):
         """Adjust executable name args[0] for windows and/or valgrind"""
@@ -80,9 +88,9 @@ class ExampleTest(unittest.TestCase):
         return "127.0.0.1:%s" % p
 
     def background(self, *args):
-        """Run executable in the backround, return the popen"""
-        print >>sys.stderr, "FIXME backround", args
+        """Run executable in the background, return the popen"""
         p = Popen(self.cmdline(*args), stdout=PIPE, stderr=sys.stderr)
+        print >>sys.stderr, "FIXME backround", args, id(p)
         p.args = args               # Save arguments for debugging output
         self.procs.append(p)
         return p
@@ -91,24 +99,32 @@ class ExampleTest(unittest.TestCase):
         """Wait for executable to exit and verify status, return the output"""
         print >>sys.stderr, "FIXME verify", p.args
         try:
-            out, err = p.communicate()
-        except Exception as e:
-            raise Exception("Error running %s: %s", p.args, e)
-        if p.returncode:
-            raise Exception("""%s exit code %s
-    vvvvvvvvvvvvvvvv
-    %s
-    ^^^^^^^^^^^^^^^^
-    """ % (p.args, p.returncode, out))
-        if platform.system() == "Windows":
-            # Just \n please
-            if out:
-                out = out.translate(None, '\r')
-        return out
+            try:
+                out, err = p.communicate()
+            except Exception as e:
+                raise Exception("Error running %s: %s", p.args, e)
+            if p.returncode:
+                raise Exception("""%s exit code %s
+        vvvvvvvvvvvvvvvv
+        %s
+        ^^^^^^^^^^^^^^^^
+        """ % (p.args, p.returncode, out))
+            if platform.system() == "Windows":
+                # Just \n please
+                if out:
+                    out = out.translate(None, '\r')
+            return out
+        except Exception, e:
+            print >>sys.stderr, "FIXME verify: ", e
+        finally:
+            print >>sys.stderr, "FIXME verify done"
 
     def execute(self, *args):
         """Run a program, verify its exit status and return its output"""
-        return self.verify(self.background(*args))
+        p = self.background(*args)
+        out = self.verify(p)
+        self.procs.remove(p)
+        return out
 
 class BrokerExampleTest(ExampleTest):
     """


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[7/8] qpid-proton git commit: Timeout on verify.

Posted by ac...@apache.org.
Timeout on verify.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9268d46b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9268d46b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9268d46b

Branch: refs/heads/fix
Commit: 9268d46bfe0ee0f5a4d9679b50c7d12e5229cc46
Parents: 91c8432
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 16:42:09 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 16:42:09 2016 -0500

----------------------------------------------------------------------
 examples/cpp/CMakeLists.txt         | 72 ++++++++++++++++----------------
 examples/cpp/engine/example_test.py |  8 +++-
 2 files changed, 42 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9268d46b/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 14d5748..3297302 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -19,45 +19,45 @@
 
 find_package(ProtonCpp REQUIRED)
 
-include_directories(${ProtonCpp_INCLUDE_DIRS})
+# include_directories(${ProtonCpp_INCLUDE_DIRS})
 
-set(examples
-  broker
-  helloworld
-  helloworld_direct
-  simple_recv
-  simple_send
-  direct_recv
-  direct_send
-  client
-  server
-  server_direct
-  recurring_timer
-  connection_options
-  queue_browser
-  selected_recv
-  ssl
-  ssl_client_cert
-  encode_decode)
+# set(examples
+#   broker
+#   helloworld
+#   helloworld_direct
+#   simple_recv
+#   simple_send
+#   direct_recv
+#   direct_send
+#   client
+#   server
+#   server_direct
+#   recurring_timer
+#   connection_options
+#   queue_browser
+#   selected_recv
+#   ssl
+#   ssl_client_cert
+#   encode_decode)
 
-foreach(example ${examples})
-  add_executable(${example} ${example}.cpp)
-  target_link_libraries(${example} ${ProtonCpp_LIBRARIES})
-  set_source_files_properties(${example}.cpp PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS}")
-endforeach()
+# foreach(example ${examples})
+#   add_executable(${example} ${example}.cpp)
+#   target_link_libraries(${example} ${ProtonCpp_LIBRARIES})
+#   set_source_files_properties(${example}.cpp PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS}")
+# endforeach()
 
-set(env_py "${CMAKE_SOURCE_DIR}/proton-c/env.py")
-set(test_bin_dir "$<TARGET_FILE_DIR:broker>")
-if (WIN32)
-  # Ignore existing path (usualy containting spaces, escape chars).
-  # Choose just enough path for Windows, ';' separated.
-  set(test_path "${test_bin_dir}" "$<TARGET_FILE_DIR:qpid-proton>" "$<TARGET_FILE_DIR:qpid-proton-cpp>")
-else(WIN32)
-  # ':' separated path with test_bin_dir first.
-  set(test_path "${test_bin_dir}:$ENV{PATH}")
-endif(WIN32)
+# set(env_py "${CMAKE_SOURCE_DIR}/proton-c/env.py")
+# set(test_bin_dir "$<TARGET_FILE_DIR:broker>")
+# if (WIN32)
+#   # Ignore existing path (usualy containting spaces, escape chars).
+#   # Choose just enough path for Windows, ';' separated.
+#   set(test_path "${test_bin_dir}" "$<TARGET_FILE_DIR:qpid-proton>" "$<TARGET_FILE_DIR:qpid-proton-cpp>")
+# else(WIN32)
+#   # ':' separated path with test_bin_dir first.
+#   set(test_path "${test_bin_dir}:$ENV{PATH}")
+# endif(WIN32)
 
-add_test(NAME cpp_example_test
-  COMMAND ${PYTHON_EXECUTABLE} ${env_py} -- "PATH=${test_path}" ${VALGRIND_ENV} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v)
+# add_test(NAME cpp_example_test
+#   COMMAND ${PYTHON_EXECUTABLE} ${env_py} -- "PATH=${test_path}" ${VALGRIND_ENV} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v)
 
 add_subdirectory(engine)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9268d46b/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index 6d438bc..52bc37e 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -26,7 +26,7 @@ from subprocess import Popen, PIPE, STDOUT
 from copy import copy
 import platform
 from os.path import dirname as dirname
-from threading import Thread
+from threading import Thread, Timer
 try:
     from Queue import Queue, Empty
 except:
@@ -111,14 +111,18 @@ vvvvvvvvvvvvvvvv
         self.procs.append(p)
         return p
 
-    def verify(self, p):
+    def verify(self, p, timeout=5):
         """Wait for executable to exit and verify status, return the output"""
         print >>sys.stderr, "FIXME verify", p.args
         try:
+            timer = Timer(timeout, p.kill)
             try:
+                timer.start()
                 out, err = p.communicate()
             except Exception as e:
                 raise Exception("Error running %s: %s", p.args, e)
+            finally:
+                timer.cancel()
             if p.returncode:
                 raise Exception("""%s exit code %s
 vvvvvvvvvvvvvvvv


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/8] qpid-proton git commit: WIP: print test progress, 2

Posted by ac...@apache.org.
WIP: print test progress, 2


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3682984c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3682984c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3682984c

Branch: refs/heads/fix
Commit: 3682984cd638cb7dddf2351ae84f18074821728f
Parents: 9da5b56
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 14:15:41 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 14:25:32 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/example_test.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3682984c/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index ef42455..b3b9c72 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -32,11 +32,15 @@ class ExampleTest(unittest.TestCase):
     """Base class for tests that run example programs and verify their output."""
 
     def setUp(self):
+        print >>sys.stderr, "FIXME setUp", self.id()
         self.procs = []
 
     def tearDown(self):
+        print >>sys.stderr, "FIXME tearDown", self.id()
         for p in self.procs:
-            try: p.kill()
+            try:
+                print >>sys.stderr, "FIXME kill", p.args
+                p.kill()
             except: pass
 
     def cmdline(self, *args):
@@ -77,6 +81,7 @@ class ExampleTest(unittest.TestCase):
 
     def background(self, *args):
         """Run executable in the backround, return the popen"""
+        print >>sys.stderr, "FIXME backround", args
         p = Popen(self.cmdline(*args), stdout=PIPE, stderr=sys.stderr)
         p.args = args               # Save arguments for debugging output
         self.procs.append(p)
@@ -84,6 +89,7 @@ class ExampleTest(unittest.TestCase):
 
     def verify(self, p):
         """Wait for executable to exit and verify status, return the output"""
+        print >>sys.stderr, "FIXME verify", p.args
         try:
             out, err = p.communicate()
         except Exception as e:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[5/8] qpid-proton git commit: WIP: example test with frame trace

Posted by ac...@apache.org.
WIP: example test with frame trace


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f7c795b6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f7c795b6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f7c795b6

Branch: refs/heads/fix
Commit: f7c795b6cdf36acf7d6c528b477d728bb9386327
Parents: e494040
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 15:59:31 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 15:59:31 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/example_test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f7c795b6/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index d815bbc..7a0a523 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -29,7 +29,7 @@ from os.path import dirname as dirname
 from threading import Thread, Event
 
 # FIXME aconway 2016-01-26:
-os.environ["PN_TRACE_FRM"] = "0"
+os.environ["PN_TRACE_FRM"] = "1"
 
 class ExampleTest(unittest.TestCase):
     """Base class for tests that run example programs and verify their output."""
@@ -90,7 +90,7 @@ class ExampleTest(unittest.TestCase):
     def background(self, *args):
         """Run executable in the background, return the popen"""
         p = Popen(self.cmdline(*args), stdout=PIPE, stderr=sys.stderr)
-        print >>sys.stderr, "FIXME backround", args, id(p)
+        print >>sys.stderr, "FIXME background", args, id(p)
         p.args = args               # Save arguments for debugging output
         self.procs.append(p)
         return p


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[8/8] qpid-proton git commit: printing port/addr for broker

Posted by ac...@apache.org.
printing port/addr for broker


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/6cee4cac
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/6cee4cac
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/6cee4cac

Branch: refs/heads/fix
Commit: 6cee4cac3ca52c953ff7ed1460e3cca5799c6411
Parents: 9268d46
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 16:56:07 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 16:56:07 2016 -0500

----------------------------------------------------------------------
 examples/cpp/CMakeLists.txt         | 70 ++++++++++++++++----------------
 examples/cpp/engine/example_test.py |  2 +
 2 files changed, 37 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6cee4cac/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 3297302..65d814a 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -21,43 +21,43 @@ find_package(ProtonCpp REQUIRED)
 
 # include_directories(${ProtonCpp_INCLUDE_DIRS})
 
-# set(examples
-#   broker
-#   helloworld
-#   helloworld_direct
-#   simple_recv
-#   simple_send
-#   direct_recv
-#   direct_send
-#   client
-#   server
-#   server_direct
-#   recurring_timer
-#   connection_options
-#   queue_browser
-#   selected_recv
-#   ssl
-#   ssl_client_cert
-#   encode_decode)
+set(examples
+  broker
+  helloworld
+  helloworld_direct
+  simple_recv
+  simple_send
+  direct_recv
+  direct_send
+  client
+  server
+  server_direct
+  recurring_timer
+  connection_options
+  queue_browser
+  selected_recv
+  ssl
+  ssl_client_cert
+  encode_decode)
 
-# foreach(example ${examples})
-#   add_executable(${example} ${example}.cpp)
-#   target_link_libraries(${example} ${ProtonCpp_LIBRARIES})
-#   set_source_files_properties(${example}.cpp PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS}")
-# endforeach()
+foreach(example ${examples})
+  add_executable(${example} ${example}.cpp)
+  target_link_libraries(${example} ${ProtonCpp_LIBRARIES})
+  set_source_files_properties(${example}.cpp PROPERTIES COMPILE_FLAGS "${CXX_WARNING_FLAGS}")
+endforeach()
 
-# set(env_py "${CMAKE_SOURCE_DIR}/proton-c/env.py")
-# set(test_bin_dir "$<TARGET_FILE_DIR:broker>")
-# if (WIN32)
-#   # Ignore existing path (usualy containting spaces, escape chars).
-#   # Choose just enough path for Windows, ';' separated.
-#   set(test_path "${test_bin_dir}" "$<TARGET_FILE_DIR:qpid-proton>" "$<TARGET_FILE_DIR:qpid-proton-cpp>")
-# else(WIN32)
-#   # ':' separated path with test_bin_dir first.
-#   set(test_path "${test_bin_dir}:$ENV{PATH}")
-# endif(WIN32)
+set(env_py "${CMAKE_SOURCE_DIR}/proton-c/env.py")
+set(test_bin_dir "$<TARGET_FILE_DIR:broker>")
+if (WIN32)
+  # Ignore existing path (usualy containting spaces, escape chars).
+  # Choose just enough path for Windows, ';' separated.
+  set(test_path "${test_bin_dir}" "$<TARGET_FILE_DIR:qpid-proton>" "$<TARGET_FILE_DIR:qpid-proton-cpp>")
+else(WIN32)
+  # ':' separated path with test_bin_dir first.
+  set(test_path "${test_bin_dir}:$ENV{PATH}")
+endif(WIN32)
 
-# add_test(NAME cpp_example_test
-#   COMMAND ${PYTHON_EXECUTABLE} ${env_py} -- "PATH=${test_path}" ${VALGRIND_ENV} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v)
+add_test(NAME cpp_example_test
+  COMMAND ${PYTHON_EXECUTABLE} ${env_py} -- "PATH=${test_path}" ${VALGRIND_ENV} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v)
 
 add_subdirectory(engine)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/6cee4cac/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index 52bc37e..e71c2ec 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -101,6 +101,7 @@ vvvvvvvvvvvvvvvv
         """Pick a new host:port address."""
         # TODO aconway 2015-07-14: need a safer way to pick ports.
         p =  randrange(10000, 20000)
+        print >>sys.stderr, "FIXME port", p
         return "127.0.0.1:%s" % p
 
     def background(self, *args):
@@ -158,6 +159,7 @@ class BrokerExampleTest(ExampleTest):
         try:
             if not getattr(cls, "broker", None):
                 cls.addr = cls.pick_addr() + "/examples"
+                print >>sys.stderr, "FIXME broker addr", cls.addr
                 cls.broker = Popen([cls.broker_exe, "-a", cls.addr], stdout=PIPE, stderr=sys.stderr)
                 cls.wait_line(cls.broker.stdout, "listening")
         finally:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[6/8] qpid-proton git commit: frame trace plus more logging

Posted by ac...@apache.org.
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 <ac...@redhat.com>
Authored: Tue Jan 26 16:17:30 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
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: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/8] qpid-proton git commit: PROTON-1062: c++: Simplified example test runner for connection_engine tests.

Posted by ac...@apache.org.
PROTON-1062: c++: Simplified example test runner for connection_engine tests.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9da5b56a
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9da5b56a
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9da5b56a

Branch: refs/heads/fix
Commit: 9da5b56a0551d5a669a48e378b97f73aa1bdb541
Parents: 68f7d3c
Author: Alan Conway <ac...@redhat.com>
Authored: Tue Jan 26 13:01:01 2016 -0500
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jan 26 14:13:41 2016 -0500

----------------------------------------------------------------------
 examples/cpp/engine/example_test.py   | 229 ++++++++++++++---------------
 proton-c/bindings/cpp/src/handler.cpp |   2 +-
 2 files changed, 114 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9da5b56a/examples/cpp/engine/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/engine/example_test.py b/examples/cpp/engine/example_test.py
index a4c4c17..ef42455 100644
--- a/examples/cpp/engine/example_test.py
+++ b/examples/cpp/engine/example_test.py
@@ -20,141 +20,143 @@
 # This is a test script to run the examples and verify that they behave as expected.
 
 import unittest
-import os, sys, socket, time
+import os, sys, socket, time, re
 from  random import randrange
 from subprocess import Popen, PIPE, STDOUT
 from copy import copy
 import platform
 from os.path import dirname as dirname
+from threading import Thread, Event
 
-def cmdline(*args):
-    """Adjust executable name args[0] for windows and/or valgrind"""
-    args = list(args)
-    if platform.system() == "Windows":
-        args[0] += ".exe"
-    if "VALGRIND" in os.environ and os.environ["VALGRIND"]:
-        args = [os.environ["VALGRIND"], "--error-exitcode=42", "--quiet",
-                "--leak-check=full"] + args
-    return args
-
-def background(*args):
-    """Run executable in the backround, return the popen"""
-    p = Popen(cmdline(*args), stdout=PIPE, stderr=sys.stderr)
-    p.args = args               # Save arguments for debugging output
-    return p
-
-def verify(p):
-    """Wait for executable to exit and verify status."""
-    try:
-        out, err = p.communicate()
-    except Exception as e:
-        raise Exception("Error running %s: %s", p.args, e)
-    if p.returncode:
-        raise Exception("""%s exit code %s
-vvvvvvvvvvvvvvvv
-%s
-^^^^^^^^^^^^^^^^
-""" % (p.args, p.returncode, out))
-    if platform.system() == "Windows":
-        # Just \n please
-        if out:
-            out = out.translate(None, '\r')
-    return out
-
-def execute(*args):
-    return verify(background(*args))
-
-NULL = open(os.devnull, 'w')
-
-def wait_addr(addr, timeout=10):
-    """Wait up to timeout for something to listen on port"""
-    deadline = time.time() + timeout
-    while time.time() < deadline:
+class ExampleTest(unittest.TestCase):
+    """Base class for tests that run example programs and verify their output."""
+
+    def setUp(self):
+        self.procs = []
+
+    def tearDown(self):
+        for p in self.procs:
+            try: p.kill()
+            except: pass
+
+    def cmdline(self, *args):
+        """Adjust executable name args[0] for windows and/or valgrind"""
+        args = list(args)
+        if platform.system() == "Windows":
+            args[0] += ".exe"
+        if "VALGRIND" in os.environ and os.environ["VALGRIND"]:
+            args = [os.environ["VALGRIND"], "--error-exitcode=42", "--quiet",
+                    "--leak-check=full"] + args
+        return args
+
+    NULL = open(os.devnull, 'w')
+
+    @staticmethod
+    def wait_line(io, pattern, timeout=5):
+        found = Event()
+        def find_line():
+            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)
+
+    @staticmethod
+    def pick_addr():
+        """Pick a new host:port address."""
+        # TODO aconway 2015-07-14: need a safer way to pick ports.
+        p =  randrange(10000, 20000)
+        return "127.0.0.1:%s" % p
+
+    def background(self, *args):
+        """Run executable in the backround, return the popen"""
+        p = Popen(self.cmdline(*args), stdout=PIPE, stderr=sys.stderr)
+        p.args = args               # Save arguments for debugging output
+        self.procs.append(p)
+        return p
+
+    def verify(self, p):
+        """Wait for executable to exit and verify status, return the output"""
         try:
-            c = socket.create_connection(addr.split(":"), deadline - time.time())
-            c.close()
-            return
-        except socket.error as e:
-            time.sleep(0.01)
-    raise Exception("Timed out waiting for %s", addr)
-
-def pick_addr():
-    """Pick a new host:port address."""
-    # TODO aconway 2015-07-14: need a safer way to pick ports.
-    p =  randrange(10000, 20000)
-    return "127.0.0.1:%s" % p
-
-def ssl_certs_dir():
-    """Absolute path to the test SSL certificates"""
-    pn_root = dirname(dirname(dirname(sys.argv[0])))
-    return os.path.join(pn_root, "examples/cpp/ssl_certs")
-
-class Broker(object):
-    """Run the test broker"""
+            out, err = p.communicate()
+        except Exception as e:
+            raise Exception("Error running %s: %s", p.args, e)
+        if p.returncode:
+            raise Exception("""%s exit code %s
+    vvvvvvvvvvvvvvvv
+    %s
+    ^^^^^^^^^^^^^^^^
+    """ % (p.args, p.returncode, out))
+        if platform.system() == "Windows":
+            # Just \n please
+            if out:
+                out = out.translate(None, '\r')
+        return out
+
+    def execute(self, *args):
+        """Run a program, verify its exit status and return its output"""
+        return self.verify(self.background(*args))
+
+class BrokerExampleTest(ExampleTest):
+    """
+    ExampleTest that starts a broker in setUpClass and kills it in tearDownClass.
+    Derived classes should have a 'broker_exe' attribute with the executable.
+    """
 
     @classmethod
-    def get(cls):
-        if not hasattr(cls, "_broker"):
-            cls._broker = Broker()
-        return cls._broker
+    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")
 
     @classmethod
-    def stop(cls):
-        if cls.get() and cls._broker.process:
-            cls._broker.process.kill()
-            cls._broker = None
-
-    def __init__(self):
-        broker_exe = os.environ.get("TEST_BROKER") or "broker"
-        self.addr = pick_addr()
-        cmd = cmdline(broker_exe, "-a", self.addr)
-        try:
-            self.process = Popen(cmd, stdout=NULL, stderr=sys.stderr)
-            wait_addr(self.addr)
-            self.addr += "/examples"
-        except Exception as e:
-            raise Exception("Error running %s: %s", cmd, e)
+    def tearDownClass(cls):
+        cls.broker.kill()
+        cls.broker = None
 
-class ExampleTest(unittest.TestCase):
+
+class ConnectionEngineTest(BrokerExampleTest):
     """Run the examples, verify they behave as expected."""
 
-    @classmethod
-    def tearDownClass(self):
-        Broker.stop()
+    broker_exe = "broker"
 
     def test_helloworld(self):
-        b = Broker.get()
-        hw = execute("helloworld", b.addr)
+        hw = self.execute("helloworld", self.addr)
         self.assertEqual('Hello World!\n', hw)
 
     def test_simple_send_recv(self):
-        b = Broker.get()
-        send = execute("simple_send", "-a", b.addr)
+        send = self.execute("simple_send", "-a", self.addr)
         self.assertEqual("all messages confirmed\n", send)
-        recv = execute("simple_recv", "-a", b.addr)
-        recv_expect = "simple_recv listening on amqp://%s\n" % (b.addr)
+        recv = self.execute("simple_recv", "-a", self.addr)
+        recv_expect = "simple_recv listening on amqp://%s\n" % (self.addr)
         recv_expect += "".join(['{"sequence"=%s}\n' % (i+1) for i in range(100)])
         self.assertEqual(recv_expect, recv)
 
     def test_simple_send_direct_recv(self):
-        addr = pick_addr()
-        recv = background("direct_recv", "-a", addr)
-        while not "listening" in recv.stdout.readline():
-            pass
-        self.assertEqual("all messages confirmed\n", execute("simple_send", "-a", addr))
+        addr = self.pick_addr()
+        recv = self.background("direct_recv", "-a", addr)
+        self.wait_line(recv.stdout, "listening")
+        self.assertEqual("all messages confirmed\n", self.execute("simple_send", "-a", addr))
         recv_expect = "".join(['{"sequence"=%s}\n' % (i+1) for i in range(100)])
-        self.assertEqual(recv_expect, verify(recv))
+        self.assertEqual(recv_expect, self.verify(recv))
 
     def test_simple_recv_direct_send(self):
-        addr = pick_addr()
-        send = background("direct_send", "-a", addr)
-        while not "listening" in send.stdout.readline():
-            pass
+        addr = self.pick_addr()
+        send = self.background("direct_send", "-a", addr)
+        self.wait_line(send.stdout, "listening")
         recv_expect = "simple_recv listening on amqp://%s\n" % (addr)
         recv_expect += "".join(['{"sequence"=%s}\n' % (i+1) for i in range(100)])
-        self.assertEqual(recv_expect, execute("simple_recv", "-a", addr))
+        self.assertEqual(recv_expect, self.execute("simple_recv", "-a", addr))
         send_expect = "all messages confirmed\n"
-        self.assertEqual(send_expect, verify(send))
+        self.assertEqual(send_expect, self.verify(send))
 
     CLIENT_EXPECT="""Twas brillig, and the slithy toves => TWAS BRILLIG, AND THE SLITHY TOVES
 Did gire and gymble in the wabe. => DID GIRE AND GYMBLE IN THE WABE.
@@ -163,20 +165,15 @@ And the mome raths outgrabe. => AND THE MOME RATHS OUTGRABE.
 """
     def test_simple_recv_send(self):
         # Start receiver first, then run sender"""
-        b = Broker.get()
-        recv = background("simple_recv", "-a", b.addr)
-        self.assertEqual("all messages confirmed\n", execute("simple_send", "-a", b.addr))
-        recv_expect = "simple_recv listening on amqp://%s\n" % (b.addr)
+        recv = self.background("simple_recv", "-a", self.addr)
+        self.assertEqual("all messages confirmed\n", self.execute("simple_send", "-a", self.addr))
+        recv_expect = "simple_recv listening on amqp://%s\n" % (self.addr)
         recv_expect += "".join(['{"sequence"=%s}\n' % (i+1) for i in range(100)])
-        self.assertEqual(recv_expect, verify(recv))
+        self.assertEqual(recv_expect, self.verify(recv))
 
     def test_client_server(self):
-        b = Broker.get()
-        server = background("server", "-a", b.addr)
-        try:
-            self.assertEqual(execute("client", "-a", b.addr), self.CLIENT_EXPECT)
-        finally:
-            server.kill()
+        server = self.background("server", "-a", self.addr)
+        self.assertEqual(self.execute("client", "-a", self.addr), self.CLIENT_EXPECT)
 
 if __name__ == "__main__":
     unittest.main()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9da5b56a/proton-c/bindings/cpp/src/handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/handler.cpp b/proton-c/bindings/cpp/src/handler.cpp
index 34c19e6..9d8ca76 100644
--- a/proton-c/bindings/cpp/src/handler.cpp
+++ b/proton-c/bindings/cpp/src/handler.cpp
@@ -63,6 +63,6 @@ void handler::on_transaction_declare(event &e) { on_unhandled(e); }
 void handler::on_unhandled(event &) {}
 // XXXXX: FIXME - temporarily disabled exception to keep tests passing
 //void handler::on_unhandled_error(event &, const condition& c) { throw std::runtime_error(c.str()); }
-void handler::on_unhandled_error(event &, const condition& c) {}
+void handler::on_unhandled_error(event &, const condition&) {}
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org