]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/cmd_test.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/system.hpp>
16 #include <boost/process/env.hpp>
17 #include <boost/process/cmd.hpp>
19 #include <boost/filesystem/path.hpp>
20 #include <boost/filesystem/operations.hpp>
22 #include <system_error>
24 #include <boost/algorithm/string/case_conv.hpp>
26 #include <boost/system/error_code.hpp>
29 namespace bp
= boost::process
;
30 namespace fs
= boost::filesystem
;
33 BOOST_AUTO_TEST_CASE(excplicit
)
35 using boost::unit_test::framework::master_test_suite
;
39 fs::path pth
= master_test_suite().argv
[1];
40 auto env
= boost::this_process::environment();
42 auto itr
= std::find_if(env
.begin(), env
.end(),
43 [](const bp::native_environment::entry_type
& e
){return boost::to_upper_copy(e
.get_name()) == "PATH";});
45 BOOST_REQUIRE(itr
!= env
.end());
47 (*itr
) += fs::canonical(fs::absolute(pth
.parent_path())).string();
50 bp::cmd
="sparring_partner --exit-code 42",
56 BOOST_TEST_MESSAGE(ec
.message());
57 BOOST_CHECK_EQUAL(ret
, 42);
60 BOOST_AUTO_TEST_CASE(implicit
)
62 using boost::unit_test::framework::master_test_suite
;
66 fs::path pth
= master_test_suite().argv
[1];
67 auto env
= boost::this_process::environment();
69 auto itr
= std::find_if(env
.begin(), env
.end(),
70 [](const bp::native_environment::entry_type
& e
){return boost::to_upper_copy(e
.get_name()) == "PATH";});
72 BOOST_REQUIRE(itr
!= env
.end());
74 (*itr
) += fs::canonical(fs::absolute(pth
.parent_path())).string();
77 "sparring_partner --exit-code 21",
83 BOOST_TEST_MESSAGE(ec
.message());
84 BOOST_CHECK_EQUAL(ret
, 21);