diff --git a/doc/runtime_configuration/runtime_config_reference.qbk b/doc/runtime_configuration/runtime_config_reference.qbk index 38b3da61b0..d3ba622e40 100644 --- a/doc/runtime_configuration/runtime_config_reference.qbk +++ b/doc/runtime_configuration/runtime_config_reference.qbk @@ -136,8 +136,15 @@ acceptable values list. All values are case sensitive and are required to exactl [__param_detect_fp_exceptions__] [Traps floating point exceptions (on supported platforms).] ] - - + + + [/ ###############################################################################################] + [ + [__param_deprecated_timer_format__] + [Enables output of the deprecated timer format.] + ] + + [/ ###############################################################################################] [ [__param_log_sink__] @@ -156,8 +163,7 @@ acceptable values list. All values are case sensitive and are required to exactl [__param_save_pattern__] [Provides parameters for testing output streams.] ] - - + [/ ###############################################################################################] [ [__param_list_content__] @@ -548,7 +554,25 @@ Dnables/disable hardware traps for the floating point exception (if supported). BOOST_TEST_DETECT_FP_EXCEPTIONS -[endsect] [/detect_fp_exceptions] +[endsect] [/detect_fp_exceptions] + +[/ ###############################################################################################] +[#ref_param_deprecated_timer_format][section `deprecated_timer_format`] + +Enables the deprecated timer format + +Enables/disables the output of the deprecated timer format for times when using the HRF format. + +[h4 Acceptable values] + +* [*no] (default) +* yes + +[h4 Environment variable] + + BOOST_TEST_DEPRECATED_TIMER_FORMAT + +[endsect] [/deprecated_timer_format] [/ ###############################################################################################] [#ref_param_log_sink][section `log_sink`] @@ -614,7 +638,7 @@ You can use this parameter to switch between these modes, by passing the paramet BOOST_TEST_SAVE_PATTERN -[endsect] [/save_patterm] +[endsect] [/save_patterm] [/ ###############################################################################################] [section:param_list_content `list_content`] diff --git a/doc/test.qbk b/doc/test.qbk index 6167a2886f..0218976a9e 100644 --- a/doc/test.qbk +++ b/doc/test.qbk @@ -122,27 +122,28 @@ [/ runtime/cla parameters] -[def __param_show_progress__ [link ref_param_show_progress `show_progress`]] -[def __param_log_level__ [link ref_param_log_level `log_level`]] -[def __param_output_format__ [link ref_param_output_format `output_format`]] -[def __param_log_format__ [link ref_param_log_format `log_format`]] -[def __param_run_test__ [link ref_param_run_test `run_test`]] -[def __param_report_level__ [link ref_param_report_level `report_level`]] -[def __param_report_format__ [link ref_param_report_format `report_format`]] -[def __param_catch_system__ [link ref_param_catch_system `catch_system_error`]] -[def __param_result_code__ [link ref_param_result_code `result_code`]] -[def __param_build_info__ [link ref_param_build_info `build_info`]] -[def __param_auto_start_dbg__ [link ref_param_auto_dbg `auto_start_dbg`]] -[def __param_break_exec_path__ [link ref_param_break_exe_path `break_exec_path`]] -[def __param_color_output__ [link ref_param_color_output `color_output`]] -[def __param_random__ [link ref_param_random `random`]] -[def __param_detect_memory_leaks__ [link ref_param_detect_memory_leaks `detect_memory_leaks`]] -[def __param_use_alt_stack__ [link ref_param_use_alt_stack `use_alt_stack`]] -[def __param_detect_fp_exceptions__ [link ref_param_detect_fp_exceptions `detect_fp_exceptions`]] -[def __param_log_sink__ [link ref_param_log_sink `log_sink`]] -[def __param_report_sink__ [link ref_param_report_sink `report_sink`]] -[def __param_save_pattern__ [link ref_param_save_patterm `save_patterm`]] -[def __param_list_content__ [link boost_test.users_guide.runtime_config.rt_param_reference.param_list_content `list_content`]] +[def __param_show_progress__ [link ref_param_show_progress `show_progress`]] +[def __param_log_level__ [link ref_param_log_level `log_level`]] +[def __param_output_format__ [link ref_param_output_format `output_format`]] +[def __param_log_format__ [link ref_param_log_format `log_format`]] +[def __param_run_test__ [link ref_param_run_test `run_test`]] +[def __param_report_level__ [link ref_param_report_level `report_level`]] +[def __param_report_format__ [link ref_param_report_format `report_format`]] +[def __param_catch_system__ [link ref_param_catch_system `catch_system_error`]] +[def __param_result_code__ [link ref_param_result_code `result_code`]] +[def __param_build_info__ [link ref_param_build_info `build_info`]] +[def __param_auto_start_dbg__ [link ref_param_auto_dbg `auto_start_dbg`]] +[def __param_break_exec_path__ [link ref_param_break_exe_path `break_exec_path`]] +[def __param_color_output__ [link ref_param_color_output `color_output`]] +[def __param_random__ [link ref_param_random `random`]] +[def __param_detect_memory_leaks__ [link ref_param_detect_memory_leaks `detect_memory_leaks`]] +[def __param_use_alt_stack__ [link ref_param_use_alt_stack `use_alt_stack`]] +[def __param_detect_fp_exceptions__ [link ref_param_detect_fp_exceptions `detect_fp_exceptions`]] +[def __param_deprecated_timer_format__ [link ref_param_deprecated_timer_format `deprecated_timer_format`]] +[def __param_log_sink__ [link ref_param_log_sink `log_sink`]] +[def __param_report_sink__ [link ref_param_report_sink `report_sink`]] +[def __param_save_pattern__ [link ref_param_save_patterm `save_patterm`]] +[def __param_list_content__ [link boost_test.users_guide.runtime_config.rt_param_reference.param_list_content `list_content`]] [/ decorators] [def __decorator_label__ [link ref_decorator_label `label`]] diff --git a/include/boost/test/impl/compiler_log_formatter.ipp b/include/boost/test/impl/compiler_log_formatter.ipp index 3d7459bd8a..dae6e2f2ae 100644 --- a/include/boost/test/impl/compiler_log_formatter.ipp +++ b/include/boost/test/impl/compiler_log_formatter.ipp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -101,18 +102,15 @@ compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const& //____________________________________________________________________________// void -compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, unsigned long elapsed ) +compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, elapsed_t elapsed ) { BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::BLUE ); output << "Leaving test " << tu.p_type_name << " \"" << tu.p_name << "\""; - if( elapsed > 0 ) { + if( has_time( elapsed ) ) { output << "; testing time: "; - if( elapsed % 1000 == 0 ) - output << elapsed/1000 << "ms"; - else - output << elapsed << "mks"; + output << to_string( elapsed ); } output << std::endl; diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index 12ba84668c..d42e24f69b 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -41,8 +41,9 @@ #include #include +#include + // Boost -#include #include // STL @@ -372,7 +373,7 @@ public: return true; } - void test_unit_finish( test_unit const& tu, unit_test_monitor_t::error_level run_result, unsigned long elapsed ) + void test_unit_finish( test_unit const& tu, unit_test_monitor_t::error_level run_result, elapsed_t elapsed ) { // if run error is critical skip teardown, who knows what the state of the program at this point if( !unit_test_monitor.is_critical_error( run_result ) ) { @@ -413,9 +414,12 @@ public: m_curr_test_case = tc.p_id; // execute the test case body - boost::timer tc_timer; + timer_t tc_timer; unit_test_monitor_t::error_level run_result = unit_test_monitor.execute_and_translate( tc.p_test_func, tc.p_timeout ); - unsigned long elapsed = static_cast( tc_timer.elapsed() * 1e6 ); + + tc_timer.stop(); + elapsed_t elapsed = tc_timer.elapsed(); + // cleanup leftover context m_context.clear(); @@ -434,7 +438,7 @@ public: void test_suite_finish( test_suite const& ts ) { - test_unit_finish( ts, unit_test_monitor_t::test_ok, 0 ); + test_unit_finish( ts, unit_test_monitor_t::test_ok, elapsed_t() ); } ////////////////////////////////////////////////////////////////// diff --git a/include/boost/test/impl/progress_monitor.ipp b/include/boost/test/impl/progress_monitor.ipp index 4e69d3e9da..72133d1877 100644 --- a/include/boost/test/impl/progress_monitor.ipp +++ b/include/boost/test/impl/progress_monitor.ipp @@ -20,13 +20,14 @@ #include #include +#include +#include #include #include #include // Boost -#include #include #include @@ -79,7 +80,7 @@ progress_monitor_t::test_aborted() //____________________________________________________________________________// void -progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long ) +progress_monitor_t::test_unit_finish( test_unit const& tu, elapsed_t ) { BOOST_TEST_SCOPE_SETCOLOR( *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA ); diff --git a/include/boost/test/impl/results_collector.ipp b/include/boost/test/impl/results_collector.ipp index 42b8dc2c00..fa18ef88db 100644 --- a/include/boost/test/impl/results_collector.ipp +++ b/include/boost/test/impl/results_collector.ipp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -184,7 +185,7 @@ private: //____________________________________________________________________________// void -results_collector_t::test_unit_finish( test_unit const& tu, unsigned long ) +results_collector_t::test_unit_finish( test_unit const& tu, elapsed_t ) { if( tu.p_type == TUT_SUITE ) { results_collect_helper ch( s_rc_impl().m_results_store[tu.p_id], tu ); diff --git a/include/boost/test/impl/test_tree.ipp b/include/boost/test/impl/test_tree.ipp index 17ea329b3c..7dd3019d21 100644 --- a/include/boost/test/impl/test_tree.ipp +++ b/include/boost/test/impl/test_tree.ipp @@ -28,9 +28,10 @@ #include #include +#include // Boost -#include +// none // STL #include diff --git a/include/boost/test/impl/unit_test_log.ipp b/include/boost/test/impl/unit_test_log.ipp index 7bfb2ab1b9..579a9339e3 100644 --- a/include/boost/test/impl/unit_test_log.ipp +++ b/include/boost/test/impl/unit_test_log.ipp @@ -28,6 +28,8 @@ #include #include +#include + // Boost #include #include @@ -177,7 +179,7 @@ unit_test_log_t::test_unit_start( test_unit const& tu ) //____________________________________________________________________________// void -unit_test_log_t::test_unit_finish( test_unit const& tu, unsigned long elapsed ) +unit_test_log_t::test_unit_finish( test_unit const& tu, elapsed_t elapsed ) { if( s_log_impl().m_threshold_level > log_test_units ) return; diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp index 7e3b7cbff5..b16d477561 100644 --- a/include/boost/test/impl/unit_test_parameters.ipp +++ b/include/boost/test/impl/unit_test_parameters.ipp @@ -152,28 +152,29 @@ namespace runtime_config { namespace { // framework parameters and corresponding command-line arguments -std::string AUTO_START_DBG = "auto_start_dbg"; -std::string BREAK_EXEC_PATH = "break_exec_path"; -std::string BUILD_INFO = "build_info"; -std::string CATCH_SYS_ERRORS = "catch_system_errors"; -std::string COLOR_OUTPUT = "color_output"; -std::string DETECT_FP_EXCEPT = "detect_fp_exceptions"; -std::string DETECT_MEM_LEAKS = "detect_memory_leaks"; -std::string LIST_CONTENT = "list_content"; -std::string LOG_FORMAT = "log_format"; -std::string LOG_LEVEL = "log_level"; -std::string LOG_SINK = "log_sink"; -std::string OUTPUT_FORMAT = "output_format"; -std::string RANDOM_SEED = "random"; -std::string REPORT_FORMAT = "report_format"; -std::string REPORT_LEVEL = "report_level"; -std::string REPORT_SINK = "report_sink"; -std::string RESULT_CODE = "result_code"; -std::string TESTS_TO_RUN = "run_test"; -std::string SAVE_TEST_PATTERN = "save_pattern"; -std::string SHOW_PROGRESS = "show_progress"; -std::string USE_ALT_STACK = "use_alt_stack"; -std::string WAIT_FOR_DEBUGGER = "wait_for_debugger"; +std::string AUTO_START_DBG = "auto_start_dbg"; +std::string BREAK_EXEC_PATH = "break_exec_path"; +std::string BUILD_INFO = "build_info"; +std::string CATCH_SYS_ERRORS = "catch_system_errors"; +std::string COLOR_OUTPUT = "color_output"; +std::string DEPRECATED_TIMER_FORMAT = "deprecated_timer_format"; +std::string DETECT_FP_EXCEPT = "detect_fp_exceptions"; +std::string DETECT_MEM_LEAKS = "detect_memory_leaks"; +std::string LIST_CONTENT = "list_content"; +std::string LOG_FORMAT = "log_format"; +std::string LOG_LEVEL = "log_level"; +std::string LOG_SINK = "log_sink"; +std::string OUTPUT_FORMAT = "output_format"; +std::string RANDOM_SEED = "random"; +std::string REPORT_FORMAT = "report_format"; +std::string REPORT_LEVEL = "report_level"; +std::string REPORT_SINK = "report_sink"; +std::string RESULT_CODE = "result_code"; +std::string TESTS_TO_RUN = "run_test"; +std::string SAVE_TEST_PATTERN = "save_pattern"; +std::string SHOW_PROGRESS = "show_progress"; +std::string USE_ALT_STACK = "use_alt_stack"; +std::string WAIT_FOR_DEBUGGER = "wait_for_debugger"; static const_string parameter_2_env_var( const_string param_name ) @@ -182,28 +183,29 @@ parameter_2_env_var( const_string param_name ) static mtype s_mapping; if( s_mapping.empty() ) { - s_mapping[AUTO_START_DBG] = "BOOST_TEST_AUTO_START_DBG"; - s_mapping[BREAK_EXEC_PATH] = "BOOST_TEST_BREAK_EXEC_PATH"; - s_mapping[BUILD_INFO] = "BOOST_TEST_BUILD_INFO"; - s_mapping[CATCH_SYS_ERRORS] = "BOOST_TEST_CATCH_SYSTEM_ERRORS"; - s_mapping[COLOR_OUTPUT] = "BOOST_TEST_COLOR_OUTPUT"; - s_mapping[DETECT_FP_EXCEPT] = "BOOST_TEST_DETECT_FP_EXCEPTIONS"; - s_mapping[DETECT_MEM_LEAKS] = "BOOST_TEST_DETECT_MEMORY_LEAK"; - s_mapping[LIST_CONTENT] = "BOOST_TEST_LIST_CONTENT"; - s_mapping[LOG_FORMAT] = "BOOST_TEST_LOG_FORMAT"; - s_mapping[LOG_LEVEL] = "BOOST_TEST_LOG_LEVEL"; - s_mapping[LOG_SINK] = "BOOST_TEST_LOG_SINK"; - s_mapping[OUTPUT_FORMAT] = "BOOST_TEST_OUTPUT_FORMAT"; - s_mapping[RANDOM_SEED] = "BOOST_TEST_RANDOM"; - s_mapping[REPORT_FORMAT] = "BOOST_TEST_REPORT_FORMAT"; - s_mapping[REPORT_LEVEL] = "BOOST_TEST_REPORT_LEVEL"; - s_mapping[REPORT_SINK] = "BOOST_TEST_REPORT_SINK"; - s_mapping[RESULT_CODE] = "BOOST_TEST_RESULT_CODE"; - s_mapping[TESTS_TO_RUN] = "BOOST_TESTS_TO_RUN"; - s_mapping[SAVE_TEST_PATTERN] = "BOOST_TEST_SAVE_PATTERN"; - s_mapping[SHOW_PROGRESS] = "BOOST_TEST_SHOW_PROGRESS"; - s_mapping[USE_ALT_STACK] = "BOOST_TEST_USE_ALT_STACK"; - s_mapping[WAIT_FOR_DEBUGGER] = "BOOST_TEST_WAIT_FOR_DEBUGGER"; + s_mapping[AUTO_START_DBG] = "BOOST_TEST_AUTO_START_DBG"; + s_mapping[BREAK_EXEC_PATH] = "BOOST_TEST_BREAK_EXEC_PATH"; + s_mapping[BUILD_INFO] = "BOOST_TEST_BUILD_INFO"; + s_mapping[CATCH_SYS_ERRORS] = "BOOST_TEST_CATCH_SYSTEM_ERRORS"; + s_mapping[COLOR_OUTPUT] = "BOOST_TEST_COLOR_OUTPUT"; + s_mapping[DEPRECATED_TIMER_FORMAT] = "BOOST_TEST_DEPRECATED_TIMER_FORMAT"; + s_mapping[DETECT_FP_EXCEPT] = "BOOST_TEST_DETECT_FP_EXCEPTIONS"; + s_mapping[DETECT_MEM_LEAKS] = "BOOST_TEST_DETECT_MEMORY_LEAK"; + s_mapping[LIST_CONTENT] = "BOOST_TEST_LIST_CONTENT"; + s_mapping[LOG_FORMAT] = "BOOST_TEST_LOG_FORMAT"; + s_mapping[LOG_LEVEL] = "BOOST_TEST_LOG_LEVEL"; + s_mapping[LOG_SINK] = "BOOST_TEST_LOG_SINK"; + s_mapping[OUTPUT_FORMAT] = "BOOST_TEST_OUTPUT_FORMAT"; + s_mapping[RANDOM_SEED] = "BOOST_TEST_RANDOM"; + s_mapping[REPORT_FORMAT] = "BOOST_TEST_REPORT_FORMAT"; + s_mapping[REPORT_LEVEL] = "BOOST_TEST_REPORT_LEVEL"; + s_mapping[REPORT_SINK] = "BOOST_TEST_REPORT_SINK"; + s_mapping[RESULT_CODE] = "BOOST_TEST_RESULT_CODE"; + s_mapping[TESTS_TO_RUN] = "BOOST_TESTS_TO_RUN"; + s_mapping[SAVE_TEST_PATTERN] = "BOOST_TEST_SAVE_PATTERN"; + s_mapping[SHOW_PROGRESS] = "BOOST_TEST_SHOW_PROGRESS"; + s_mapping[USE_ALT_STACK] = "BOOST_TEST_USE_ALT_STACK"; + s_mapping[WAIT_FOR_DEBUGGER] = "BOOST_TEST_WAIT_FOR_DEBUGGER"; } mtype::const_iterator it = s_mapping.find( param_name ); @@ -282,6 +284,9 @@ init( int& argc, char** argv ) << cla::dual_name_parameter( COLOR_OUTPUT + "|x" ) - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional, cla::description = "Allows to switch between catching and ignoring system errors (signals)") + << cla::named_parameter( DEPRECATED_TIMER_FORMAT ) + - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, + cla::description = "Forces HRF output for timing information to mimic the deprecated boost timer output") << cla::named_parameter( DETECT_FP_EXCEPT ) - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional, cla::description = "Allows to switch between catching and ignoring floating point exceptions") @@ -499,6 +504,14 @@ detect_fp_exceptions() //____________________________________________________________________________// +bool +deprecated_timer_format() +{ + return retrieve_parameter( DEPRECATED_TIMER_FORMAT, s_cla_parser, false ); +} + +//____________________________________________________________________________// + output_format report_format() { diff --git a/include/boost/test/impl/xml_log_formatter.ipp b/include/boost/test/impl/xml_log_formatter.ipp index a14977484d..82de55132f 100644 --- a/include/boost/test/impl/xml_log_formatter.ipp +++ b/include/boost/test/impl/xml_log_formatter.ipp @@ -23,6 +23,8 @@ #include #include +#include + // Boost #include @@ -92,11 +94,11 @@ xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu ) //____________________________________________________________________________// void -xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed ) +xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, elapsed_t elapsed ) { if( tu.p_type == TUT_CASE ) - ostr << "" << elapsed << ""; - + ostr << to_xml( elapsed ); + ostr << ""; } diff --git a/include/boost/test/output/compiler_log_formatter.hpp b/include/boost/test/output/compiler_log_formatter.hpp index 1b91e97477..c607fcdc86 100644 --- a/include/boost/test/output/compiler_log_formatter.hpp +++ b/include/boost/test/output/compiler_log_formatter.hpp @@ -21,6 +21,8 @@ #include +#include + //____________________________________________________________________________// namespace boost { @@ -39,7 +41,7 @@ class BOOST_TEST_DECL compiler_log_formatter : public unit_test_log_formatter { void log_build_info( std::ostream& ); void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); + void test_unit_finish( std::ostream&, test_unit const& tu, elapsed_t elapsed ); void test_unit_skipped( std::ostream&, test_unit const& tu ); void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); diff --git a/include/boost/test/output/xml_log_formatter.hpp b/include/boost/test/output/xml_log_formatter.hpp index 77af0cbb3e..4a4802bdb0 100644 --- a/include/boost/test/output/xml_log_formatter.hpp +++ b/include/boost/test/output/xml_log_formatter.hpp @@ -19,6 +19,8 @@ #include #include +#include + // STL #include // std::size_t @@ -42,7 +44,7 @@ class xml_log_formatter : public unit_test_log_formatter { void log_build_info( std::ostream& ); void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); + void test_unit_finish( std::ostream&, test_unit const& tu, elapsed_t elapsed ); void test_unit_skipped( std::ostream&, test_unit const& tu ); void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); diff --git a/include/boost/test/progress_monitor.hpp b/include/boost/test/progress_monitor.hpp index 364b469bd7..9927f7ff61 100644 --- a/include/boost/test/progress_monitor.hpp +++ b/include/boost/test/progress_monitor.hpp @@ -15,6 +15,7 @@ // Boost.Test #include #include +#include // STL #include // for std::ostream& @@ -38,7 +39,7 @@ class BOOST_TEST_DECL progress_monitor_t : public test_observer, public singleto virtual void test_start( counter_t test_cases_amount ); virtual void test_aborted(); - virtual void test_unit_finish( test_unit const&, unsigned long ); + virtual void test_unit_finish( test_unit const&, elapsed_t ); virtual void test_unit_skipped( test_unit const& ); virtual int priority() { return 3; } diff --git a/include/boost/test/results_collector.hpp b/include/boost/test/results_collector.hpp index 4a183ee485..3fefa59e12 100644 --- a/include/boost/test/results_collector.hpp +++ b/include/boost/test/results_collector.hpp @@ -99,7 +99,7 @@ class BOOST_TEST_DECL results_collector_t : public test_observer, public singlet virtual void test_start( counter_t test_cases_amount ); virtual void test_unit_start( test_unit const& ); - virtual void test_unit_finish( test_unit const&, unsigned long ); + virtual void test_unit_finish( test_unit const&, elapsed_t ); virtual void test_unit_skipped( test_unit const& ); virtual void test_unit_aborted( test_unit const& ); diff --git a/include/boost/test/tree/observer.hpp b/include/boost/test/tree/observer.hpp index f5f2e3a645..7d62bf6f38 100644 --- a/include/boost/test/tree/observer.hpp +++ b/include/boost/test/tree/observer.hpp @@ -17,6 +17,8 @@ #include #include +#include + #include //____________________________________________________________________________// @@ -36,7 +38,7 @@ class BOOST_TEST_DECL test_observer { virtual void test_aborted() {} virtual void test_unit_start( test_unit const& ) {} - virtual void test_unit_finish( test_unit const&, unsigned long /* elapsed */ ) {} + virtual void test_unit_finish( test_unit const&, elapsed_t /* elapsed */ ) {} virtual void test_unit_skipped( test_unit const& ) {} virtual void test_unit_aborted( test_unit const& ) {} diff --git a/include/boost/test/unit_test_log.hpp b/include/boost/test/unit_test_log.hpp index 1f9a347851..05381b5837 100644 --- a/include/boost/test/unit_test_log.hpp +++ b/include/boost/test/unit_test_log.hpp @@ -24,6 +24,7 @@ #include #include #include +#include // Boost @@ -93,7 +94,7 @@ class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton #include +#include + // STL #include #include // for std::string @@ -134,7 +136,7 @@ class BOOST_TEST_DECL unit_test_log_formatter { /// @param[in] tu test unit being finished /// @param[in] elapsed time in milliseconds spend executing this test unit /// @see test_unit_start - virtual void test_unit_finish( std::ostream& os, test_unit const& tu, unsigned long elapsed ) = 0; + virtual void test_unit_finish( std::ostream& os, test_unit const& tu, elapsed_t elapsed ) = 0; /// Invoked if test unit skipped for any reason diff --git a/include/boost/test/unit_test_parameters.hpp b/include/boost/test/unit_test_parameters.hpp index da2701468b..c26c53737c 100644 --- a/include/boost/test/unit_test_parameters.hpp +++ b/include/boost/test/unit_test_parameters.hpp @@ -42,6 +42,8 @@ BOOST_TEST_DECL const_string break_exec_path(); BOOST_TEST_DECL bool catch_sys_errors(); /// Should we try to produce color output? BOOST_TEST_DECL bool color_output(); +/// Enable output of deprecated timer format? +BOOST_TEST_DECL bool deprecated_timer_format(); /// Should we detect floating point exceptions? BOOST_TEST_DECL bool detect_fp_exceptions(); /// Should we detect memory leaks (>0)? And if yes, which specific memory allocation should we break. diff --git a/include/boost/test/utils/progress.hpp b/include/boost/test/utils/progress.hpp new file mode 100644 index 0000000000..d0b675dd88 --- /dev/null +++ b/include/boost/test/utils/progress.hpp @@ -0,0 +1,107 @@ +// boost progress.hpp header file ------------------------------------------// + +// Copyright Beman Dawes 1994-99. Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/timer for documentation. + +// Revision History +// 1 Dec 01 Add leading progress display strings (suggested by Toon Knapen) +// 20 May 01 Introduce several static_casts<> to eliminate warning messages +// (Fixed by Beman, reported by Herve Bronnimann) +// 12 Jan 01 Change to inline implementation to allow use without library +// builds. See docs for more rationale. (Beman Dawes) +// 22 Jul 99 Name changed to .hpp +// 16 Jul 99 Second beta +// 6 Jul 99 Initial boost version + +#ifndef BOOST_TEST_UTILS_PROGRESS_DISPLAY_HPP +#define BOOST_TEST_UTILS_PROGRESS_DISPLAY_HPP + +#include +#include // for ostream, cout, etc +#include // for string + +namespace boost { + +namespace unit_test { + +// progress_display --------------------------------------------------------// + +// progress_display displays an appropriate indication of +// progress at an appropriate place in an appropriate form. + +// NOTE: (Jan 12, 2001) Tried to change unsigned long to boost::uintmax_t, but +// found some compilers couldn't handle the required conversion to double. +// Reverted to unsigned long until the compilers catch up. + +class progress_display : private noncopyable +{ + public: + explicit progress_display( unsigned long expected_count, + std::ostream & os = std::cout, + const std::string & s1 = "\n", //leading strings + const std::string & s2 = "", + const std::string & s3 = "" ) + // os is hint; implementation may ignore, particularly in embedded systems + : m_os(os), m_s1(s1), m_s2(s2), m_s3(s3) { restart(expected_count); } + + void restart( unsigned long expected_count ) + // Effects: display appropriate scale + // Postconditions: count()==0, expected_count()==expected_count + { + _count = _next_tic_count = _tic = 0; + _expected_count = expected_count; + + m_os << m_s1 << "0% 10 20 30 40 50 60 70 80 90 100%\n" + << m_s2 << "|----|----|----|----|----|----|----|----|----|----|" + << std::endl // endl implies flush, which ensures display + << m_s3; + if ( !_expected_count ) _expected_count = 1; // prevent divide by zero + } // restart + + unsigned long operator+=( unsigned long increment ) + // Effects: Display appropriate progress tic if needed. + // Postconditions: count()== original count() + increment + // Returns: count(). + { + if ( (_count += increment) >= _next_tic_count ) { display_tic(); } + return _count; + } + + unsigned long operator++() { return operator+=( 1 ); } + unsigned long count() const { return _count; } + unsigned long expected_count() const { return _expected_count; } + + private: + std::ostream & m_os; // may not be present in all imps + const std::string m_s1; // string is more general, safer than + const std::string m_s2; // const char *, and efficiency or size are + const std::string m_s3; // not issues + + unsigned long _count, _expected_count, _next_tic_count; + unsigned int _tic; + void display_tic() + { + // use of floating point ensures that both large and small counts + // work correctly. static_cast<>() is also used several places + // to suppress spurious compiler warnings. + unsigned int tics_needed = + static_cast( + (static_cast(_count)/_expected_count)*50.0 ); + do { m_os << '*' << std::flush; } while ( ++_tic < tics_needed ); + _next_tic_count = + static_cast((_tic/50.0)*_expected_count); + if ( _count == _expected_count ) { + if ( _tic < 51 ) m_os << '*'; + m_os << std::endl; + } + } // display_tic +}; + +} // namespace unit_test + +} // namespace boost + +#endif // BOOST_TEST_UTILS_PROGRESS_DISPLAY_HPP diff --git a/include/boost/test/utils/timer.hpp b/include/boost/test/utils/timer.hpp new file mode 100644 index 0000000000..53b7a3f94a --- /dev/null +++ b/include/boost/test/utils/timer.hpp @@ -0,0 +1,87 @@ +// (C) Copyright Jamie Allsop 2015. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/test for the library home page. +// +// Description : timer and elapsed types +// *************************************************************************** + +#ifndef BOOST_TEST_UTILS_TIMER_HPP +#define BOOST_TEST_UTILS_TIMER_HPP + +#include +#include +#include + +namespace boost { + +namespace unit_test { + +// ************************************************************************** // +// ************** opaque timer and elapsed types ************** // +// ************************************************************************** // + +typedef boost::timer::cpu_timer timer_t; +typedef boost::timer::cpu_times elapsed_t; +typedef boost::timer::nanosecond_type nanoseconds_t; + +inline long microsecond_cpu_time( elapsed_t elapsed ) +{ + return ( elapsed.user + elapsed.system )/1000; +} + +inline std::string deprecated_hrf_format( elapsed_t elapsed ) +{ + std::ostringstream output; + long duration = microsecond_cpu_time( elapsed ); + if( duration % 1000 == 0 ) + { + output << duration/1000 << "ms"; + } + else + { + output << duration << "mks"; + } + return output.str(); +} + +inline std::string to_string( elapsed_t elapsed ) +{ + if( runtime_config::deprecated_timer_format() ) + { + return deprecated_hrf_format( elapsed ); + } + return boost::timer::format( elapsed, 9, "%ws wall, %us user + %ss system = %ts CPU (%p%)" ); +} + +inline std::string to_xml( elapsed_t elapsed ) +{ + std::ostringstream output; + output << "" << microsecond_cpu_time( elapsed ) << "" + << "" << ( elapsed.user + elapsed.system ) << "" + << "" << elapsed.wall << "" + << "" << elapsed.user << "" + << "" << elapsed.system << ""; + return output.str(); +} + +inline bool has_time( const elapsed_t& elapsed ) +{ + if( runtime_config::deprecated_timer_format() ) + { + return elapsed.user != 0 || elapsed.system != 0 ; + } + return elapsed.wall != 0 || elapsed.user != 0 || elapsed.system != 0; + +} + +//____________________________________________________________________________// + +} // namespace unit_test + +} // namespace boost + +#endif // BOOST_TEST_UTILS_TIMER_HPP + diff --git a/old_doc/html/utf/user-guide/runtime-config/reference.html b/old_doc/html/utf/user-guide/runtime-config/reference.html index d10c434886..0b1023c5a2 100755 --- a/old_doc/html/utf/user-guide/runtime-config/reference.html +++ b/old_doc/html/utf/user-guide/runtime-config/reference.html @@ -43,6 +43,7 @@
  • build_info
  • catch_system_errors
  • color_output
  • +
  • deprecated_timer_format
  • detect_fp_exceptions
  • detect_memory_leaks
  • log_format
  • @@ -241,6 +242,44 @@
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Parameter Name: Force the timer output format to match the deprecated Boost.Timer
    Environment variable name: BOOST_TEST_DEPRECATED_TIMER_FORMAT
    Command line argument name: deprecated_timer_format
    Acceptable Values: + + +
    no
    yes
    Description:

    + Specifying this option forces any timer output to match that provided by the deprecated Boost.Timer + class. If you use scripts that parse either the HRF or XML output for Boost.Test and find you are no + longer able to parse the output correctly then enabling this feature should allow your scripts to + work as before. Disabled by default. +

    +
    +
    diff --git a/old_doc/src/utf.user-guide.runtime-config.xml b/old_doc/src/utf.user-guide.runtime-config.xml index d8f2cd9963..ece88fd68e 100644 --- a/old_doc/src/utf.user-guide.runtime-config.xml +++ b/old_doc/src/utf.user-guide.runtime-config.xml @@ -337,6 +337,24 @@ Leaving test suite "example" + + Use the deprecated timer format for output + BOOST_TEST_DEPRECATED_TIMER_FORMAT + deprecated_timer_format + + + no + yes + + + + + This ensures timer test output matches the format produced for the deprecated Boost.Timer class. Otherwise + updated output will be displayed that provides Wall, User and System times. + + + + [Do not] trap floating point exceptions BOOST_TEST_DETECT_FP_EXCEPTIONS @@ -644,7 +662,7 @@ Leaving test suite "example" makes the framework to print progress information. - + Use alternative stack BOOST_TEST_USE_ALT_STACK diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index dc69ccc3a5..b3aeeca597 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,23 +1,18 @@ # (C) Copyright Gennadiy Rozental 2001-2014. -# Use, modification, and distribution are subject to the -# Boost Software License, Version 1.0. (See accompanying file +# Use, modification, and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file # LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # # See http://www.boost.org/libs/test for the library home page. -project - : requirements - ; - - -rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? ) +rule test-btl-lib ( test-rule : test-name : args * : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? ) { source_files ?= $(test-name).cpp ; return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs) - : #args + : $(args) : $(pattern_file) - : #on + : #on # Activating -pedantic finds more gotchas # Unfortunately, this warns about the use of "long long" in gcc's own stdlib # So deactivate those warnings again @@ -35,13 +30,13 @@ rule test-btl-lib ( test-rule : test-name : lib-name ? : pattern_file * : source ] ; } -rule test-btl-lib-c11 ( test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? ) +rule test-btl-lib-c11 ( test-rule : test-name : args * : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? ) { source_files ?= $(test-name).cpp ; return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs) - : #args + : $(args) : $(pattern_file) - : #on + : #on # Activating -pedantic finds more gotchas # Unfortunately, this warns about the use of "long long" in gcc's own stdlib # So deactivate those warnings again @@ -63,14 +58,14 @@ rule test-btl-lib-c11 ( test-rule : test-name : lib-name ? : pattern_file * : so ] ; } -rule test-btl-lib-mt ( test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? ) +rule test-btl-lib-mt ( test-rule : test-name : args * : lib-name ? : pattern_file * : source_files * : extra-libs ? ) { source_files ?= $(test-name).cpp ; return [ $(test-rule) $(source_files) ../build//$(lib-name) $(extra-libs) - : #args + : $(args) : $(pattern_file) - : #on + : #on # Activating -pedantic finds more gotchas # Unfortunately, this warns about the use of "long long" in gcc's own stdlib # So deactivate those warnings again @@ -83,7 +78,7 @@ rule test-btl-lib-mt ( test-rule : test-name : lib-name ? : pattern_file * : sou gcc-4.5:-std=gnu++0x gcc-4.7:-std=gnu++11 clang:-Wno-c99-extensions - clang:-Wno-variadic-macros + clang:-Wno-variadic-macros BOOST_TEST_NO_AUTO_LINK=1 # requirements multi all @@ -93,53 +88,53 @@ rule test-btl-lib-mt ( test-rule : test-name : lib-name ? : pattern_file * : sou test-suite "basics_test" : - [ test-btl-lib run : class_properties_test : boost_unit_test_framework ] - [ test-btl-lib run : basic_cstring_test : boost_unit_test_framework/static ] + [ test-btl-lib run : class_properties_test : : boost_unit_test_framework ] + [ test-btl-lib run : basic_cstring_test : : boost_unit_test_framework/static ] ; test-suite "prg_exec_monitor_test" - : [ test-btl-lib run-fail : prg_exec_fail1 : included ] - [ test-btl-lib run-fail : prg_exec_fail2 : boost_prg_exec_monitor/static ] - [ test-btl-lib run-fail : prg_exec_fail3 : boost_prg_exec_monitor/static ] - [ test-btl-lib run-fail : prg_exec_fail4 : boost_prg_exec_monitor/static ] + : [ test-btl-lib run-fail : prg_exec_fail1 : : included ] + [ test-btl-lib run-fail : prg_exec_fail2 : : boost_prg_exec_monitor/static ] + [ test-btl-lib run-fail : prg_exec_fail3 : : boost_prg_exec_monitor/static ] + [ test-btl-lib run-fail : prg_exec_fail4 : : boost_prg_exec_monitor/static ] ; test-suite "unit_test_framework_test" : - [ test-btl-lib run : errors_handling_test : boost_unit_test_framework : test_files/errors_handling_test.pattern ] - [ test-btl-lib run : single_header_test ] + [ test-btl-lib run : errors_handling_test : --deprecated_timer_format : boost_unit_test_framework : test_files/errors_handling_test.pattern ] + [ test-btl-lib run : single_header_test : : : : single_header_test.cpp : /boost/timer//boost_timer/static ] [ test-btl-lib run-fail : minimal_test ] [ test-btl-lib run : foreach_test ] - [ test-btl-lib run : output_test_stream_test : boost_unit_test_framework ] - [ test-btl-lib run : result_report_test : boost_unit_test_framework : test_files/result_report_test.pattern ] - [ test-btl-lib run : parameterized_test_test : boost_unit_test_framework ] - [ test-btl-lib run : test_fp_comparisons : boost_unit_test_framework ] - [ test-btl-lib run : test_tools_test : boost_unit_test_framework : test_files/test_tools_test.pattern ] - [ test-btl-lib run : test_case_template_test : boost_unit_test_framework ] - [ test-btl-lib run : custom_exception_test : boost_unit_test_framework/static ] - [ test-btl-lib run : fixed_mapping_test : boost_unit_test_framework ] - [ test-btl-lib run : ifstream_line_iterator_test : boost_unit_test_framework : test_files/ifstream_line_iterator.tst1 test_files/ifstream_line_iterator.tst2 ] - [ test-btl-lib run : algorithms_test : boost_unit_test_framework/static ] - [ test-btl-lib run : token_iterator_test : boost_unit_test_framework ] - [ test-btl-lib run : boost_check_equal_str : boost_unit_test_framework ] - [ test-btl-lib run : test_tree_management_test : boost_unit_test_framework ] - [ test-btl-lib run : run_by_name_label_test : boost_unit_test_framework/static ] - [ test-btl-lib run : test_assertion_construction : boost_unit_test_framework/static ] - [ test-btl-lib run : test_datasets : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ] - # test-rule : test-name : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? - [ test-btl-lib-c11 run : test_datasets_cxx11 : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ] - # [ test-btl-lib run : config_file_iterator_test : boost_unit_test_framework/static ] - # [ test-btl-lib run : config_file_test : boost_unit_test_framework/static ] - [ test-btl-lib run : test_dont_print_log_value : boost_unit_test_framework ] + [ test-btl-lib run : output_test_stream_test : : boost_unit_test_framework ] + [ test-btl-lib run : result_report_test : : boost_unit_test_framework : test_files/result_report_test.pattern ] + [ test-btl-lib run : parameterized_test_test : : boost_unit_test_framework ] + [ test-btl-lib run : test_fp_comparisons : : boost_unit_test_framework ] + [ test-btl-lib run : test_tools_test : : boost_unit_test_framework : test_files/test_tools_test.pattern ] + [ test-btl-lib run : test_case_template_test : : boost_unit_test_framework ] + [ test-btl-lib run : custom_exception_test : : boost_unit_test_framework/static ] + [ test-btl-lib run : fixed_mapping_test : : boost_unit_test_framework ] + [ test-btl-lib run : ifstream_line_iterator_test : : boost_unit_test_framework : test_files/ifstream_line_iterator.tst1 test_files/ifstream_line_iterator.tst2 ] + [ test-btl-lib run : algorithms_test : : boost_unit_test_framework/static ] + [ test-btl-lib run : token_iterator_test : : boost_unit_test_framework ] + [ test-btl-lib run : boost_check_equal_str : : boost_unit_test_framework ] + [ test-btl-lib run : test_tree_management_test : : boost_unit_test_framework ] + [ test-btl-lib run : run_by_name_label_test : : boost_unit_test_framework/static ] + [ test-btl-lib run : test_assertion_construction : : boost_unit_test_framework/static ] + [ test-btl-lib run : test_datasets : : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ] + # test-rule : test-name : args * : lib-name ? : pattern_file * : source_files * : extra-libs ? : extra-options ? + [ test-btl-lib-c11 run : test_datasets_cxx11 : : boost_unit_test_framework : : [ glob test_datasets_src/*.cpp ] : ] + # [ test-btl-lib run : config_file_iterator_test : : boost_unit_test_framework/static ] + # [ test-btl-lib run : config_file_test : : boost_unit_test_framework/static ] + [ test-btl-lib run : test_dont_print_log_value : : boost_unit_test_framework ] ; test-suite "multithreaded_test" : - [ test-btl-lib-mt run : sync_access_test : boost_unit_test_framework/static : : : /boost/thread//boost_thread/static ] + [ test-btl-lib-mt run : sync_access_test : : boost_unit_test_framework/static : : : /boost/thread//boost_thread/static ] ; -# A target that runs all the tests -alias test : basics_test prg_exec_monitor_test unit_test_framework_test ; - -# Only run tests when explicitly requested +# A target that runs all the tests +alias test : basics_test prg_exec_monitor_test unit_test_framework_test ; + +# Only run tests when explicitly requested # explicit test basics_test prg_exec_monitor_test unit_test_framework_test ;