]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/test/start_dir.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>
13 #include <boost/process.hpp>
14 #include <boost/system/error_code.hpp>
15 #include <boost/filesystem.hpp>
16 #include <boost/algorithm/string/compare.hpp>
20 namespace bp
= boost::process
;
26 test_dir(const std::string
&s
) : s_(s
)
27 { BOOST_REQUIRE_NO_THROW(boost::filesystem::create_directory(s
)); }
28 ~test_dir() { boost::filesystem::remove(s_
); }
31 BOOST_AUTO_TEST_CASE(start_in_dir
)
33 using boost::unit_test::framework::master_test_suite
;
35 test_dir
dir("start_in_dir_test");
41 bp::exe
=boost::filesystem::absolute(master_test_suite().argv
[1]).string(),
42 bp::args
+={"test", "--pwd"},
43 bp::start_dir
= dir
.s_
,
52 auto path_read
= boost::filesystem::absolute(boost::filesystem::path(s
)).string();
53 auto path_set
= boost::filesystem::absolute(dir
.s_
).string();
55 if (path_read
.size() > path_set
.size())
56 path_read
.resize(path_set
.size());
57 else if (path_read
.size() < path_set
.size())
58 path_set
.resize(path_read
.size());
60 BOOST_CHECK_EQUAL_COLLECTIONS(path_read
.begin(), path_read
.end(),
61 path_set
.begin(), path_set
.end());
63 BOOST_REQUIRE_NO_THROW(c
.wait());