123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- #ifndef BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER
- #define BOOST_TEST_EXECUTION_MONITOR_HPP_071894GER
- #include <boost/test/detail/global_typedef.hpp>
- #include <boost/test/detail/fwd_decl.hpp>
- #include <boost/test/detail/throw_exception.hpp>
- #include <boost/test/utils/class_properties.hpp>
- #include <boost/shared_ptr.hpp>
- #include <boost/scoped_array.hpp>
- #include <boost/type.hpp>
- #include <boost/cstdlib.hpp>
- #include <boost/function/function0.hpp>
- #include <boost/test/detail/suppress_warnings.hpp>
- #ifdef BOOST_SEH_BASED_SIGNAL_HANDLING
- #include <float.h>
- #ifndef EM_INVALID
- #define EM_INVALID _EM_INVALID
- #endif
- #ifndef EM_DENORMAL
- #define EM_DENORMAL _EM_DENORMAL
- #endif
- #ifndef EM_ZERODIVIDE
- #define EM_ZERODIVIDE _EM_ZERODIVIDE
- #endif
- #ifndef EM_OVERFLOW
- #define EM_OVERFLOW _EM_OVERFLOW
- #endif
- #ifndef EM_UNDERFLOW
- #define EM_UNDERFLOW _EM_UNDERFLOW
- #endif
- #ifndef MCW_EM
- #define MCW_EM _MCW_EM
- #endif
- #else
- #if !defined(BOOST_NO_FENV_H)
- #include <boost/detail/fenv.hpp>
- #endif
- #endif
- #if defined(BOOST_SEH_BASED_SIGNAL_HANDLING) && !defined(UNDER_CE)
-
-
- #define BOOST_TEST_FPE_SUPPORT_WITH_SEH__
- #elif !defined(BOOST_SEH_BASED_SIGNAL_HANDLING) && !defined(UNDER_CE)
- #if !defined(BOOST_NO_FENV_H) && !defined(BOOST_CLANG) && \
- defined(__GLIBC__) && defined(__USE_GNU) && \
- !(defined(__UCLIBC__) || defined(__nios2__) || defined(__microblaze__))
-
-
-
- #define BOOST_TEST_FPE_SUPPORT_WITH_GLIBC_EXTENSIONS__
- #endif
- #endif
- #ifdef BOOST_TEST_DOXYGEN_DOC__
- #define BOOST_TEST_DISABLE_ALT_STACK
- #endif
- namespace boost {
- namespace detail {
- class translator_holder_base;
- typedef boost::shared_ptr<translator_holder_base> translator_holder_base_ptr;
- class BOOST_TEST_DECL translator_holder_base {
- protected:
- typedef boost::unit_test::const_string const_string;
- public:
-
- translator_holder_base( translator_holder_base_ptr next, const_string tag )
- : m_next( next )
- , m_tag( std::string() + tag )
- {
- }
-
- virtual ~translator_holder_base() {}
-
-
- virtual int operator()( boost::function<int ()> const& F ) = 0;
-
- translator_holder_base_ptr erase( translator_holder_base_ptr this_, const_string tag )
- {
- if( m_next )
- m_next = m_next->erase( m_next, tag );
- return m_tag == tag ? m_next : this_;
- }
- #ifndef BOOST_NO_RTTI
- virtual translator_holder_base_ptr erase( translator_holder_base_ptr this_, std::type_info const& ) = 0;
- template<typename ExceptionType>
- translator_holder_base_ptr erase( translator_holder_base_ptr this_, boost::type<ExceptionType>* = 0 )
- {
- if( m_next )
- m_next = m_next->erase<ExceptionType>( m_next );
- return erase( this_, typeid(ExceptionType) );
- }
- #endif
- protected:
-
- translator_holder_base_ptr m_next;
- std::string m_tag;
- };
- }
- class BOOST_SYMBOL_VISIBLE execution_exception {
- typedef boost::unit_test::const_string const_string;
- public:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- enum error_code {
- no_error = 0,
- user_error = 200,
- cpp_exception_error = 205,
- system_error = 210,
- timeout_error = 215,
- user_fatal_error = 220,
- system_fatal_error = 225
- };
-
- struct BOOST_TEST_DECL location {
- explicit location( char const* file_name = 0, size_t line_num = 0, char const* func = 0 );
- explicit location( const_string file_name, size_t line_num = 0, char const* func = 0 );
- const_string m_file_name;
- size_t m_line_num;
- const_string m_function;
- };
-
-
-
-
-
- execution_exception( error_code ec, const_string what_msg, location const& location );
-
-
- error_code code() const { return m_error_code; }
-
- const_string what() const { return m_what; }
-
- location const& where() const { return m_location; }
-
- private:
-
- error_code m_error_code;
- const_string m_what;
- location m_location;
- };
- class BOOST_TEST_DECL execution_monitor {
- typedef boost::unit_test::const_string const_string;
- public:
-
- execution_monitor();
-
-
-
-
-
-
- unit_test::readwrite_property<bool> p_catch_system_errors;
-
-
-
-
- unit_test::readwrite_property<bool> p_auto_start_dbg;
-
-
-
-
- unit_test::readwrite_property<unsigned long int> p_timeout;
-
-
-
-
-
- unit_test::readwrite_property<bool> p_use_alt_stack;
-
-
-
-
- unit_test::readwrite_property<unsigned> p_detect_fp_exceptions;
-
-
-
-
-
-
-
-
-
-
-
- int execute( boost::function<int ()> const& F );
-
-
-
-
-
- void vexecute( boost::function<void ()> const& F );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template<typename ExceptionType, typename ExceptionTranslator>
- void register_exception_translator( ExceptionTranslator const& tr, const_string tag = const_string(), boost::type<ExceptionType>* = 0 );
-
-
-
- void erase_exception_translator( const_string tag )
- {
- m_custom_translators = m_custom_translators->erase( m_custom_translators, tag );
- }
- #ifndef BOOST_NO_RTTI
-
-
-
- template<typename ExceptionType>
- void erase_exception_translator( boost::type<ExceptionType>* = 0 )
- {
- m_custom_translators = m_custom_translators->erase<ExceptionType>( m_custom_translators );
- }
-
- #endif
- private:
-
- int catch_signals( boost::function<int ()> const& F );
-
- detail::translator_holder_base_ptr m_custom_translators;
- boost::scoped_array<char> m_alt_stack;
- };
- namespace detail {
- template<typename ExceptionType, typename ExceptionTranslator>
- class translator_holder : public translator_holder_base
- {
- public:
- explicit translator_holder( ExceptionTranslator const& tr, translator_holder_base_ptr& next, const_string tag = const_string() )
- : translator_holder_base( next, tag ), m_translator( tr ) {}
-
- int operator()( boost::function<int ()> const& F ) BOOST_OVERRIDE
- {
- BOOST_TEST_I_TRY {
- return m_next ? (*m_next)( F ) : F();
- }
- BOOST_TEST_I_CATCH( ExceptionType, e ) {
- m_translator( e );
- return boost::exit_exception_failure;
- }
- }
- #ifndef BOOST_NO_RTTI
- translator_holder_base_ptr erase( translator_holder_base_ptr this_, std::type_info const& ti ) BOOST_OVERRIDE
- {
- return ti == typeid(ExceptionType) ? m_next : this_;
- }
- #endif
- private:
-
- ExceptionTranslator m_translator;
- };
- }
- template<typename ExceptionType, typename ExceptionTranslator>
- void
- execution_monitor::register_exception_translator( ExceptionTranslator const& tr, const_string tag, boost::type<ExceptionType>* )
- {
- m_custom_translators.reset(
- new detail::translator_holder<ExceptionType,ExceptionTranslator>( tr, m_custom_translators, tag ) );
- }
- struct BOOST_SYMBOL_VISIBLE execution_aborted {};
- class system_error {
- public:
-
- explicit system_error( char const* exp );
- long const p_errno;
- char const* const p_failed_exp;
- };
- #define BOOST_TEST_SYS_ASSERT( cond ) BOOST_TEST_I_ASSRT( cond, ::boost::system_error( BOOST_STRINGIZE( exp ) ) )
- namespace fpe {
- enum masks {
- BOOST_FPE_OFF = 0,
- #if defined(BOOST_TEST_FPE_SUPPORT_WITH_SEH__)
- BOOST_FPE_DIVBYZERO = EM_ZERODIVIDE,
- BOOST_FPE_INEXACT = EM_INEXACT,
- BOOST_FPE_INVALID = EM_INVALID,
- BOOST_FPE_OVERFLOW = EM_OVERFLOW,
- BOOST_FPE_UNDERFLOW = EM_UNDERFLOW|EM_DENORMAL,
- BOOST_FPE_ALL = MCW_EM,
- #elif !defined(BOOST_TEST_FPE_SUPPORT_WITH_GLIBC_EXTENSIONS__)
- BOOST_FPE_DIVBYZERO = BOOST_FPE_OFF,
- BOOST_FPE_INEXACT = BOOST_FPE_OFF,
- BOOST_FPE_INVALID = BOOST_FPE_OFF,
- BOOST_FPE_OVERFLOW = BOOST_FPE_OFF,
- BOOST_FPE_UNDERFLOW = BOOST_FPE_OFF,
- BOOST_FPE_ALL = BOOST_FPE_OFF,
- #else
- #if defined(FE_DIVBYZERO)
- BOOST_FPE_DIVBYZERO = FE_DIVBYZERO,
- #else
- BOOST_FPE_DIVBYZERO = BOOST_FPE_OFF,
- #endif
- #if defined(FE_INEXACT)
- BOOST_FPE_INEXACT = FE_INEXACT,
- #else
- BOOST_FPE_INEXACT = BOOST_FPE_OFF,
- #endif
- #if defined(FE_INVALID)
- BOOST_FPE_INVALID = FE_INVALID,
- #else
- BOOST_FPE_INVALID = BOOST_FPE_OFF,
- #endif
- #if defined(FE_OVERFLOW)
- BOOST_FPE_OVERFLOW = FE_OVERFLOW,
- #else
- BOOST_FPE_OVERFLOW = BOOST_FPE_OFF,
- #endif
- #if defined(FE_UNDERFLOW)
- BOOST_FPE_UNDERFLOW = FE_UNDERFLOW,
- #else
- BOOST_FPE_UNDERFLOW = BOOST_FPE_OFF,
- #endif
- #if defined(FE_ALL_EXCEPT)
- BOOST_FPE_ALL = FE_ALL_EXCEPT,
- #else
- BOOST_FPE_ALL = BOOST_FPE_OFF,
- #endif
- #endif
- BOOST_FPE_INV = BOOST_FPE_ALL+1
- };
- unsigned BOOST_TEST_DECL enable( unsigned mask );
- unsigned BOOST_TEST_DECL disable( unsigned mask );
- }
- }
- #include <boost/test/detail/enable_warnings.hpp>
- #endif
|