Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64764 - in sandbox/SOC/2010/process/libs/process/test: . util
From: boris_at_[hidden]
Date: 2010-08-12 13:41:06


Author: bschaeling
Date: 2010-08-12 13:41:02 EDT (Thu, 12 Aug 2010)
New Revision: 64764
URL: http://svn.boost.org/trac/boost/changeset/64764

Log:
Added POSIX- and Windows-specific test cases
Text files modified:
   sandbox/SOC/2010/process/libs/process/test/child.cpp | 96 ++++++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2010/process/libs/process/test/util/boost.hpp | 1
   sandbox/SOC/2010/process/libs/process/test/util/helpers.cpp | 4
   3 files changed, 99 insertions(+), 2 deletions(-)

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-08-12 13:41:02 EDT (Thu, 12 Aug 2010)
@@ -584,3 +584,99 @@
     BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
 #endif
 }
+
+#if defined(BOOST_POSIX_API)
+class context : public bp::context
+{
+public:
+ context()
+ : p(bpb::pipe::output_stream)
+ {
+ }
+
+ void setup(std::vector<bool> &closeflags)
+ {
+ if (dup2(p.get_child_end().native(), 10) == -1)
+ {
+ write(STDERR_FILENO, "dup2() failed\n", 14);
+ _exit(127);
+ }
+ closeflags[10] = false;
+ }
+
+ bpb::pipe p;
+};
+
+BOOST_AUTO_TEST_CASE(test_posix)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("posix-echo-one");
+ args.push_back("10");
+ args.push_back("test");
+
+ context ctx;
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ std::string word;
+ bp::pistream is(ctx.p.get_parent_end());
+ is >> word;
+ BOOST_CHECK_EQUAL(word, "test");
+
+ int s = c.wait();
+ BOOST_REQUIRE(WIFEXITED(s));
+ BOOST_CHECK_EQUAL(WEXITSTATUS(s), EXIT_SUCCESS);
+}
+#endif
+
+#if defined(BOOST_WINDOWS_API)
+STARTUPINFOA sa;
+
+class context : public bp::context
+{
+public:
+ void setup(STARTUPINFOA &sainfo)
+ {
+ sa.dwFlags = sainfo.dwFlags |= STARTF_USEPOSITION | STARTF_USESIZE;
+ sa.dwX = sainfo.dwX = 100;
+ sa.dwY = sainfo.dwY = 200;
+ sa.dwXSize = sainfo.dwXSize = 640;
+ sa.dwYSize = sainfo.dwYSize = 480;
+ }
+};
+
+BOOST_AUTO_TEST_CASE(test_windows)
+{
+ check_helpers();
+
+ std::vector<std::string> args;
+ args.push_back("windows-print-startupinfo");
+
+ context ctx;
+ ctx.stdout_behavior = bpb::pipe::create(bpb::pipe::output_stream);
+
+ bp::child c = bp::create_child(get_helpers_path(), args, ctx);
+
+ bp::pistream &is = c.get_stdout();
+ std::string line;
+ std::getline(is, line);
+ BOOST_CHECK_EQUAL(line, "dwFlags = " + boost::lexical_cast<std::string>(
+ sa.dwFlags) + "\r");
+ std::getline(is, line);
+ BOOST_CHECK_EQUAL(line, "dwX = " + boost::lexical_cast<std::string>(
+ sa.dwX) + "\r");
+ std::getline(is, line);
+ BOOST_CHECK_EQUAL(line, "dwY = " + boost::lexical_cast<std::string>(
+ sa.dwY) + "\r");
+ std::getline(is, line);
+ BOOST_CHECK_EQUAL(line, "dwXSize = " + boost::lexical_cast<std::string>(
+ sa.dwXSize) + "\r");
+ std::getline(is, line);
+ BOOST_CHECK_EQUAL(line, "dwYSize = " + boost::lexical_cast<std::string>(
+ sa.dwYSize) + "\r");
+
+ int s = c.wait();
+ BOOST_CHECK_EQUAL(s, EXIT_SUCCESS);
+}
+#endif

Modified: sandbox/SOC/2010/process/libs/process/test/util/boost.hpp
==============================================================================
--- sandbox/SOC/2010/process/libs/process/test/util/boost.hpp (original)
+++ sandbox/SOC/2010/process/libs/process/test/util/boost.hpp 2010-08-12 13:41:02 EDT (Thu, 12 Aug 2010)
@@ -21,6 +21,7 @@
 #include <boost/asio.hpp>
 #include <boost/bind.hpp>
 #include <boost/ref.hpp>
+#include <boost/lexical_cast.hpp>
 
 namespace bp = boost::process;
 namespace bpb = boost::process::behavior;

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-08-12 13:41:02 EDT (Thu, 12 Aug 2010)
@@ -214,7 +214,7 @@
 #endif
 
 #if defined(BOOST_WINDOWS_API)
-int h_win32_print_startupinfo(int argc, char *argv[])
+int h_windows_print_startupinfo(int argc, char *argv[])
 {
     STARTUPINFO si;
     GetStartupInfo(&si);
@@ -259,7 +259,7 @@
     { "posix-echo-one", h_posix_echo_one, 3, "desc message" },
     { "posix-echo-two", h_posix_echo_two, 4, "desc1 desc2 message" },
 #elif defined(BOOST_WINDOWS_API)
- { "win32-print-startupinfo", h_win32_print_startupinfo, 1, "" },
+ { "windows-print-startupinfo", h_windows_print_startupinfo, 1, "" },
 #endif
     { 0 }
 };


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