]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/process/test/shell.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / process / test / shell.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#include <iostream>
14
15
16#include <boost/process/cmd.hpp>
17#include <boost/process/args.hpp>
18#include <boost/process/pipe.hpp>
19#include <boost/process/io.hpp>
20#include <boost/process/error.hpp>
21#include <boost/process/child.hpp>
22#include <boost/process/shell.hpp>
23
24namespace bp = boost::process;
25
26BOOST_AUTO_TEST_CASE(shell_simple, *boost::unit_test::timeout(5))
27{
28 using boost::unit_test::framework::master_test_suite;
29
30 std::error_code ec;
31 BOOST_CHECK(!ec);
32
33 bp::ipstream p;
34
35 bp::child c(master_test_suite().argv[1],
36 bp::shell,
37 bp::args+={"test", "--echo-stdout", "hello"},
38 ec,
39 bp::std_out > p);
40 BOOST_CHECK(!ec);
41
42 if (ec)
43 std::cerr << ec.message() << std::endl;
44 std::string s;
45
46 BOOST_TEST_CHECKPOINT("Starting read");
47 p >> s;
48 BOOST_TEST_CHECKPOINT("Finished read");
49
50 BOOST_CHECK_EQUAL(s, "hello");
51}
52
53BOOST_AUTO_TEST_CASE(shell_error, *boost::unit_test::timeout(5))
54{
55 std::error_code ec;
56
57
58 auto c2 = bp::child("doesnt-exist", bp::shell, ec);
59 BOOST_CHECK(!ec);
60
61 c2.wait();
62 BOOST_CHECK(c2.exit_code() != 0);
63}