Parcourir la source

[trac542] Update format of message

... and catch both isc::Exception and std::exception.
Stephen Morris il y a 14 ans
Parent
commit
d4a2c864bf

+ 3 - 0
src/lib/util/unittests/Makefile.am

@@ -8,4 +8,7 @@ libutil_unittests_la_SOURCES += run_all.h run_all.cc
 libutil_unittests_la_SOURCES += testdata.h testdata.cc
 libutil_unittests_la_SOURCES += textdata.h
 
+libutil_unittests_ls_LDADD  = $(top_builddir)/src/lib/util/io/libutil_io.la
+libutil_unittests_ls_LDADD += $(top_builddir)/src/lib/util/libutil.la
+
 CLEANFILES = *.gcno *.gcda

+ 12 - 3
src/lib/util/unittests/run_all.cc

@@ -18,6 +18,7 @@
 #include <iomanip>
 
 #include <gtest/gtest.h>
+#include <exceptions/exceptions.h>
 #include <util/unittests/run_all.h>
 
 namespace isc {
@@ -31,10 +32,18 @@ run_all() {
     if (getenv("B10TEST_CATCH_EXCEPTION")) {
         try {
             ret = RUN_ALL_TESTS();
+        } catch (const isc::Exception& ex) {
+             std::cerr << "*** isc::exception of class '" << typeid(ex).name()
+                          << "' was thrown:\n"
+                       << "    file: " << ex.getFile() << "\n"
+                       << "    line: " << ex.getLine() << "\n"
+                       << "    what: " << ex.what() << std::endl;
+            throw;
         } catch (const std::exception& ex) {
-            std::cerr << "***EXCEPTION: an exception of class '"
-                      << typeid(ex).name() << "' was thrown, what(): "
-                      << ex.what() << std::endl;
+             std::cerr << "*** std::exception of class '"
+                          << typeid(ex).name()
+                          << "' was thrown:\n"
+                       << "    what: " << ex.what() << std::endl;
             throw;
         }
     } else {

+ 4 - 0
src/lib/util/unittests/run_all.h

@@ -17,6 +17,10 @@
 #ifndef __RUN_ALL_H
 #define __RUN_ALL_H
 
+// Avoid need for user to include this header file.
+
+#include <gtest/gtest.h>
+
 namespace isc {
 namespace util {
 namespace unittests {