Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64320 - in sandbox/SOC/2010/process: boost/process libs/process/test libs/process/test/util
From: boris_at_[hidden]
Date: 2010-07-24 20:13:08


Author: bschaeling
Date: 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
New Revision: 64320
URL: http://svn.boost.org/trac/boost/changeset/64320

Log:
Simplified test cases
Removed:
   sandbox/SOC/2010/process/libs/process/test/child.hpp
   sandbox/SOC/2010/process/libs/process/test/process.hpp
Text files modified:
   sandbox/SOC/2010/process/boost/process/operations.hpp | 36 ++
   sandbox/SOC/2010/process/libs/process/test/arguments.cpp | 5
   sandbox/SOC/2010/process/libs/process/test/child.cpp | 455 ++++++++++++++++++++++++++++++++++++---
   sandbox/SOC/2010/process/libs/process/test/environment.cpp | 7
   sandbox/SOC/2010/process/libs/process/test/executable.cpp | 18 -
   sandbox/SOC/2010/process/libs/process/test/process.cpp | 54 ++--
   sandbox/SOC/2010/process/libs/process/test/self.cpp | 17 -
   sandbox/SOC/2010/process/libs/process/test/status.cpp | 29 +-
   sandbox/SOC/2010/process/libs/process/test/util/helpers.cpp | 16 +
   9 files changed, 520 insertions(+), 117 deletions(-)

Modified: sandbox/SOC/2010/process/boost/process/operations.hpp
==============================================================================
--- sandbox/SOC/2010/process/boost/process/operations.hpp (original)
+++ sandbox/SOC/2010/process/boost/process/operations.hpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -183,6 +183,12 @@
 template <typename Arguments, typename Context>
 inline child create_child(const std::string &executable, Arguments args, Context ctx)
 {
+#if !defined(NDEBUG)
+ BOOST_ASSERT(ctx.stdin_behavior.get());
+ BOOST_ASSERT(ctx.stdout_behavior.get());
+ BOOST_ASSERT(ctx.stderr_behavior.get());
+#endif
+
     std::string p_name = ctx.process_name.empty() ?
         executable_to_progname(executable) : ctx.process_name;
     args.insert(args.begin(), p_name);
@@ -269,10 +275,17 @@
         if (ctx.stderr_behavior->get_child_end() != -1)
             close(ctx.stderr_behavior->get_child_end());
 
- return child(pid,
- detail::file_handle(ctx.stdin_behavior->get_parent_end()),
- detail::file_handle(ctx.stdout_behavior->get_parent_end()),
- detail::file_handle(ctx.stderr_behavior->get_parent_end()));
+ detail::file_handle fhin(ctx.stdin_behavior->get_parent_end());
+ detail::file_handle fhout(ctx.stdout_behavior->get_parent_end());
+ detail::file_handle fherr(ctx.stderr_behavior->get_parent_end());
+
+#if !defined(NDEBUG)
+ ctx.stdin_behavior.reset();
+ ctx.stdout_behavior.reset();
+ ctx.stderr_behavior.reset();
+#endif
+
+ return child(pid, fhin, fhout, fherr);
     }
 #elif defined(BOOST_WINDOWS_API)
     STARTUPINFOA startup_info;
@@ -315,10 +328,17 @@
     if (ctx.stderr_behavior->get_child_end() != INVALID_HANDLE_VALUE)
         CloseHandle(ctx.stderr_behavior->get_child_end());
 
- return child(pi.hProcess,
- detail::file_handle(ctx.stdin_behavior->get_parent_end()),
- detail::file_handle(ctx.stdout_behavior->get_parent_end()),
- detail::file_handle(ctx.stderr_behavior->get_parent_end()));
+ detail::file_handle fhin(ctx.stdin_behavior->get_parent_end());
+ detail::file_handle fhout(ctx.stdout_behavior->get_parent_end());
+ detail::file_handle fherr(ctx.stderr_behavior->get_parent_end());
+
+#if !defined(NDEBUG)
+ ctx.stdin_behavior.reset();
+ ctx.stdout_behavior.reset();
+ ctx.stderr_behavior.reset();
+#endif
+
+ return child(pi.hProcess, fhin, fhout, fherr);
 #endif
 }
 

Modified: sandbox/SOC/2010/process/libs/process/test/arguments.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/arguments.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/arguments.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,8 +3,9 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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)

Modified: sandbox/SOC/2010/process/libs/process/test/child.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/child.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/child.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,63 +3,434 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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 "child.hpp"
-#include <boost/mpl/vector.hpp>
-#include <boost/mpl/front.hpp>
-#include <boost/mpl/back.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/int.hpp>
-#include <vector>
+#include <boost/process/config.hpp>
+
+#if defined(BOOST_POSIX_API)
+# include <stdlib.h>
+# include <unistd.h>
+# 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 <string>
+#include <vector>
+#include <utility>
+#include <cstdlib>
+
+BOOST_AUTO_TEST_CASE(test_close_stdin)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("is-closed-stdin");
+
+ bp::context ctx;
+ ctx.stdin_behavior = bpb::close::def();
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_close_stdout)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("is-closed-stdout");
+
+ bp::context ctx1;
+ ctx1.stdout_behavior = bpb::close::def();
+
+ bp::child c1 = bp::create_child(get_helpers_path(), args, ctx1);
+
+ int s1 = c1.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s1));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s1), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s1, EXIT_SUCCESS);
+#endif
+
+ bp::context ctx2;
+ ctx2.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c2 = bp::create_child(get_helpers_path(), args, ctx2);
+
+ int s2 = c2.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s2));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s2), EXIT_FAILURE);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s2, EXIT_FAILURE);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_close_stderr)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("is-closed-stderr");
+
+ bp::context ctx1;
+ ctx1.stderr_behavior = bpb::close::def();
+
+ bp::child c1 = bp::create_child(get_helpers_path(), args, ctx1);
+
+ int s1 = c1.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s1));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s1), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s1, EXIT_SUCCESS);
+#endif
+
+ bp::context ctx2;
+ ctx2.stderr_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c2 = bp::create_child(get_helpers_path(), args, ctx2);
+
+ int s2 = c2.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s2));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s2), EXIT_FAILURE);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s2, EXIT_FAILURE);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_input)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("stdin-to-stdout");
+
+ bp::context ctx;
+ ctx.stdin_behavior = bpb::pipe::def(bpb::pipe::input_stream);
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ bp::postream &os = c.get_stdin();
+ bp::pistream &is = c.get_stdout();
+
+ os << "message-to-process" << std::endl;
+ os.close();
+
+ std::string word;
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "message-to-process");
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_output)
+{
+ std::vector<std::string> args;
+ args.push_back("echo-stdout");
+ args.push_back("message-stdout");
+
+ bp::context ctx;
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ std::string word;
+ bp::pistream &is = c.get_stdout();
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "message-stdout");
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_output_error)
+{
+ std::vector<std::string> args;
+ args.push_back("echo-stderr");
+ args.push_back("message-stderr");
+
+ bp::context ctx;
+ ctx.stderr_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ std::string word;
+ bp::pistream &is = c.get_stderr();
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "message-stderr");
 
-class launcher
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+}
+
+class redirect_to : public bpb::stream
 {
 public:
- bp::child operator()(const std::vector<std::string> args,
- bp::context ctx,
- boost::shared_ptr<bpb::stream> bstdin = bpb::close::def(),
- boost::shared_ptr<bpb::stream> bstdout = bpb::close::def(),
- boost::shared_ptr<bpb::stream> bstderr = bpb::close::def())
- const
+ redirect_to(stream_end_type stream_end)
+ {
+#if defined(BOOST_POSIX_API)
+ child_end_ = dup(stream_end);
+ if (child_end_ == -1)
+ BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("dup() failed");
+#elif defined(BOOST_WINDOWS_API)
+ if (!DuplicateHandle(GetCurrentProcess(), stream_end,
+ GetCurrentProcess(), &child_end_, 0, TRUE, DUPLICATE_SAME_ACCESS))
+ BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR("DuplicateHandle() failed");
+#endif
+ }
+
+ static boost::shared_ptr<redirect_to> def(stream_end_type stream_end)
+ {
+ return boost::make_shared<redirect_to>(redirect_to(stream_end));
+ }
+
+ stream_end_type get_child_end()
     {
- ctx.stdin_behavior = bstdin;
- ctx.stdout_behavior = bstdout;
- ctx.stderr_behavior = bstderr;
- return bp::create_child(get_helpers_path(), args, ctx);
+ return child_end_;
     }
+
+private:
+ stream_end_type child_end_;
 };
 
-namespace mpl = boost::mpl;
+BOOST_AUTO_TEST_CASE(test_redirect_err_to_out)
+{
+ std::vector<std::string> args;
+ args.push_back("echo-stdout-stderr");
+ args.push_back("message-to-two-streams");
+
+ bp::context ctx;
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+ ctx.stderr_behavior = redirect_to::def(
+ ctx.stdout_behavior->get_child_end());
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
 
-typedef mpl::vector<
- mpl::vector<launcher, bp::context, bp::child>
-> test_types;
+ bp::pistream &is = c.get_stdout();
+ std::string word;
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "stdout");
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "message-to-two-streams");
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "stderr");
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "message-to-two-streams");
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(child_test_case, T, test_types)
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(check_work_directory)
 {
- check_helpers();
+ std::vector<std::string> args;
+ args.push_back("pwd");
+
+ bp::context ctx;
+ BOOST_CHECK(bfs::equivalent(ctx.work_dir, bfs::current_path().string()));
+
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ bp::pistream &is = c.get_stdout();
+ std::string dir;
+ std::getline(is, dir);
+ std::string::size_type pos = dir.rfind('\r');
+ if (pos != std::string::npos)
+ dir.erase(pos);
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+
+ BOOST_CHECK_EQUAL(bfs::path(dir), bfs::path(ctx.work_dir));
+}
+
+BOOST_AUTO_TEST_CASE(check_work_directory2)
+{
+ std::vector<std::string> args;
+ args.push_back("pwd");
+
+ bfs::path wdir = bfs::current_path() / "test.dir";
+ BOOST_REQUIRE_NO_THROW(bfs::create_directory(wdir));
+
+ try
+ {
+ bp::context ctx;
+ ctx.work_dir = wdir.string();
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ bp::pistream &is = c.get_stdout();
+ std::string dir;
+ std::getline(is, dir);
+ std::string::size_type pos = dir.rfind('\r');
+ if (pos != std::string::npos)
+ dir.erase(pos);
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+
+ BOOST_CHECK_EQUAL(bfs::path(dir), bfs::path(ctx.work_dir));
+ BOOST_CHECK_NO_THROW(bfs::remove_all(wdir));
+ }
+ catch (...)
+ {
+ BOOST_CHECK_NO_THROW(bfs::remove_all(wdir));
+ throw;
+ }
+}
+
+std::pair<bool, std::string> get_var_value(bp::context &ctx, const std::string &var)
+{
+ std::vector<std::string> args;
+ args.push_back("query-env");
+ args.push_back(var);
+
+ ctx.stdout_behavior = bpb::pipe::def(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ bp::pistream &is = c.get_stdout();
+ std::string status;
+ is >> status;
+ std::string gotval;
+ if (status == "defined")
+ is >> gotval;
+
+ int s = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+#endif
+
+ return std::pair<bool, std::string>(status == "defined", gotval);
+}
+
+BOOST_AUTO_TEST_CASE(test_clear_environment)
+{
+ bp::context ctx;
+ ctx.environment.erase("TO_BE_QUERIED");
+
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(setenv("TO_BE_QUERIED", "test", 1) != -1);
+ BOOST_REQUIRE(getenv("TO_BE_QUERIED") != 0);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_REQUIRE(SetEnvironmentVariableA("TO_BE_QUERIED", "test") != 0);
+ char buf[5];
+ BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_QUERIED", buf, 5) == 4);
+#endif
+
+ std::pair<bool, std::string> p = get_var_value(ctx, "TO_BE_QUERIED");
+ BOOST_REQUIRE(!p.first);
+}
+
+BOOST_AUTO_TEST_CASE(test_unset_environment)
+{
+ std::vector<std::string> args;
+ args.push_back("query-env");
+ args.push_back("TO_BE_UNSET");
+
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(setenv("TO_BE_UNSET", "test", 1) != -1);
+ BOOST_REQUIRE(getenv("TO_BE_UNSET") != 0);
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_REQUIRE(SetEnvironmentVariableA("TO_BE_UNSET", "test") != 0);
+ char buf[5];
+ BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_UNSET", buf, 5) == 4);
+#endif
+
+ bp::context ctx;
+ ctx.environment.erase("TO_BE_UNSET");
+ std::pair<bool, std::string> p = get_var_value(ctx, "TO_BE_UNSET");
+ BOOST_CHECK(!p.first);
+}
+
+BOOST_AUTO_TEST_CASE(test_set_environment_var)
+{
+ std::vector<std::string> args;
+ args.push_back("query-env");
+ args.push_back("TO_BE_SET");
+
+#if defined(BOOST_POSIX_API)
+ unsetenv("TO_BE_SET");
+ BOOST_REQUIRE(getenv("TO_BE_SET") == 0);
+#elif defined(BOOST_WINDOWS_API)
+ char buf[5];
+ BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_SET", buf, 5) == 0 ||
+ SetEnvironmentVariableA("TO_BE_SET", NULL) != 0);
+ BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_SET", buf, 5) == 0);
+#endif
+
+ bp::context ctx;
+ ctx.environment.insert(bp::environment_t::value_type("TO_BE_SET",
+ "some-value"));
+ std::pair<bool, std::string> p = get_var_value(ctx, "TO_BE_SET");
+ BOOST_CHECK(p.first);
+ BOOST_CHECK_EQUAL(p.second, "'some-value'");
 
- typedef mpl::front<T>::type Launcher;
- typedef mpl::at<T, mpl::int_<1> >::type Context;
- typedef mpl::back<T>::type Child;
-
- using namespace child_test;
- test_close_stdin<Launcher, Context, Child>();
- test_close_stdout<Launcher, Context, Child>();
- test_close_stderr<Launcher, Context, Child>();
- test_stdout<Launcher, Context, Child>();
- test_stderr<Launcher, Context, Child>();
- // test_redirect_err_to_out<Launcher, Context, Child>();
- test_input<Launcher, Context, Child>();
- test_work_directory<Launcher, Context, Child>();
- test_clear_environment<Launcher, Context, Child>();
- test_unset_environment<Launcher, Context, Child>();
- test_set_environment<Launcher, Context, Child>();
+#if defined(BOOST_POSIX_API)
+ context ctx2;
+ ctx2.environment.insert(bp::environment_t::value_type("TO_BE_SET", ""));
+ std::pair<bool, std::string> p2 = get_var_value(ctx, "TO_BE_SET");
+ BOOST_CHECK(p2.first);
+ BOOST_CHECK_EQUAL(p2.second, "''");
+#endif
 }

Deleted: sandbox/SOC/2010/process/libs/process/test/child.hpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/child.hpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
+++ (empty file)
@@ -1,390 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 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 <stdlib.h>
-# include <sys/wait.h>
-# if defined(__CYGWIN__)
-# undef BOOST_POSIX_API
-# define BOOST_CYGWIN_PATH
-# endif
-#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 <string>
-#include <vector>
-#include <utility>
-#include <cstdlib>
-
-namespace child_test {
-
-//
-// Overview
-// --------
-//
-// The functions below implement tests for common launcher functionality.
-// These are used to test different implementations without duplicating
-// much code.
-//
-// Launcher concept
-// ----------------
-//
-// The functions in this file all rely on a Launcher concept. This concept
-// provides a class whose () operator starts a new process given an
-// executable, its arguments, an execution context and the redirections for
-// the standard streams, and returns a new Child object. The operator also
-// receives a boolean, defaulting to false, that indicates if the child
-// process focuses on testing stdin input. This is needed when testing
-// pipelines to properly place a dummy process in the flow.
-//
-
-template <class Launcher, class Context, class Child>
-void test_close_stdin()
-{
- std::vector<std::string> args;
- args.push_back("is-closed-stdin");
-
- int s = Launcher()(args, Context(), bpb::close::def(),
- bpb::close::def(), bpb::close::def()).wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-}
-
-template <class Launcher, class Context, class Child>
-void test_close_stdout()
-{
- std::vector<std::string> args;
- args.push_back("is-closed-stdout");
-
- int s1 = Launcher()(args, Context()).wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s1));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s1), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s1, EXIT_SUCCESS);
-#endif
-
- int s2 = Launcher()(args, Context(), bpb::close::def(),
- bpb::pipe::def(bpb::pipe::output_stream)).wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s2));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s2), EXIT_FAILURE);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s2, EXIT_FAILURE);
-#endif
-}
-
-template <class Launcher, class Context, class Child>
-void test_close_stderr()
-{
- std::vector<std::string> args;
- args.push_back("is-closed-stderr");
-
- int s1 = Launcher()(args, Context()).wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s1));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s1), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s1, EXIT_SUCCESS);
-#endif
-
- int s2 = Launcher()(args, Context(), bpb::close::def(), bpb::close::def(),
- bpb::pipe::def(bpb::pipe::output_stream)).wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s2));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s2), EXIT_FAILURE);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s2, EXIT_FAILURE);
-#endif
-}
-
-template <class Launcher, class Context, class Child>
-void test_input()
-{
- std::vector<std::string> args;
- args.push_back("stdin-to-stdout");
-
- Child c = Launcher()(args, Context(),
- bpb::pipe::def(bpb::pipe::input_stream),
- bpb::pipe::def(bpb::pipe::output_stream));
-
- bp::postream &os = c.get_stdin();
- bp::pistream &is = c.get_stdout();
-
- os << "message-to-process" << std::endl;
- os.close();
-
- std::string word;
- is >> word;
- BOOST_CHECK_EQUAL(word, "message-to-process");
-
- int s = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-}
-
-template <class Launcher, class Context, class Child>
-void test_output(bool out, const std::string &msg)
-{
- std::vector<std::string> args;
- args.push_back(out ? "echo-stdout" : "echo-stderr");
- args.push_back(msg);
-
- Child c = Launcher()(args, Context(), bpb::close::def(),
- out ? bpb::pipe::def(bpb::pipe::output_stream) :
- bpb::close::def(), out ? bpb::close::def() :
- bpb::pipe::def(bpb::pipe::output_stream));
-
- std::string word;
- if (out)
- {
- bp::pistream &is = c.get_stdout();
- is >> word;
- }
- else
- {
- bp::pistream &is = c.get_stderr();
- is >> word;
- }
- BOOST_CHECK_EQUAL(word, msg);
-
- int s = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-}
-
-template <class Launcher, class Context, class Child>
-void test_stderr()
-{
- test_output<Launcher, Context, Child>(false, "message1-stderr");
- test_output<Launcher, Context, Child>(false, "message2-stderr");
-}
-
-template <class Launcher, class Context, class Child>
-void test_stdout()
-{
- test_output<Launcher, Context, Child>(true, "message1-stdout");
- test_output<Launcher, Context, Child>(true, "message2-stdout");
-}
-
-/*
-template <class Launcher, class Context, class Child>
-void test_redirect_err_to_out()
-{
- std::vector<std::string> args;
- args.push_back("echo-stdout-stderr");
- args.push_back("message-to-two-streams");
-
- Child c = Launcher()(args, Context(), bpb::close::def(),
- bpb::pipe::def(bpb::pipe::output_stream),
- bp::redirect_stream_to_stdout());
-
- bp::pistream &is = c.get_stdout();
- std::string word;
- is >> word;
- BOOST_CHECK_EQUAL(word, "stdout");
- is >> word;
- BOOST_CHECK_EQUAL(word, "message-to-two-streams");
- is >> word;
- BOOST_CHECK_EQUAL(word, "stderr");
- is >> word;
- BOOST_CHECK_EQUAL(word, "message-to-two-streams");
-
- int s = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-}
-*/
-
-template <class Launcher, class Context, class Child>
-void check_work_directory(const std::string &wdir)
-{
- std::vector<std::string> args;
- args.push_back("pwd");
-
- Context ctx;
- if (wdir.empty())
- BOOST_CHECK(bfs::equivalent(ctx.work_dir,
- bfs::current_path().string()));
- else
- ctx.work_dir = wdir;
- Child c = Launcher()(args, ctx, bpb::close::def(),
- bpb::pipe::def(bpb::pipe::output_stream));
-
- bp::pistream &is = c.get_stdout();
- std::string dir;
- std::getline(is, dir);
- std::string::size_type pos = dir.rfind('\r');
- if (pos != std::string::npos)
- dir.erase(pos);
-
- int s = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-
- BOOST_CHECK_EQUAL(bfs::path(dir), bfs::path(ctx.work_dir));
-}
-
-template <class Launcher, class Context, class Child>
-void test_work_directory()
-{
- check_work_directory<Launcher, Context, Child>("");
-
- bfs::path wdir = bfs::current_path() / "test.dir";
- BOOST_REQUIRE_NO_THROW(bfs::create_directory(wdir));
- try
- {
- check_work_directory<Launcher, Context, Child>(wdir.string());
- BOOST_CHECK_NO_THROW(bfs::remove_all(wdir));
- }
- catch (...)
- {
- BOOST_CHECK_NO_THROW(bfs::remove_all(wdir));
- throw;
- }
-}
-
-template <class Launcher, class Context, class Child>
-std::pair<bool, std::string> get_var_value(Context &ctx, const std::string &var)
-{
- std::vector<std::string> args;
- args.push_back("query-env");
- args.push_back(var);
-
- Child c = Launcher()(args, ctx, bpb::close::def(),
- bpb::pipe::def(bpb::pipe::output_stream));
-
- bp::pistream &is = c.get_stdout();
- std::string status;
- is >> status;
- std::string gotval;
- if (status == "defined")
- is >> gotval;
-
- int s = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(WIFEXITED(s));
- BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
-#endif
-
- return std::pair<bool, std::string>(status == "defined", gotval);
-}
-
-template <class Launcher, class Context, class Child>
-void test_clear_environment()
-{
- Context ctx;
- ctx.environment.erase("TO_BE_QUERIED");
-
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(setenv("TO_BE_QUERIED", "test", 1) != -1);
- BOOST_REQUIRE(getenv("TO_BE_QUERIED") != 0);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_REQUIRE(SetEnvironmentVariableA("TO_BE_QUERIED", "test") != 0);
- char buf[5];
- BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_QUERIED", buf, 5) == 4);
-#endif
-
- std::pair<bool, std::string> p =
- get_var_value<Launcher, Context, Child>(ctx, "TO_BE_QUERIED");
- BOOST_REQUIRE(!p.first);
-}
-
-template <class Launcher, class Context, class Child>
-void test_unset_environment()
-{
- std::vector<std::string> args;
- args.push_back("query-env");
- args.push_back("TO_BE_UNSET");
-
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(setenv("TO_BE_UNSET", "test", 1) != -1);
- BOOST_REQUIRE(getenv("TO_BE_UNSET") != 0);
-#elif defined(BOOST_WINDOWS_API)
- BOOST_REQUIRE(SetEnvironmentVariableA("TO_BE_UNSET", "test") != 0);
- char buf[5];
- BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_UNSET", buf, 5) == 4);
-#endif
-
- Context ctx;
- ctx.environment.erase("TO_BE_UNSET");
- std::pair<bool, std::string> p =
- get_var_value<Launcher, Context, Child>(ctx, "TO_BE_UNSET");
- BOOST_CHECK(!p.first);
-}
-
-template <class Launcher, class Context, class Child>
-void test_set_environment_var(const std::string &value)
-{
- std::vector<std::string> args;
- args.push_back("query-env");
- args.push_back("TO_BE_SET");
-
-#if defined(BOOST_POSIX_API)
- unsetenv("TO_BE_SET");
- BOOST_REQUIRE(getenv("TO_BE_SET") == 0);
-#elif defined(BOOST_WINDOWS_API)
- char buf[5];
- BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_SET", buf, 5) == 0 ||
- SetEnvironmentVariableA("TO_BE_SET", NULL) != 0);
- BOOST_REQUIRE(GetEnvironmentVariableA("TO_BE_SET", buf, 5) == 0);
-#endif
-
- Context ctx;
- ctx.environment.insert(bp::environment_t::value_type("TO_BE_SET", value));
- std::pair<bool, std::string> p =
- get_var_value<Launcher, Context, Child>(ctx, "TO_BE_SET");
- BOOST_CHECK(p.first);
- BOOST_CHECK_EQUAL(p.second, "'" + value + "'");
-}
-
-template <class Launcher, class Context, class Child>
-void test_set_environment()
-{
-#if defined(BOOST_POSIX_API)
- test_set_environment_var<Launcher, Context, Child>("");
-#endif
- test_set_environment_var<Launcher, Context, Child>("some-value-1");
- test_set_environment_var<Launcher, Context, Child>("some-value-2");
-}
-
-}

Modified: sandbox/SOC/2010/process/libs/process/test/environment.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/environment.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/environment.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,8 +3,9 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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)
@@ -35,7 +36,7 @@
 #if defined(BOOST_POSIX_API)
     BOOST_REQUIRE(setenv("THIS_SHOULD_BE_DEFINED", "some-value", 1) == 0);
 #elif defined(BOOST_WINDOWS_API)
- BOOST_REQUIRE(SetEnvironmentVariable("THIS_SHOULD_BE_DEFINED",
+ BOOST_REQUIRE(SetEnvironmentVariableA("THIS_SHOULD_BE_DEFINED",
         "some-value") != 0);
 #endif
 

Modified: sandbox/SOC/2010/process/libs/process/test/executable.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/executable.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/executable.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,8 +3,9 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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)
@@ -14,13 +15,7 @@
 
 #if defined(BOOST_POSIX_API)
 # include <stdlib.h>
-# if defined(__CYGWIN__)
-# undef BOOST_POSIX_API
-# define BOOST_CYGWIN_PATH
-# endif
 #elif defined(BOOST_WINDOWS_API)
-# include <boost/shared_array.hpp>
-# include <cstring>
 # include <windows.h>
 #else
 # error "Unsupported platform."
@@ -30,7 +25,6 @@
 #include "util/boost.hpp"
 #include "util/use_helpers.hpp"
 #include <string>
-#include <stdexcept>
 
 BOOST_AUTO_TEST_CASE(test_find_default)
 {
@@ -39,7 +33,7 @@
     std::string helpersname = bfs::path(get_helpers_path()).leaf();
 
     BOOST_CHECK_THROW(bp::find_executable_in_path(helpersname),
- boost::filesystem::filesystem_error);
+ bfs::filesystem_error);
 }
 
 BOOST_AUTO_TEST_CASE(test_find_env)
@@ -72,11 +66,11 @@
             helpersdir.c_str()) != 0);
         bfs::path found = bp::find_executable_in_path(helpersname);
         BOOST_CHECK(bfs::equivalent(orig, found));
- BOOST_REQUIRE(SetEnvironmentVariable("PATH", oldpath) != 0);
+ BOOST_REQUIRE(SetEnvironmentVariableA("PATH", oldpath) != 0);
     }
     catch (...)
     {
- BOOST_REQUIRE(SetEnvironmentVariable("PATH", oldpath) != 0);
+ BOOST_REQUIRE(SetEnvironmentVariableA("PATH", oldpath) != 0);
     }
 #endif
 }

Modified: sandbox/SOC/2010/process/libs/process/test/process.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/process.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/process.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,39 +3,45 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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 "process.hpp"
-#include <boost/mpl/list.hpp>
-#include <boost/mpl/pair.hpp>
+#include <boost/process/config.hpp>
 
-namespace {
+#if defined(BOOST_POSIX_API)
+# include <sys/wait.h>
+#elif defined(BOOST_WINDOWS_API)
+# include <cstdlib>
+#else
+# error "Unsupported platform."
+#endif
+
+#define BOOST_TEST_MAIN
+#include "util/boost.hpp"
+#include "util/use_helpers.hpp"
+#include <string>
+#include <vector>
 
-class launcher
+BOOST_AUTO_TEST_CASE(test_terminate)
 {
-public:
- bp::process operator()(bp::pid_type id) const
- {
- return bp::process(id);
- }
-};
+ std::vector<std::string> args;
+ args.push_back("loop");
 
-}
-
-namespace mpl = boost::mpl;
+ bp::context ctx;
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
 
-typedef mpl::list<
- mpl::pair<bp::process, launcher>
-> test_types;
+ c.terminate();
 
-BOOST_AUTO_TEST_CASE_TEMPLATE(process_test_case, T, test_types)
-{
- using namespace process_test;
- test_getters<T::first, T::second>();
- test_terminate<T::first, T::second>();
+ int status = c.wait();
+#if defined(BOOST_POSIX_API)
+ BOOST_REQUIRE(!WIFEXITED(status));
+ BOOST_REQUIRE(WIFSIGNALED(status));
+#elif defined(BOOST_WINDOWS_API)
+ BOOST_CHECK_EQUAL(status, EXIT_FAILURE);
+#endif
 }

Deleted: sandbox/SOC/2010/process/libs/process/test/process.hpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/process.hpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
+++ (empty file)
@@ -1,81 +0,0 @@
-//
-// Boost.Process
-// ~~~~~~~~~~~~~
-//
-// Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 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 <cstdlib>
-#else
-# error "Unsupported platform."
-#endif
-
-#define BOOST_TEST_MAIN
-#include "util/boost.hpp"
-#include "util/use_helpers.hpp"
-#include <string>
-#include <vector>
-
-namespace process_test {
-
-//
-// Overview
-// --------
-//
-// The functions below implement tests for the basic Process implementation.
-// In order to ensure appropriate behavior, all implementations must
-// have the same behavior in common public methods; keeping this set of
-// tests generic makes it easy to check this restriction because the tests
-// can easily be applied to any specific Process implementation.
-//
-// Factory concept
-// ---------------
-//
-// The functions in this file all rely on a Factory concept. This concept
-// provides a class whose () operator constructs a new Process instance
-// based on a process's identifier. Note that this is the most possible
-// generic construction, which should be conceptually supported by all
-// implementations.
-//
-
-template <class Process, class Factory>
-void test_getters()
-{
- bp::pid_type id = static_cast<bp::pid_type>(0);
- Process c = Factory()(id);
-
- BOOST_CHECK_EQUAL(c.get_id(), id);
-}
-
-template <class Process, class Factory>
-void test_terminate()
-{
- std::vector<std::string> args;
- args.push_back("loop");
-
- bp::context ctx;
- bp::child c = bp::create_child(get_helpers_path(), args, ctx);
-
- Process p = Factory()(c.get_id());
- p.terminate();
-
- int status = c.wait();
-#if defined(BOOST_POSIX_API)
- BOOST_REQUIRE(!WIFEXITED(status));
- BOOST_REQUIRE(WIFSIGNALED(status));
-#elif defined(BOOST_WINDOWS_API)
- BOOST_CHECK_EQUAL(status, EXIT_FAILURE);
-#endif
-}
-
-}

Modified: sandbox/SOC/2010/process/libs/process/test/self.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/self.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/self.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,8 +3,9 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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)
@@ -25,15 +26,6 @@
 #include "util/boost.hpp"
 #include "util/use_helpers.hpp"
 
-class launcher
-{
-public:
- bp::self &operator()(bp::pid_type id)
- {
- return bp::self::get_instance();
- }
-};
-
 BOOST_AUTO_TEST_CASE(test_id)
 {
     bp::self &p = bp::self::get_instance();
@@ -55,7 +47,8 @@
 #if defined(BOOST_POSIX_API)
     BOOST_REQUIRE(setenv("THIS_SHOULD_BE_DEFINED", "some-value", 1) == 0);
 #elif defined(BOOST_WINDOWS_API)
- BOOST_REQUIRE(SetEnvironmentVariableA("THIS_SHOULD_BE_DEFINED", "some-value") != 0);
+ BOOST_REQUIRE(SetEnvironmentVariableA("THIS_SHOULD_BE_DEFINED",
+ "some-value") != 0);
 #endif
 
     bp::environment_t env2 = p.get_environment();

Modified: sandbox/SOC/2010/process/libs/process/test/status.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/status.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/status.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -3,8 +3,9 @@
 // ~~~~~~~~~~~~~
 //
 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
-// Copyright (c) 2008, 2009 Boris Schaeling
-// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
+// 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)
@@ -13,9 +14,10 @@
 #include <boost/process/config.hpp>
 
 #if defined(BOOST_POSIX_API)
+# include <sys/wait.h>
 #elif defined(BOOST_WINDOWS_API)
 #else
-# error "Unsupported platform."
+# error "Unsupported platform."
 #endif
 
 #define BOOST_TEST_MAIN
@@ -23,18 +25,16 @@
 #include "util/use_helpers.hpp"
 #include <string>
 #include <vector>
+#include <cstdlib>
 
-bp::child launch_helper(const std::string &command)
+BOOST_AUTO_TEST_CASE(test_exit_failure)
 {
     std::vector<std::string> args;
- args.push_back(command);
- bp::context ctx;
- return bp::create_child(get_helpers_path(), args, ctx);
-}
+ args.push_back("exit-failure");
 
-BOOST_AUTO_TEST_CASE(test_exit_failure)
-{
- int status = launch_helper("exit-failure").wait();
+ bp::child c = bp::create_child(get_helpers_path(), args);
+
+ int status = c.wait();
 #if defined(BOOST_POSIX_API)
     BOOST_REQUIRE(WIFEXITED(status));
     BOOST_CHECK_EQUAL(WEXITSTATUS(status), EXIT_FAILURE);
@@ -45,7 +45,12 @@
 
 BOOST_AUTO_TEST_CASE(test_exit_success)
 {
- int status = launch_helper("exit-success").wait();
+ std::vector<std::string> args;
+ args.push_back("exit-success");
+
+ bp::child c = bp::create_child(get_helpers_path(), args);
+
+ int status = c.wait();
 #if defined(BOOST_POSIX_API)
     BOOST_REQUIRE(WIFEXITED(status));
     BOOST_CHECK_EQUAL(WEXITSTATUS(status), EXIT_SUCCESS);

Modified: sandbox/SOC/2010/process/libs/process/test/util/helpers.cpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/util/helpers.cpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/util/helpers.cpp 2010-07-24 20:13:06 EDT (Sat, 24 Jul 2010)
@@ -116,10 +116,22 @@
 #if defined(BOOST_WINDOWS_API)
     char buf[1024];
     DWORD res = GetEnvironmentVariableA(argv[1], buf, sizeof(buf));
- std::cout << (res ? buf : "undefined") << std::endl;
+ if (res == 0)
+ std::cout << "undefined" << std::endl;
+ else
+ {
+ std::cout << "defined" << std::endl;
+ std::cout << "'" << buf << "'" << std::endl;
+ }
 #else
     const char *value = getenv(argv[1]);
- std::cout << (value ? value : "undefined") << std::endl;
+ if (value == NULL)
+ std::cout << "undefined" << std::endl;
+ else
+ {
+ std::cout << "defined" << std::endl;
+ std::cout << "'" << value << "'" << std::endl;
+ }
 #endif
 
     return EXIT_SUCCESS;


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