|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64524 - in sandbox/SOC/2010/process: boost/process/detail libs/process/test
From: boris_at_[hidden]
Date: 2010-08-01 12:45:52
Author: bschaeling
Date: 2010-08-01 12:45:52 EDT (Sun, 01 Aug 2010)
New Revision: 64524
URL: http://svn.boost.org/trac/boost/changeset/64524
Log:
Added wait test case
Added:
sandbox/SOC/2010/process/libs/process/test/wait.cpp (contents, props changed)
Text files modified:
sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp | 2 +-
sandbox/SOC/2010/process/libs/process/test/Jamfile.jam | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
Modified: sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/detail/basic_status_service.hpp 2010-08-01 12:45:52 EDT (Sun, 01 Aug 2010)
@@ -104,7 +104,7 @@
int wait(implementation_type &impl, pid_type pid)
{
boost::system::error_code ec;
- int status = impl.wait(pid, ec);
+ int status = impl->wait(pid, ec);
boost::asio::detail::throw_error(ec);
return status;
}
Modified: sandbox/SOC/2010/process/libs/process/test/Jamfile.jam
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/Jamfile.jam (original)
+++ sandbox/SOC/2010/process/libs/process/test/Jamfile.jam 2010-08-01 12:45:52 EDT (Sun, 01 Aug 2010)
@@ -14,6 +14,9 @@
alias bfs : /boost//filesystem : : : <link>shared:<source>/boost//system ;
explicit bfs ;
+alias bt : /boost//thread ;
+explicit bt ;
+
project : requirements
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
<target-os>linux:<linkflags>-lpthread ;
@@ -31,3 +34,4 @@
run executable.cpp bfs : : helpers : <dependency>helpers ;
run process.cpp bfs : : helpers : <dependency>helpers ;
run status.cpp bfs : : helpers : <dependency>helpers ;
+run wait.cpp bfs bt : : helpers : <dependency>helpers ;
Added: sandbox/SOC/2010/process/libs/process/test/wait.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/process/libs/process/test/wait.cpp 2010-08-01 12:45:52 EDT (Sun, 01 Aug 2010)
@@ -0,0 +1,96 @@
+//
+// Boost.Process
+// ~~~~~~~~~~~~~
+//
+// Copyright (c) 2006, 2007 Julio M. Merino Vidal
+// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
+// Copyright (c) 2009 Boris Schaeling
+// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+# include <sys/wait.h>
+#elif defined(BOOST_WINDOWS_API)
+# include <windows.h>
+#else
+# error "Unsupported platform."
+#endif
+
+#define BOOST_TEST_MAIN
+#include "util/boost.hpp"
+#include "util/use_helpers.hpp"
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+#include <cstdlib>
+
+namespace ba = boost::asio;
+
+BOOST_AUTO_TEST_CASE(test_child_wait)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("exit-success");
+
+ bp::child c = bp::create_child(get_helpers_path(), args);
+
+ int exit_code = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(exit_code));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(exit_code, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_status_wait)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("exit-success");
+
+ bp::child c = bp::create_child(get_helpers_path(), args);
+
+ ba::io_service ioservice;
+ bp::status s(ioservice);
+ int exit_code = s.wait(c.get_id());
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(exit_code));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(exit_code, EXIT_SUCCESS);
+#endif
+}
+
+void handler(boost::system::error_code ec, int exit_code)
+{
+ BOOST_REQUIRE_EQUAL(ec, boost::system::error_code());
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(exit_code));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(exit_code), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(exit_code, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_status_async_wait)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("exit-success");
+
+ bp::child c = bp::create_child(get_helpers_path(), args);
+
+ ba::io_service ioservice;
+ bp::status s(ioservice);
+ s.async_wait(c.get_id(), handler);
+ ioservice.run();
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk