]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/system_test2.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / process / test / system_test2.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
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
10 #define BOOST_TEST_MAIN
11 #define BOOST_TEST_IGNORE_SIGCHLD
12 #include <boost/test/included/unit_test.hpp>
13
14 #include <boost/system/error_code.hpp>
15
16 #include <iostream>
17
18 #include <boost/asio.hpp>
19 #include <boost/chrono.hpp>
20 #include <boost/algorithm/string/predicate.hpp>
21 #include <boost/asio/steady_timer.hpp>
22 #include <boost/asio/deadline_timer.hpp>
23
24 #include <boost/process/error.hpp>
25 #include <boost/process/io.hpp>
26 #include <boost/process/args.hpp>
27 #include <boost/process/system.hpp>
28 #include <boost/process/async_pipe.hpp>
29 #include <boost/process/async.hpp>
30 #include <system_error>
31
32 #include <boost/filesystem.hpp>
33
34 #include <atomic>
35 #include <string>
36 #include <chrono>
37 #include <istream>
38 #include <cstdlib>
39
40 namespace fs = boost::filesystem;
41 namespace bp = boost::process;
42
43 BOOST_AUTO_TEST_CASE(explicit_async_io, *boost::unit_test::timeout(2))
44 {
45 using boost::unit_test::framework::master_test_suite;
46
47 boost::asio::io_context ios;
48
49 std::future<std::string> fut;
50
51 std::error_code ec;
52 bp::system(
53 master_test_suite().argv[1],
54 "test", "--echo-stdout", "abc",
55 bp::std_out > fut,
56 ios,
57 ec
58 );
59 BOOST_REQUIRE(!ec);
60
61 BOOST_REQUIRE(fut.valid());
62 BOOST_REQUIRE(boost::starts_with(fut.get(), "abc"));
63 }
64
65 BOOST_AUTO_TEST_CASE(explicit_async_io_running, *boost::unit_test::timeout(10))
66 {
67 using boost::unit_test::framework::master_test_suite;
68
69 boost::asio::io_context ios;
70 std::future<std::string> fut;
71 std::error_code ec;
72
73 ios.post([&]
74 {
75 bp::system(
76 master_test_suite().argv[1],
77 "test", "--echo-stdout", "abc",
78 bp::std_out > fut,
79 ios,
80 ec
81 );
82 BOOST_REQUIRE(!ec);
83 });
84
85
86 ios.run();
87
88 BOOST_REQUIRE(fut.valid());
89 BOOST_REQUIRE(boost::starts_with(
90 fut.get(), "abc"));
91
92
93 }