prg_exec_monitor.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_TEST_SOURCE) && !defined(BOOST_TEST_INCLUDED)
  28. # define BOOST_LIB_NAME boost_prg_exec_monitor
  29. // If we're importing code from a dll, then tell auto_link.hpp about it:
  30. # if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEST_DYN_LINK)
  31. # define BOOST_DYN_LINK
  32. # endif
  33. # include <boost/config/auto_link.hpp>
  34. #endif // auto-linking disabled
  35. // ************************************************************************** //
  36. // ************** prg_exec_monitor_main ************** //
  37. // ************************************************************************** //
  38. namespace boost {
  39. /// @brief Wrapper around the main function
  40. ///
  41. /// Call this routine instead of your own main body implementation directly. This routine impements all the monitoring
  42. /// functionality. THe monitor behavior is configurable by using the environment variable BOOST_TEST_CATCH_SYSTEM_ERRORS.
  43. /// If set to string value "no", the monitor will not attempt to catch system errors (signals)
  44. /// @param[in] cpp_main main function body. Should have the same signature as regular main function
  45. /// @param[in] argc, argv command line arguments
  46. int BOOST_TEST_DECL prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char* argv[] );
  47. } // boost
  48. #if defined(BOOST_TEST_DYN_LINK) && !defined(BOOST_TEST_NO_MAIN)
  49. // ************************************************************************** //
  50. // ************** main function for tests using dll ************** //
  51. // ************************************************************************** //
  52. // prototype for user's cpp_main()
  53. int cpp_main( int argc, char* argv[] );
  54. int BOOST_TEST_CALL_DECL
  55. main( int argc, char* argv[] )
  56. {
  57. return ::boost::prg_exec_monitor_main( &cpp_main, argc, argv );
  58. }
  59. //____________________________________________________________________________//
  60. #endif // BOOST_TEST_DYN_LINK && !BOOST_TEST_NO_MAIN
  61. #endif // BOOST_PRG_EXEC_MONITOR_HPP_071894GER