run_exe_path.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 <system_error>
  13. #include <boost/filesystem.hpp>
  14. #include <boost/process/cmd.hpp>
  15. #include <boost/process/error.hpp>
  16. #include <boost/process/child.hpp>
  17. namespace bp = boost::process;
  18. BOOST_AUTO_TEST_CASE(run_exe_success)
  19. {
  20. using boost::unit_test::framework::master_test_suite;
  21. boost::filesystem::path exe = master_test_suite().argv[1];
  22. std::error_code ec;
  23. bp::child c(
  24. exe,
  25. ec
  26. );
  27. BOOST_CHECK(!ec);
  28. }
  29. #if defined(BOOST_WINDOWS_API)
  30. BOOST_AUTO_TEST_CASE(run_exe_error)
  31. {
  32. boost::filesystem::path exe = "doesnt-exist";
  33. std::error_code ec;
  34. bp::child c(
  35. exe,
  36. ec
  37. );
  38. BOOST_CHECK(ec);
  39. }
  40. #endif