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 | |
6 | // See http://www.boost.org/libs/test for the library home page. |
7 | // |
8 | /// @file |
9 | /// @brief defines specific version of execution monitor used to managed run unit of test cases |
10 | /// |
11 | /// Translates execution exception into error level |
12 | // *************************************************************************** |
13 | |
14 | #ifndef BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
15 | #define BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
16 | |
17 | // Boost.Test |
18 | #include <boost/test/execution_monitor.hpp> |
19 | #include <boost/test/detail/fwd_decl.hpp> |
20 | |
21 | #include <boost/test/detail/suppress_warnings.hpp> |
22 | |
23 | //____________________________________________________________________________// |
24 | |
25 | namespace boost { |
26 | namespace unit_test { |
27 | |
28 | // ************************************************************************** // |
29 | // ************** unit_test_monitor ************** // |
30 | // ************************************************************************** // |
31 | |
32 | class BOOST_TEST_DECL unit_test_monitor_t :public execution_monitor { |
33 | public: |
34 | enum error_level { |
35 | test_ok = 0, |
36 | /// Indicates a failure to prepare the unit test (eg. fixture). Does not |
37 | /// account for tests skipped because of parent tests failed/skipped. |
38 | test_setup_failure = -1, |
39 | unexpected_exception = -2, |
40 | os_exception = -3, |
41 | os_timeout = -4, |
42 | fatal_error = -5 // includes both system and user |
43 | }; |
44 | |
45 | static bool is_critical_error( error_level e ) { return e <= fatal_error; } |
46 | |
47 | // monitor method |
48 | // timeout is expressed in seconds |
49 | error_level execute_and_translate( boost::function<void ()> const& func, unsigned long int timeout_microseconds = 0 ); |
50 | |
51 | // singleton pattern |
52 | BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t ) |
53 | }; |
54 | |
55 | BOOST_TEST_SINGLETON_INST( unit_test_monitor ) |
56 | |
57 | } // namespace unit_test |
58 | } // namespace boost |
59 | |
60 | #include <boost/test/detail/enable_warnings.hpp> |
61 | |
62 | #endif // BOOST_TEST_UNIT_TEST_MONITOR_HPP_020905GER |
63 | |