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
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)
10 #define BOOST_TEST_MAIN
11 #define BOOST_TEST_IGNORE_SIGCHLD
12 #include <boost/test/included/unit_test.hpp>
13 #include <boost/process/error.hpp>
14 #include <boost/process/child.hpp>
15 #include <boost/process/args.hpp>
16 #include <boost/process/async.hpp>
19 #include <system_error>
20 #include <boost/asio.hpp>
21 #if defined(BOOST_POSIX_API)
25 namespace bp = boost::process;
27 BOOST_AUTO_TEST_CASE(sync_wait, *boost::unit_test::timeout(2))
29 using boost::unit_test::framework::master_test_suite;
33 master_test_suite().argv[1],
34 bp::args+={"test", "--wait", "1"},
43 BOOST_AUTO_TEST_CASE(async_wait, *boost::unit_test::timeout(2))
45 using boost::unit_test::framework::master_test_suite;
46 using namespace boost::asio;
48 boost::asio::io_service io_service;
54 master_test_suite().argv[1],
55 bp::args+={"test", "--wait", "1"},
58 bp::on_exit([&](int, const std::error_code&){called = true;})
68 BOOST_AUTO_TEST_CASE(double_wait, *boost::unit_test::timeout(5))
70 using boost::unit_test::framework::master_test_suite;
71 using namespace boost::asio;
73 boost::asio::io_service io_service;
76 std::atomic<bool> called{false};
79 master_test_suite().argv[1],
80 bp::args+={"test", "--wait", "1"},
83 bp::on_exit([&](int, const std::error_code&){called.store(true);})
88 std::thread th([&]{io_service.run();});
93 BOOST_CHECK(called.load());