1 // Copyright (c) 2016 Klemens D. Morgenstern 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #define BOOST_TEST_MAIN 7 #define BOOST_TEST_IGNORE_SIGCHLD 8 #include <boost/test/included/unit_test.hpp> 9 10 #include <boost/process/error.hpp> 11 #include <boost/process/io.hpp> 12 #include <boost/process/async.hpp> 13 #include <boost/process/child.hpp> 14 #include <boost/process/async_system.hpp> 15 16 #include <string> 17 #include <boost/asio/io_context.hpp> 18 #include <boost/asio/post.hpp> 19 #include <boost/asio/spawn.hpp> 20 #include <boost/asio/coroutine.hpp> 21 #include <boost/asio/strand.hpp> 22 #include <boost/asio/use_future.hpp> 23 #include <boost/asio/yield.hpp> 24 25 #include <vector> 26 #include <array> 27 BOOST_AUTO_TEST_SUITE( async ); 28 29 namespace bp = boost::process; 30 BOOST_AUTO_TEST_CASE(stackful, *boost::unit_test::timeout(15)) 31 { 32 using boost::unit_test::framework::master_test_suite; 33 34 bool did_something_else = false; 35 36 boost::asio::io_context ios; 37 auto stackful = 38 [&](boost::asio::yield_context yield_) __anon81eb1a5f0102(boost::asio::yield_context yield_) 39 { 40 int ret = 41 bp::async_system( 42 ios, yield_, 43 master_test_suite().argv[1], 44 "test", "--wait", "1"); 45 46 BOOST_CHECK_EQUAL(ret, 0); 47 BOOST_CHECK(did_something_else); 48 }; 49 50 boost::asio::io_context::strand str{ios}; __anon81eb1a5f0202null51 boost::asio::post(str, [&]{boost::asio::spawn(ios, stackful);}); __anon81eb1a5f0302null52 boost::asio::post(str, [&]{did_something_else = true;}); 53 54 ios.run(); 55 BOOST_CHECK(did_something_else); 56 } 57 58 BOOST_AUTO_TEST_SUITE_END();