prg_exec_monitor.hpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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
  8. /// @brief Entry point for the end user into the Program Execution Monitor.
  9. ///
  10. /// Use this header to forward declare function prg_exec_monitor_main and to automatically define a main
  11. /// function for you. If you prefer to use your own main you are free to do so, but you need to define
  12. /// BOOST_TEST_NO_MAIN before incuding this header. To initiate your main program body execution you
  13. /// would use statement like this:
  14. /// @code ::boost::prg_exec_monitor_main( &my_main, argc, argv ); @endcode
  15. /// Also this header facilitate auto linking with the Program Execution Monitor library if this feature
  16. /// is supported
  17. // ***************************************************************************
  18. #ifndef BOOST_PRG_EXEC_MONITOR_HPP_071894GER
  19. #define BOOST_PRG_EXEC_MONITOR_HPP_071894GER
  20. #include <boost/test/detail/config.hpp>
  21. //____________________________________________________________________________//
  22. // ************************************************************************** //
  23. // ************** Auto Linking ************** //
  24. // ************************************************************************** //
  25. // Automatically link to the correct build variant where possible.
  26. #if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TEST_NO_LIB) && \
  27. !defined(BOOST_PRG_EXEC_MONITOR_NO_LIB) && \
  28. !defined(BOOST_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED)
  29. # define BOOST_LIB_NAME boost_prg_exec_monitor
  30. // If we're importing code from a dll, then tell auto_link.hpp about it:
  31. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEST_DYN_LINK)
  32. # define BOOST_DYN_LINK
  33. # endif
  34. # include <boost/config/auto_link.hpp>
  35. #endif // auto-linking disabled
  36. // ************************************************************************** //
  37. // ************** prg_exec_monitor_main ************** //
  38. // ************************************************************************** //
  39. namespace boost {
  40. /// @brief Wrapper around the main function
  41. ///
  42. /// Call this routine instead of your own main body implementation directly. This routine impements all the monitoring
  43. /// functionality. THe monitor behavior is configurable by using the environment variable BOOST_TEST_CATCH_SYSTEM_ERRORS.
  44. /// If set to string value "no", the monitor will not attempt to catch system errors (signals)
  45. /// @param[in] cpp_main main function body. Should have the same signature as regular main function
  46. /// @param[in] argc, argv command line arguments
  47. int BOOST_TEST_DECL prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char* argv[] );
  48. } // boost
  49. #if defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
  50. // ************************************************************************** //
  51. // ************** main function for tests using dll ************** //
  52. // ************************************************************************** //
  53. // prototype for user's cpp_main()
  54. int cpp_main( int argc, char* argv[] );
  55. int BOOST_TEST_CALL_DECL
  56. main( int argc, char* argv[] )
  57. {
  58. return ::boost::prg_exec_monitor_main( &cpp_main, argc, argv );
  59. }
  60. //____________________________________________________________________________//
  61. #endif // BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
  62. #endif // BOOST_PRG_EXEC_MONITOR_HPP_071894GER