]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/wait.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / process / test / wait.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 #include <boost/process/error.hpp>
14 #include <boost/process/child.hpp>
15 #include <boost/process/args.hpp>
16 #include <boost/process/async.hpp>
17 #include <thread>
18 #include <atomic>
19 #include <system_error>
20 #include <boost/asio.hpp>
21 #if defined(BOOST_POSIX_API)
22 # include <signal.h>
23 #endif
24
25 namespace bp = boost::process;
26
27 BOOST_AUTO_TEST_CASE(sync_wait, *boost::unit_test::timeout(2))
28 {
29 using boost::unit_test::framework::master_test_suite;
30
31 std::error_code ec;
32 bp::child c(
33 master_test_suite().argv[1],
34 bp::args+={"test", "--wait", "1"},
35 ec
36 );
37 BOOST_REQUIRE(!ec);
38
39 c.wait();
40
41 }
42
43 BOOST_AUTO_TEST_CASE(async_wait, *boost::unit_test::timeout(2))
44 {
45 using boost::unit_test::framework::master_test_suite;
46 using namespace boost::asio;
47
48 boost::asio::io_context io_context;
49
50 std::error_code ec;
51 bool called = false;
52
53 bp::child c(
54 master_test_suite().argv[1],
55 bp::args+={"test", "--wait", "1"},
56 ec,
57 io_context,
58 bp::on_exit([&](int, const std::error_code&){called = true;})
59
60 );
61 BOOST_REQUIRE(!ec);
62
63 io_context.run();
64 BOOST_CHECK(called);
65
66 }