]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/async_fut.cpp
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>
14 #include <boost/process/error.hpp>
15 #include <boost/process/async.hpp>
16 #include <boost/process/io.hpp>
17 #include <boost/process/spawn.hpp>
18 #include <boost/process/child.hpp>
20 #include <boost/thread.hpp>
23 #include <boost/system/error_code.hpp>
25 #include <boost/algorithm/string/predicate.hpp>
30 namespace bp
= boost::process
;
32 BOOST_AUTO_TEST_CASE(async_out_future
, *boost::unit_test::timeout(2))
35 using boost::unit_test::framework::master_test_suite
;
37 boost::asio::io_context io_context
;
42 std::future
<std::string
> fut
;
43 std::future
<void> fut_in
;
44 boost::asio::streambuf in_buf
;
47 std::ostream
ostr(&in_buf
);
48 ostr
<< "-string" << endl
;
51 master_test_suite().argv
[1],
52 "test", "--prefix-once", "test",
53 bp::std_in
< in_buf
> fut_in
,
63 BOOST_REQUIRE(fut
.valid());
64 BOOST_REQUIRE(fut_in
.valid());
65 BOOST_CHECK_NO_THROW(fut_in
.get());
69 BOOST_CHECK_NO_THROW(line
= fut
.get());
71 std::string val
= "test-string";
72 BOOST_REQUIRE_GE(line
.size(), val
.size());
74 BOOST_CHECK(boost::algorithm::starts_with(line
, val
));
78 BOOST_AUTO_TEST_CASE(emtpy_out
, *boost::unit_test::timeout(2))
80 using boost::unit_test::framework::master_test_suite
;
82 boost::asio::io_context io_context
;
86 std::future
<std::string
> fut
;
89 master_test_suite().argv
[1],
90 "test", "--exit-code", "0",
100 BOOST_REQUIRE(fut
.valid());
101 BOOST_CHECK_EQUAL(fut
.get(), "");