summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsangwan.kwon <sangwan.kwon@samsung.com>2017-05-11 15:51:30 +0900
committersangwan.kwon <sangwan.kwon@samsung.com>2017-05-15 13:08:52 +0900
commit7c64fdbb179004f85ecf0ae31da4b81fa215504c (patch)
tree2e88610982f30b7a10ff59a67be75ba234075c81
parent1708350cf7b62d346fa3b12b10bab5e11cb41d7d (diff)
downloadlibcryptsvc-7c64fdbb179004f85ecf0ae31da4b81fa215504c.tar.gz
libcryptsvc-7c64fdbb179004f85ecf0ae31da4b81fa215504c.tar.bz2
libcryptsvc-7c64fdbb179004f85ecf0ae31da4b81fa215504c.zip
Support previous boost version on TC
* This could be revert when boost-version is completely upgraded. Change-Id: I641d2db94b9e4aa9e712ba3a9ea501059990f883 Signed-off-by: sangwan.kwon <sangwan.kwon@samsung.com>
-rw-r--r--CMakeLists.txt5
-rw-r--r--packaging/libcryptsvc.spec2
-rw-r--r--test/colour_log_formatter.cc87
-rw-r--r--test/colour_log_formatter.h3
4 files changed, 77 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e409988..9805779 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,10 +5,7 @@ INCLUDE(FindPkgConfig)
STRING(REGEX MATCH "([^.]*)" SO_VERSION "${VERSION}")
-# _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(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -std=c++0x")
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}")
diff --git a/packaging/libcryptsvc.spec b/packaging/libcryptsvc.spec
index c467259..a7d11b7 100644
--- a/packaging/libcryptsvc.spec
+++ b/packaging/libcryptsvc.spec
@@ -26,7 +26,7 @@ Crypto Service Library (Development).
%package test
Summary: Testing for Crypto Service
Group: Security/Testing
-BuildRequires: boost-devel >= 1.62.0
+BuildRequires: boost-devel
Requires: boost-test
Requires: %{name} = %{version}-%{release}
diff --git a/test/colour_log_formatter.cc b/test/colour_log_formatter.cc
index c7854d2..71a66b4 100644
--- a/test/colour_log_formatter.cc
+++ b/test/colour_log_formatter.cc
@@ -17,18 +17,17 @@
#include <iostream>
#include <string>
+#include <boost/test/impl/execution_monitor.ipp>
+#if BOOST_VERSION >= 105900
#include <boost/test/tree/test_unit.hpp>
-
+#else
+#include <boost/test/unit_test_suite_impl.hpp>
+#endif
#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 {
@@ -42,11 +41,29 @@ const char* COLOR_BOLD_YELLOW = "\033[1;33m";
const char* COLOR_END = "\033[m";
const_string
+test_unit_type_name(const test_unit &tu)
+{
+#if BOOST_VERSION >= 105900
+ return const_string(tu.p_type_name);
+#else
+ return tu.p_type_name.get();
+#endif
+}
+
+const_string
+test_unit_name(const test_unit &tu)
+{
+#if BOOST_VERSION >= 105900
+ return const_string(tu.p_name);
+#else
+ return tu.p_name.get();
+#endif
+}
+
+const_string
test_phase_identifier()
{
- return framework::test_in_progress()
- ? const_string( framework::current_test_case().p_name.get() )
- : BOOST_TEST_L( "Test setup" );
+ return test_unit_name(framework::current_test_case());
}
const_string
@@ -54,6 +71,12 @@ get_basename(const const_string &file_name) {
return basename(file_name.begin());
}
+bool
+test_unit_type_name_contains(const test_unit &tu, const std::string &substr)
+{
+ return test_unit_type_name(tu).find(const_string(substr)) == 0;
+}
+
} // local namespace
//____________________________________________________________________________//
@@ -96,11 +119,13 @@ colour_log_formatter::test_unit_start(
std::ostream& output,
test_unit const& tu )
{
- if (tu.p_type_name.find(const_string("suite")) == 0) {
- output << "Starting test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
+ if (test_unit_type_name_contains(tu, "suite")) {
+ output << "Starting test ";
} else {
- output << "Running test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
+ output << "Running test ";
}
+ output << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" <<
+ std::endl;
}
//____________________________________________________________________________//
@@ -111,10 +136,12 @@ colour_log_formatter::test_unit_finish(
test_unit const& tu,
unsigned long elapsed )
{
- if (tu.p_type_name.find(const_string("suite")) == 0) {
- output << "Finished test " << tu.p_type_name << " \"" << tu.p_name << "\""<< std::endl;
+ if (test_unit_type_name_contains(tu, "suite")) {
+ output << "Finished test " << test_unit_type_name(tu) << " \"" << test_unit_name(tu) << "\"" <<
+ std::endl;
return;
}
+
std::string color = COLOR_GREEN;
std::string status = "OK";
if (m_isTestCaseFailed) {
@@ -145,12 +172,42 @@ colour_log_formatter::test_unit_skipped(
std::ostream& output,
test_unit const& tu )
{
- output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << "is skipped" << std::endl;
+ output << "Test " << test_unit_type_name(tu) << " \"" << test_unit_name(tu)
+ << "\"" << "is skipped" << std::endl;
}
//____________________________________________________________________________//
void
+colour_log_formatter::log_exception(
+ std::ostream &output,
+ 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 << "), ";
+
+ output << "fatal error in \""
+ << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function) <<
+ "\": ";
+
+ output << COLOR_END << ex.what();
+
+ 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())
+ output << ": " << checkpoint_data.m_message;
+ }
+
+ output << std::endl;
+ m_isTestCaseFailed = true;
+}
+
+void
colour_log_formatter::log_exception_start(
std::ostream& output,
boost::unit_test::log_checkpoint_data const& checkpoint_data,
diff --git a/test/colour_log_formatter.h b/test/colour_log_formatter.h
index 224898d..734012a 100644
--- a/test/colour_log_formatter.h
+++ b/test/colour_log_formatter.h
@@ -37,6 +37,9 @@ public:
std::ostream &,
boost::unit_test::test_unit const &tu);
+ void log_exception(std::ostream &,
+ boost::unit_test::log_checkpoint_data const &,
+ boost::execution_exception const &ex);
void log_exception_start(
std::ostream &,
boost::unit_test::log_checkpoint_data const &,