]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/args_handling.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / process / test / args_handling.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 // Copyright (c) 2018 Oxford Nanopore Technologies
7 //
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10
11 #define BOOST_TEST_MAIN
12 #define BOOST_TEST_IGNORE_SIGCHLD
13 #include <boost/test/included/unit_test.hpp>
14
15 #include <system_error>
16 #include <boost/filesystem.hpp>
17
18 #include <boost/process/cmd.hpp>
19 #include <boost/process/error.hpp>
20 #include <boost/process/child.hpp>
21
22 namespace bp = boost::process;
23
24
25 BOOST_AUTO_TEST_CASE(implicit_args_fs_path)
26 {
27 using boost::unit_test::framework::master_test_suite;
28
29 boost::filesystem::path exe = master_test_suite().argv[1];
30
31 std::error_code ec;
32 bp::child c(
33 exe,
34 ec
35 );
36 BOOST_REQUIRE(!ec);
37
38 c.wait(ec);
39 BOOST_REQUIRE(!ec);
40
41 BOOST_CHECK(c.exit_code() == 1); // should pass at least exe!
42 }
43
44 BOOST_AUTO_TEST_CASE(implicit_args_cmd)
45 {
46 using boost::unit_test::framework::master_test_suite;
47
48 std::error_code ec;
49 bp::child c(
50 master_test_suite().argv[1],
51 ec
52 );
53 BOOST_REQUIRE(!ec);
54
55 c.wait(ec);
56 BOOST_REQUIRE(!ec);
57
58 BOOST_CHECK(c.exit_code() == 1); // should pass at least exe!
59 }
60
61 BOOST_AUTO_TEST_CASE(explicit_args_fs_path)
62 {
63 using boost::unit_test::framework::master_test_suite;
64
65 boost::filesystem::path exe = master_test_suite().argv[1];
66
67 std::error_code ec;
68 bp::child c(
69 exe,
70 "hello",
71 ec
72 );
73 BOOST_REQUIRE(!ec);
74
75 c.wait(ec);
76 BOOST_REQUIRE(!ec);
77
78 BOOST_CHECK(c.exit_code() == 2); // exe + "hello"
79 }