Fix log fomatter according to boost version upgrade 82/125882/1
authorsangwan.kwon <sangwan.kwon@samsung.com>
Wed, 19 Apr 2017 05:47:18 +0000 (14:47 +0900)
committersangwan.kwon <sangwan.kwon@samsung.com>
Wed, 19 Apr 2017 07:55:18 +0000 (16:55 +0900)
Change-Id: I78bc7a5438884b34c916d7651d34b1aa65bf5e61
Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
CMakeLists.txt
packaging/libcryptsvc.spec
test/colour_log_formatter.cc
test/colour_log_formatter.h

index 9805779..e409988 100644 (file)
@@ -5,7 +5,10 @@ INCLUDE(FindPkgConfig)
 
 STRING(REGEX MATCH "([^.]*)" SO_VERSION "${VERSION}")
 
-SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -std=c++0x")
+# _GLIBCXX_USE_CXX11_ABI is temporary off
+# When boost and package compiled with same gcc version,
+# it can be deleted.
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -std=c++0x -D_GLIBCXX_USE_CXX11_ABI=0")
 
 SET(CMAKE_C_FLAGS_PROFILING   "-g -O0 -pg -Wp,-U_FORITY_SOURCE")
 SET(CMAKE_CXX_FLAGS_PROFILING "-g -O0 -pg -Wp,-U_FORITY_SOURCE ${EXTRA_CXXFLAGS}")
index a7d11b7..c467259 100644 (file)
@@ -26,7 +26,7 @@ Crypto Service Library (Development).
 %package test
 Summary:    Testing for Crypto Service
 Group:      Security/Testing
-BuildRequires: boost-devel
+BuildRequires: boost-devel >= 1.62.0
 Requires:   boost-test
 Requires:   %{name} = %{version}-%{release}
 
index 50857a7..c7854d2 100644 (file)
 #include <iostream>
 #include <string>
 
-#include <boost/test/unit_test_suite_impl.hpp>
+#include <boost/test/tree/test_unit.hpp>
+
 #include <boost/test/framework.hpp>
+#include <boost/test/execution_monitor.hpp>
+#include <boost/test/unit_test_parameters.hpp>
+
 #include <boost/test/utils/basic_cstring/io.hpp>
 #include <boost/test/utils/lazy_ostream.hpp>
 #include <boost/version.hpp>
 
+#include <boost/test/utils/setcolor.hpp>
+
 using namespace boost::unit_test;
 
 namespace cryptsvc {
@@ -38,7 +44,7 @@ const char* COLOR_END = "\033[m";
 const_string
 test_phase_identifier()
 {
-    return framework::is_initialized()
+    return framework::test_in_progress()
             ? const_string( framework::current_test_case().p_name.get() )
             : BOOST_TEST_L( "Test setup" );
 }
@@ -48,11 +54,6 @@ get_basename(const const_string &file_name) {
     return basename(file_name.begin());
 }
 
-std::string
-get_basename(const std::string &file_name) {
-    return basename(file_name.c_str());
-}
-
 } // local namespace
 
 //____________________________________________________________________________//
@@ -95,7 +96,7 @@ colour_log_formatter::test_unit_start(
         std::ostream& output,
         test_unit const& tu )
 {
-    if (tu.p_type_name->find(const_string("suite")) == 0) {
+    if (tu.p_type_name.find(const_string("suite")) == 0) {
         output << "Starting test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
     } else {
         output << "Running test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
@@ -110,7 +111,7 @@ colour_log_formatter::test_unit_finish(
         test_unit const& tu,
         unsigned long elapsed )
 {
-    if (tu.p_type_name->find(const_string("suite")) == 0) {
+    if (tu.p_type_name.find(const_string("suite")) == 0) {
         output << "Finished test " << tu.p_type_name << " \"" << tu.p_name << "\""<< std::endl;
         return;
     }
@@ -150,33 +151,37 @@ colour_log_formatter::test_unit_skipped(
 //____________________________________________________________________________//
 
 void
-colour_log_formatter::log_exception(
+colour_log_formatter::log_exception_start(
         std::ostream& output,
-        log_checkpoint_data const& checkpoint_data,
-        boost::execution_exception const& ex )
+        boost::unit_test::log_checkpoint_data const& checkpoint_data,
+        boost::execution_exception const& ex)
 {
     boost::execution_exception::location const& loc = ex.where();
     output << '\t' << COLOR_BOLD_YELLOW << get_basename(loc.m_file_name)
-            << '(' << loc.m_line_num << "), ";
+           << '(' << loc.m_line_num << "), ";
 
     output << "fatal error in \""
-            << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": ";
+           << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function) << "\": ";
 
     output << COLOR_END << ex.what();
 
-    if( !checkpoint_data.m_file_name.is_empty() ) {
+    if(!checkpoint_data.m_file_name.is_empty()) {
         output << '\n';
         output << "\tlast checkpoint : " << get_basename(checkpoint_data.m_file_name)
-                << '(' << checkpoint_data.m_line_num << ")";
-        if( !checkpoint_data.m_message.empty() )
+               << '(' << checkpoint_data.m_line_num << ")";
+        if(!checkpoint_data.m_message.empty())
             output << ": " << checkpoint_data.m_message;
     }
 
-    output << std::endl;
     m_isTestCaseFailed = true;
 }
 
-//____________________________________________________________________________//
+void
+colour_log_formatter::log_exception_finish(std::ostream& output)
+{
+    output << std::endl;
+}
+
 
 void
 colour_log_formatter::log_entry_start(
@@ -242,6 +247,28 @@ colour_log_formatter::log_entry_finish(
 
 //____________________________________________________________________________//
 
+void
+colour_log_formatter::entry_context_start(
+        std::ostream& output,
+        boost::unit_test::log_level l)
+{
+    output << (l == log_successful_tests ? "\nAssertion" : "\nFailure") << " occurred in a following context:";
+}
+
+void
+colour_log_formatter::log_entry_context(
+        std::ostream& output,
+        boost::unit_test::const_string value)
+{
+    output << "\n    " << value;
+}
+
+void
+colour_log_formatter::entry_context_finish(std::ostream& output)
+{
+    output.flush();
+}
+
 //____________________________________________________________________________//
 
 } // namespace cryptsvc
index a01bf8e..193bb94 100644 (file)
@@ -37,10 +37,12 @@ public:
                 std::ostream&,
                 boost::unit_test::test_unit const& tu );
 
-    void    log_exception(
+    void    log_exception_start(
                 std::ostream&,
                 boost::unit_test::log_checkpoint_data const&,
-                boost::execution_exception const& ex );
+                boost::execution_exception const& ex);
+    void    log_exception_finish(
+                std::ostream&);
 
     void    log_entry_start(
                 std::ostream&,
@@ -53,6 +55,15 @@ public:
                 std::ostream&,
                 boost::unit_test::lazy_ostream const& value );
     void    log_entry_finish( std::ostream& );
+
+    void    entry_context_start(
+                std::ostream&,
+                boost::unit_test::log_level l);
+    void    log_entry_context(
+                std::ostream&,
+                boost::unit_test::const_string value);
+    void    entry_context_finish(std::ostream&);
+
 private:
     bool m_isTestCaseFailed;
 };