Boost logo

Boost-Commit :

From: lists.drrngrvy_at_[hidden]
Date: 2008-03-21 13:02:04


Author: drrngrvy
Date: 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
New Revision: 43755
URL: http://svn.boost.org/trac/boost/changeset/43755

Log:
* Added some compile tests and fixed the (two!) run tests.
* Tried setting up tests using wget to verify the whole program (by checking its output when it's behind a server)
Added:
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/acgi_acceptor.cpp (contents, props changed)
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_acceptor.cpp (contents, props changed)
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_request.cpp (contents, props changed)
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/shareable_tcp_connection.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/Jamfile.v2 | 74 +++++++++++++++++++++++------------
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/async_stdio_connection.cpp | 4
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/cgi_request.cpp | 2
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_service.cpp | 4
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp | 2
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/stdio_connection.cpp | 2
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/tcp_connection.cpp | 4
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/Jamfile.v2 | 23 +++++++++++
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp | 24 +++++++----
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp | 83 ++++++++++++++++++++++++++++++++++++++-
   sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/stdio_connection.cpp | 2
   11 files changed, 177 insertions(+), 47 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/Jamfile.v2 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,46 +2,70 @@
 
 import testing ;
 
-test-suite scgi_compile_tests
- :
- [ compile scgi_service.cpp ]
- [ compile scgi_request.cpp ]
- [ compile scgi_acceptor.cpp ]
- :
- <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE=1
- <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
- <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE=1
- <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
- <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
- ;
-
-explicit scgi_compile_tests ;
+project boost/cgi/test/compile
+ : requirements
+ <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE=1
+ <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
+ <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE=1
+ <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
+ <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
+ ;
+
+#rule compile-test( name )
+#{
+# return [ run $(name).cpp ] ;
+#}
+
+#test-suite scgi_compile_tests
+# :
+# [ compile scgi_service.cpp ]
+# [ compile scgi_request.cpp ]
+# [ compile scgi_acceptor.cpp ]
+# :
+# <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE=1
+# <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
+# <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE=1
+# <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
+# <toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS
+# ;
+
+#explicit scgi_compile_tests ;
+
+#test-suite acgi_compile_test
+# :
+# ;
 
 test-suite compile_test_suite
   :
     # connections
- [ compile stdio_connection.cpp ]
- [ compile async_stdio_connection.cpp ]
- [ compile tcp_connection.cpp ]
+ [ compile stdio_connection.cpp ]
+ [ compile async_stdio_connection.cpp ]
+ [ compile tcp_connection.cpp ]
+ [ compile shareable_tcp_connection.cpp ]
     
     # services
- [ compile acgi_service.cpp ]
-# [ compile fcgi_service.cpp ]
+ [ compile acgi_service.cpp ]
+ [ compile fcgi_service.cpp ]
 
     # requests
- [ compile cgi_request.cpp ]
- [ compile acgi_request.cpp ]
+ [ compile cgi_request.cpp ]
+ [ compile acgi_request.cpp ]
+ [ compile fcgi_request.cpp ]
 
     # response
- [ compile response.cpp ]
+ [ compile response.cpp ]
+
+ # acceptors
+ #[ compile acgi_acceptor.cpp ]
+ [ compile fcgi_acceptor.cpp ]
     
     # misc tests
- [ compile cgi_header_check.cpp ]
- [ compile is_async_test.cpp ]
+ [ compile cgi_header_check.cpp ]
+ [ compile is_async_test.cpp ]
   :
     <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE=1
     <toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
     <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE=1
   ;
 
-explicit compile_test_suite ;
+#explicit compile_test_suite ;

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/acgi_acceptor.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/acgi_acceptor.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -0,0 +1,9 @@
+#include "boost/cgi/acgi/acceptor.hpp"
+
+int main()
+{
+ cgi::acgi::service s;
+ cgi::acgi::acceptor a(s);
+
+ return 0;
+}

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/async_stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/async_stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/async_stdio_connection.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,8 +2,8 @@
 
 int main()
 {
- cgi::io_service ios;
- cgi::async_stdio_connection conn(ios);
+ cgi::common::io_service ios;
+ cgi::common::async_stdio_connection conn(ios);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/cgi_request.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/cgi_request.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/cgi_request.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,7 +2,7 @@
 
 int main()
 {
- cgi::cgi::request req;
+ cgi::request req;
 
   return 0;
 }

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_acceptor.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_acceptor.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -0,0 +1,9 @@
+#include <boost/cgi/fcgi/acceptor.hpp>
+
+int main()
+{
+ cgi::fcgi::service s;
+ cgi::fcgi::acceptor a(s);
+
+ return 0;
+}

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_request.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_request.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -0,0 +1,9 @@
+#include <boost/cgi/fcgi/request.hpp>
+
+int main()
+{
+ cgi::fcgi::service s;
+ cgi::fcgi::request req(s);
+
+ return 0;
+}

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_service.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_service.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/fcgi_service.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -1,8 +1,8 @@
-#include "boost/cgi/fcgi/fcgi_service.hpp"
+#include "boost/cgi/fcgi/service.hpp"
 
 int main()
 {
- cgi::fcgi_service s;
+ cgi::fcgi::service s;
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/response.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,7 +2,7 @@
 
 int main(int, char**)
 {
- cgi::response resp;
+ cgi::common::response resp;
 
   resp<< "blah";
 

Added: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/shareable_tcp_connection.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/shareable_tcp_connection.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -0,0 +1,9 @@
+#include "boost/cgi/connections/shareable_tcp_socket.hpp"
+
+int main()
+{
+ cgi::common::io_service ios;
+ cgi::common::connection::shareable_tcp conn(ios);
+
+ return 0;
+}

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/stdio_connection.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,7 +2,7 @@
 
 int main()
 {
- cgi::stdio_connection conn;
+ cgi::common::connection::stdio conn;
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/tcp_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/tcp_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/compile/tcp_connection.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -2,8 +2,8 @@
 
 int main()
 {
- cgi::io_service ios;
- cgi::tcp_connection conn(ios);
+ cgi::common::io_service ios;
+ cgi::common::connection::tcp conn(ios);
 
   return 0;
 }

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/Jamfile.v2 (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/Jamfile.v2 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -3,9 +3,32 @@
 
 import testing ;
 
+project boost/cgi/tests/run
+ : requirements
+ <include>/usr/local/src/boost/sandbox/SOC/2006/process/tags/process-0.1
+ <library>/boost/test//boost_unit_test_framework/
+ <library>/boost/system/
+ <library>/boost/thread/
+ ;
+
+#local rule run-test( name )
+#{
+# return [
+# run $(name).cpp /boost/test//boost_unit_test_framework/<link>static
+# ] ;
+#}
+
 test-suite run_test_suite
   :
     #[ run [ glob *.cpp ] ]
     
     [ run cookie.cpp ]
+ [ run response.cpp ]
   ;
+
+test-suite wget_test
+ :
+ [ run wget.cpp : "--log_level=message" ]
+ ;
+
+explicit wget_test ;

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/cookie.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -5,7 +5,7 @@
  * - Verify it works with other string types (std::wstring is probably enough)
  */
 
-#define BOOST_TEST_MAIN
+#define BOOST_TEST_MODULE cookie_test
 #include <boost/test/unit_test.hpp>
 
 #include <sstream>
@@ -18,7 +18,9 @@
   // delete the cookie. ie. set its value to NULL and give it a date
   // in the past
   using namespace cgi;
+ using namespace std;
 
+ string ex("Fri, 05-Jun-1989 15:30:00 GMT");
   cookie ck("unwanted_cookie_name");
   
   BOOST_CHECK(ck.name == "unwanted_cookie_name");
@@ -26,7 +28,7 @@
   BOOST_CHECK(ck.path == "/");
   // this one could be more robust (by using a generic RFC2616 date parser)
   // see: http://www.apps.ietf.org/rfc/rfc2616.html#sec-3.3
- BOOST_CHECK(ck.data == "Fri, 05 Jun 1989 15:30:00 GMT");
+ BOOST_CHECK_EQUAL(ck.expires, ex);
   BOOST_CHECK(ck.domain == "");
   BOOST_CHECK(ck.secure == false);
   BOOST_CHECK(ck.http_only == false);
@@ -36,8 +38,11 @@
 {
   // Check the full version of the constructor works (simple test)
   using namespace cgi;
+ using namespace std;
 
- cookie ck("name", "value", "Wed, 03-Oct-2007 16:26:06 GMT"
+ string ex("Wed, 03-Oct-2007 16:26:06 GMT");
+
+ cookie ck("name", "value", ex
            , "/cookie", "example.com", false, true);
 
   BOOST_CHECK(ck.name == "name");
@@ -45,7 +50,7 @@
   BOOST_CHECK(ck.path == "/cookie");
   // this one could be more robust (by using a generic RFC2616 date parser)
   // see: http://www.apps.ietf.org/rfc/rfc2616.html#sec-3.3
- BOOST_CHECK(ck.data == "Wed, 03-Oct-2007 16:26:06 GMT");
+ BOOST_CHECK_EQUAL(ck.expires, ex);
   BOOST_CHECK(ck.domain == "example.com");
   BOOST_CHECK(ck.secure == false);
   BOOST_CHECK(ck.http_only == true);
@@ -80,9 +85,10 @@
   cookie_content = "name=value; expires=Wed, 03-Oct-2007 16:26:06 GMT;"
                    " path=/cookie; domain=example.com; secure; HttpOnly";
 
- cookie ck("name", "value", "Wed, 03-Oct-2007 16:26:06 GMT"
- , "/cookie", "example.com", true, true);
- oss.clear();
- oss<< ck;
- BOOST_CHECK(oss.str() == cookie_content);
+ cookie ck2("name", "value", "Wed, 03-Oct-2007 16:26:06 GMT"
+ , "/cookie", "example.com", true, true);
+ oss.flush();
+ oss<< ck2;
+ string ostr(oss.str());
+ BOOST_CHECK_EQUAL(ostr, cookie_content);
 }

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/response.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -1,10 +1,87 @@
 // Test the cgi::response class works as advertised
-#define BOOST_TEST_MAIN
+#define BOOST_TEST_MODULE response_test
 #include <boost/test/unit_test.hpp>
 
 #include "boost/cgi/response.hpp"
 
+using namespace std;
+using namespace boost;
+
+class dummy_request
+{
+public:
+
+ template<typename ConstBufferSequence>
+ size_t write_some(ConstBufferSequence buf, boost::system::error_code ec)
+ {
+ return write_some(buf);
+ }
+
+ template<typename ConstBufferSequence>
+ size_t write_some(ConstBufferSequence buf)
+ {
+ typedef typename ConstBufferSequence::const_iterator iter;
+ size_t bytes_written = 0;
+
+ for( iter i = buf.begin(), e = buf.end()
+ ; i != e
+ ; ++i )
+ {
+ size_t len( asio::buffer_size(*i) );
+ buffer.append( asio::buffer_cast<const char*>(*i), len );
+ //buffer += b;
+ bytes_written += len;
+ }
+
+ return bytes_written;
+ }
+
+ std::string buffer;
+};
+
 BOOST_AUTO_TEST_CASE( response_test )
 {
- using namespace cgi;
-}
\ No newline at end of file
+ using namespace cgi::common;
+
+ dummy_request req;
+ string s ("Hello, world.");
+ string crlf ("\r\n");
+ string ct ("Content-type: text/non-plain");
+
+ {
+ response resp;
+ resp<< s
+ << content_type("text/non-plain");
+ resp.flush(req);
+
+ BOOST_CHECK( !req.buffer.empty() );
+ BOOST_CHECK_EQUAL( req.buffer, ct + crlf + crlf + s );
+
+ resp<< "...." << double(7.99);
+ resp.send(req);
+ BOOST_CHECK_EQUAL( req.buffer, ct + crlf + crlf + s + "....7.99" );
+
+ req.buffer.clear();
+ BOOST_CHECK( req.buffer.empty() );
+
+ resp.flush(req);
+ BOOST_CHECK_EQUAL( req.buffer, "....7.99" );
+
+ req.buffer.clear();
+ BOOST_CHECK( req.buffer.empty() );
+ } // destroy the response (no good way of clearing it now)
+
+ response resp;
+ resp<< content_type("text/non-plain")
+ << s
+ << header("Some", "other");
+
+ string expected( ct + crlf + "Some: other" + crlf + crlf + s );
+
+ resp.send(req);
+ BOOST_CHECK_EQUAL( req.buffer, expected );
+
+ resp.resend(req); // send it again
+ BOOST_CHECK_EQUAL( req.buffer, expected + expected );
+}
+

Modified: sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/stdio_connection.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/stdio_connection.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/acceptor_work/libs/cgi/test/run/stdio_connection.cpp 2008-03-21 13:02:02 EDT (Fri, 21 Mar 2008)
@@ -4,7 +4,7 @@
 
 int main()
 {
- cgi::stdio_connection conn;
+ cgi::common::connection::stdio conn;
 
   boost::system::error_code ec;
 


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