X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Ftest%2Ftest%2Fframework-ts%2Flog-formatter-test.cpp;h=9566cec88762fad190049cbf3db4818a252f72aa;hb=b32b81446b3b05102be0267e79203f59329c1d97;hp=4df0d387f691e2a667d4faa20ce9915ae6e29103;hpb=215dd7151453fae88e6f968c975b6ce309d42dcf;p=ceph.git diff --git a/ceph/src/boost/libs/test/test/framework-ts/log-formatter-test.cpp b/ceph/src/boost/libs/test/test/framework-ts/log-formatter-test.cpp index 4df0d387f..9566cec88 100644 --- a/ceph/src/boost/libs/test/test/framework-ts/log-formatter-test.cpp +++ b/ceph/src/boost/libs/test/test/framework-ts/log-formatter-test.cpp @@ -11,19 +11,20 @@ // Boost.Test #define BOOST_TEST_MAIN -#include +#include #include -#include #include #include #include #include typedef boost::onullstream onullstream_type; -#include // BOOST #include +// our special logger for tests +#include "logger-for-tests.hpp" + // STL #include #include @@ -56,13 +57,6 @@ void bad_foo() { BOOST_CHECK_MESSAGE( 1 == 2.3, "non sense" ); } -struct log_guard { - ~log_guard() - { - unit_test_log.set_stream( std::cout ); - } -}; - void very_bad_foo() { BOOST_TEST_CONTEXT("some context") { BOOST_FAIL( "very_bad_foo is fatal" ); @@ -83,11 +77,14 @@ void very_bad_exception() { //____________________________________________________________________________// -void check( output_test_stream& output, output_format log_format, test_unit_id id ) +void check( output_test_stream& output, + output_format log_format, + test_unit_id id, + log_level ll = log_successful_tests ) { boost::unit_test::unit_test_log.set_format(log_format); boost::unit_test::unit_test_log.set_stream(output); - boost::unit_test::unit_test_log.set_threshold_level(log_successful_tests); + boost::unit_test::unit_test_log.set_threshold_level(ll); output << "* " << log_format << "-format *******************************************************************"; output << std::endl; @@ -109,7 +106,8 @@ void check( output_test_stream& output, test_suite* ts ) check( output, OF_CLF, ts->p_id ); check( output, OF_XML, ts->p_id ); - check( output, OF_JUNIT, ts->p_id ); + check( output, OF_JUNIT, ts->p_id, log_successful_tests ); + check( output, OF_JUNIT, ts->p_id, log_cpp_exception_errors ); // should branch to the log log_all_errors } //____________________________________________________________________________// @@ -117,94 +115,11 @@ void check( output_test_stream& output, test_suite* ts ) struct guard { ~guard() { - boost::unit_test::unit_test_log.set_format( runtime_config::get( runtime_config::LOG_FORMAT ) ); + boost::unit_test::unit_test_log.set_format( runtime_config::get( runtime_config::btrt_log_format ) ); boost::unit_test::unit_test_log.set_stream( std::cout ); } }; - - -class output_test_stream_for_loggers : public output_test_stream { - -public: - explicit output_test_stream_for_loggers( - boost::unit_test::const_string pattern_file_name = boost::unit_test::const_string(), - bool match_or_save = true, - bool text_or_binary = true ) - : output_test_stream(pattern_file_name, match_or_save, text_or_binary) - {} - - static std::string normalize_path(const std::string &str) { - const std::string to_look_for[] = {"\\"}; - const std::string to_replace[] = {"/"}; - return utils::replace_all_occurrences_of( - str, - to_look_for, to_look_for + sizeof(to_look_for)/sizeof(to_look_for[0]), - to_replace, to_replace + sizeof(to_replace)/sizeof(to_replace[0]) - ); - } - - static std::string get_basename() { - static std::string basename; - - if(basename.empty()) { - basename = normalize_path(__FILE__); - std::string::size_type basename_pos = basename.rfind('/'); - if(basename_pos != std::string::npos) { - basename = basename.substr(basename_pos+1); - } - } - return basename; - } - - virtual std::string get_stream_string_representation() const { - std::string current_string = output_test_stream::get_stream_string_representation(); - - std::string pathname_fixes; - { - static const std::string to_look_for[] = {normalize_path(__FILE__)}; - static const std::string to_replace[] = {"xxx/" + get_basename() }; - pathname_fixes = utils::replace_all_occurrences_of( - current_string, - to_look_for, to_look_for + sizeof(to_look_for)/sizeof(to_look_for[0]), - to_replace, to_replace + sizeof(to_replace)/sizeof(to_replace[0]) - ); - } - - std::string other_vars_fixes; - { - static const std::string to_look_for[] = {"time=\"*\"", - get_basename() + "(*):", - "unknown location(*):", - "; testing time: *us\n", // removing this is far more easier than adding a testing time - "; testing time: *ms\n", - "*", - "condition 2>3 is not satisfied\n", - "condition 2>3 is not satisfied]", - }; - - static const std::string to_replace[] = {"time=\"0.1234\"", - get_basename() + ":*:" , - "unknown location:*:", - "\n", - "\n", - "ZZZ", - "condition 2>3 is not satisfied [2 <= 3]\n", - "condition 2>3 is not satisfied [2 <= 3]]", - }; - - other_vars_fixes = utils::replace_all_occurrences_with_wildcards( - pathname_fixes, - to_look_for, to_look_for + sizeof(to_look_for)/sizeof(to_look_for[0]), - to_replace, to_replace + sizeof(to_replace)/sizeof(to_replace[0]) - ); - } - - return other_vars_fixes; - } - -}; - //____________________________________________________________________________// @@ -220,7 +135,10 @@ BOOST_AUTO_TEST_CASE( test_result_reports ) ? (runtime_config::save_pattern() ? PATTERN_FILE_NAME : "./baseline-outputs/" PATTERN_FILE_NAME ) : framework::master_test_suite().argv[1] ); - output_test_stream_for_loggers test_output( pattern_file_name, !runtime_config::save_pattern() ); + output_test_stream_for_loggers test_output( pattern_file_name, + !runtime_config::save_pattern(), + true, + __FILE__ ); #line 207 test_suite* ts_0 = BOOST_TEST_SUITE( "0 test cases inside" );