Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:01:01

0001 //  (C) Copyright Gennadiy Rozental 2001.
0002 //  Distributed under the Boost Software License, Version 1.0.
0003 //  (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See http://www.boost.org/libs/test for the library home page.
0007 //
0008 //  File        : $RCSfile$
0009 //
0010 //  Version     : $Revision$
0011 //
0012 //  Description : implements specific subclass of Executon Monitor used by Unit
0013 //  Test Framework to monitor test cases run.
0014 // ***************************************************************************
0015 
0016 #ifndef BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
0017 #define BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER
0018 
0019 // Boost.Test
0020 #include <boost/test/unit_test_monitor.hpp>
0021 #include <boost/test/framework.hpp>
0022 #include <boost/test/tree/test_unit.hpp>
0023 #include <boost/test/unit_test_parameters.hpp>
0024 
0025 #include <boost/test/detail/suppress_warnings.hpp>
0026 
0027 //____________________________________________________________________________//
0028 
0029 namespace boost {
0030 namespace unit_test {
0031 
0032 // singleton pattern
0033 BOOST_TEST_SINGLETON_CONS_IMPL(unit_test_monitor_t)
0034 
0035 // ************************************************************************** //
0036 // **************               unit_test_monitor              ************** //
0037 // ************************************************************************** //
0038 
0039 unit_test_monitor_t::error_level
0040 unit_test_monitor_t::execute_and_translate( boost::function<void ()> const& func, unsigned long int timeout_microseconds )
0041 {
0042     BOOST_TEST_I_TRY {
0043         p_catch_system_errors.value     = runtime_config::get<bool>( runtime_config::btrt_catch_sys_errors );
0044         p_timeout.value                 = timeout_microseconds;
0045         p_auto_start_dbg.value          = runtime_config::get<bool>( runtime_config::btrt_auto_start_dbg );
0046         p_use_alt_stack.value           = runtime_config::get<bool>( runtime_config::btrt_use_alt_stack );
0047         p_detect_fp_exceptions.value    = runtime_config::get<bool>( runtime_config::btrt_detect_fp_except );
0048 
0049         vexecute( func );
0050     }
0051     BOOST_TEST_I_CATCH( execution_exception, ex ) {
0052         framework::exception_caught( ex );
0053         framework::test_unit_aborted( framework::current_test_unit() );
0054 
0055         // translate execution_exception::error_code to error_level
0056         switch( ex.code() ) {
0057         case execution_exception::no_error:             return test_ok;
0058         case execution_exception::user_error:           return unexpected_exception;
0059         case execution_exception::cpp_exception_error:  return unexpected_exception;
0060         case execution_exception::system_error:         return os_exception;
0061         case execution_exception::timeout_error:        return os_timeout;
0062         case execution_exception::user_fatal_error:
0063         case execution_exception::system_fatal_error:   return fatal_error;
0064         default:                                        return unexpected_exception;
0065         }
0066     }
0067 
0068     return test_ok;
0069 }
0070 
0071 //____________________________________________________________________________//
0072 
0073 } // namespace unit_test
0074 } // namespace boost
0075 
0076 #include <boost/test/detail/enable_warnings.hpp>
0077 
0078 #endif // BOOST_TEST_UNIT_TEST_MONITOR_IPP_012205GER