]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/process/test/bind_stdin_stdout.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / process / test / bind_stdin_stdout.cpp
CommitLineData
b32b8144
FG
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/process/error.hpp>
15#include <boost/process/io.hpp>
16#include <boost/process/child.hpp>
17#include <boost/process/args.hpp>
18#include <system_error>
19
20#include <boost/system/error_code.hpp>
21#include <string>
22#include <iostream>
23
24namespace bp = boost::process;
92f5a8d4 25BOOST_AUTO_TEST_SUITE( bind_stdin_stdout );
b32b8144
FG
26
27BOOST_AUTO_TEST_CASE(sync_io, *boost::unit_test::timeout(10))
28{
29 using boost::unit_test::framework::master_test_suite;
30
31
32 bp::opstream os;
33 bp::ipstream is;
34 std::error_code ec;
35 bp::child c(
36 master_test_suite().argv[1],
37 bp::args+={"test", "--stdin-to-stdout"},
38 bp::std_in<os,
39 bp::std_out>is,
40 ec
41 );
42 BOOST_REQUIRE(!ec);
43
44 std::string s = "abcdefghi j";
45 for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
46 {
47 os << *it << std::flush;
48 char c;
49 is >> std::noskipws >> c;
50 BOOST_CHECK_EQUAL(*it, c);
51 }
52
53 os.pipe().close();
54
55 BOOST_CHECK(c.wait_for(std::chrono::seconds(3)));
56}
92f5a8d4
TL
57
58BOOST_AUTO_TEST_SUITE_END();