unit_test_monitor.ipp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // (C) Copyright Gennadiy Rozental 2001.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision$
  10. //
  11. // Description : implements specific subclass of Executon Monitor used by Unit
  12. // Test Framework to monitor test cases run.
  13. // ***************************************************************************
  14. #ifndef BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
  15. #define BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
  16. // Boost.Test
  17. #include <boost/test/unit_test_monitor.hpp>
  18. #include <boost/test/framework.hpp>
  19. #include <boost/test/tree/test_unit.hpp>
  20. #include <boost/test/unit_test_parameters.hpp>
  21. #include <boost/test/detail/suppress_warnings.hpp>
  22. //____________________________________________________________________________//
  23. namespace boost {
  24. namespace unit_test {
  25. // ************************************************************************** //
  26. // ************** unit_test_monitor ************** //
  27. // ************************************************************************** //
  28. unit_test_monitor_t::error_level
  29. unit_test_monitor_t::execute_and_translate( boost::function<void ()> const& func, unsigned timeout )
  30. {
  31. BOOST_TEST_I_TRY {
  32. p_catch_system_errors.value = runtime_config::get<bool>( runtime_config::btrt_catch_sys_errors );
  33. p_timeout.value = timeout;
  34. p_auto_start_dbg.value = runtime_config::get<bool>( runtime_config::btrt_auto_start_dbg );
  35. p_use_alt_stack.value = runtime_config::get<bool>( runtime_config::btrt_use_alt_stack );
  36. p_detect_fp_exceptions.value = runtime_config::get<bool>( runtime_config::btrt_detect_fp_except );
  37. vexecute( func );
  38. }
  39. BOOST_TEST_I_CATCH( execution_exception, ex ) {
  40. framework::exception_caught( ex );
  41. framework::test_unit_aborted( framework::current_test_unit() );
  42. // translate execution_exception::error_code to error_level
  43. switch( ex.code() ) {
  44. case execution_exception::no_error: return test_ok;
  45. case execution_exception::user_error: return unexpected_exception;
  46. case execution_exception::cpp_exception_error: return unexpected_exception;
  47. case execution_exception::system_error: return os_exception;
  48. case execution_exception::timeout_error: return os_timeout;
  49. case execution_exception::user_fatal_error:
  50. case execution_exception::system_fatal_error: return fatal_error;
  51. default: return unexpected_exception;
  52. }
  53. }
  54. return test_ok;
  55. }
  56. //____________________________________________________________________________//
  57. } // namespace unit_test
  58. } // namespace boost
  59. #include <boost/test/detail/enable_warnings.hpp>
  60. #endif // BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER