windows_specific.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright (c) 2006, 2007 Julio M. Merino Vidal
  2. // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
  3. // Copyright (c) 2009 Boris Schaeling
  4. // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
  5. // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. #define BOOST_TEST_MAIN
  10. #define BOOST_TEST_IGNORE_SIGCHLD
  11. #include <boost/test/included/unit_test.hpp>
  12. #include <boost/process.hpp>
  13. #include <boost/process/windows.hpp>
  14. #include <boost/process/extend.hpp>
  15. #include <boost/system/error_code.hpp>
  16. #include <string>
  17. namespace bp = boost::process;
  18. BOOST_AUTO_TEST_CASE(show_window)
  19. {
  20. using boost::unit_test::framework::master_test_suite;
  21. bp::ipstream is;
  22. std::error_code ec;
  23. bp::child c(
  24. master_test_suite().argv[1],
  25. "test", "--windows-print-showwindow",
  26. bp::windows::show_normal,
  27. bp::std_out>is,
  28. ec
  29. );
  30. BOOST_REQUIRE(!ec);
  31. int i;
  32. is >> i;
  33. BOOST_CHECK_EQUAL(i, SW_SHOWNORMAL);
  34. }
  35. #if ( BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 )
  36. struct set_startup_info
  37. {
  38. int &cnt;
  39. template<typename T>
  40. void operator()(T &e) const
  41. {
  42. cnt++;
  43. BOOST_CHECK_EQUAL(e.startup_info.cb, sizeof(::boost::winapi::STARTUPINFOA_));
  44. e.set_startup_info_ex();
  45. }
  46. };
  47. struct check_startup_info
  48. {
  49. int &cnt;
  50. template<typename T>
  51. void operator()(T &e) const
  52. {
  53. cnt++;
  54. BOOST_CHECK(e.creation_flags & ::boost::winapi::EXTENDED_STARTUPINFO_PRESENT_);
  55. BOOST_CHECK_EQUAL(e.startup_info.cb, sizeof(::boost::winapi::STARTUPINFOEXA_));
  56. }
  57. };
  58. BOOST_AUTO_TEST_CASE(startup_info_ex)
  59. {
  60. using boost::unit_test::framework::master_test_suite;
  61. bp::ipstream is;
  62. int cnt = 0;
  63. std::error_code ec;
  64. bp::child c(
  65. master_test_suite().argv[1],
  66. bp::extend::on_setup(set_startup_info{cnt}),
  67. bp::extend::on_success(check_startup_info{cnt}),
  68. bp::std_out>is,
  69. ec
  70. );
  71. BOOST_REQUIRE(!ec);
  72. BOOST_CHECK_EQUAL(cnt, 2);
  73. }
  74. #endif