[complement-svn] SF.net SVN: complement: [1533] trunk/complement/explore/test/sockios
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-02-26 16:38:40
|
Revision: 1533 http://svn.sourceforge.net/complement/?rev=1533&view=rev Author: complement Date: 2007-02-26 08:38:34 -0800 (Mon, 26 Feb 2007) Log Message: ----------- add long reading test Modified Paths: -------------- trunk/complement/explore/test/sockios/sockios_test.cc trunk/complement/explore/test/sockios/sockios_test.h trunk/complement/explore/test/sockios/sockios_test_suite.cc Modified: trunk/complement/explore/test/sockios/sockios_test.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.cc 2007-02-21 17:57:04 UTC (rev 1532) +++ trunk/complement/explore/test/sockios/sockios_test.cc 2007-02-26 16:38:34 UTC (rev 1533) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/07 11:32:06 ptr> +// -*- C++ -*- Time-stamp: <07/02/26 17:18:51 ptr> /* * @@ -622,3 +622,76 @@ BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); } } + +/* ************************************************************ */ + +class LongBlockReader // dummy variant +{ + public: + LongBlockReader( std::sockstream& ); + + void connect( std::sockstream& ); + void close(); + + static xmt::Condition cnd; +}; + +xmt::Condition LongBlockReader::cnd; + +LongBlockReader::LongBlockReader( std::sockstream& s ) +{ + BOOST_REQUIRE( s.good() ); +} + +void LongBlockReader::connect( std::sockstream& s ) +{ + char buf[1024]; + int count = 0; + + for ( int i = 0; i < 1024 * 1024; ++i ) { + s.read( buf, 1024 ); + } + cnd.set( true ); +} + +void LongBlockReader::close() +{ + // pr_lock.lock(); + // BOOST_MESSAGE( "Server: client close connection" ); + // pr_lock.unlock(); +} + +void sockios_test::long_block_read() +{ + LongBlockReader::cnd.set( false ); + + sockmgr_stream_MP<LongBlockReader> srv( ::port ); + + BOOST_REQUIRE( srv.good() ); + + sockstream s; + + s.open( "localhost", ::port ); + + BOOST_REQUIRE( s.good() ); + + char buf[1024]; + + for ( int i = 0; i < 1024 * 1024; ++i ) { + s.write( buf, 1024 ); + } + s.flush(); + + BOOST_CHECK( s.good() ); + + s.close(); + LongBlockReader::cnd.try_wait(); + + srv.close(); + srv.wait(); + + // try { + // } + // catch () { + // } +} Modified: trunk/complement/explore/test/sockios/sockios_test.h =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.h 2007-02-21 17:57:04 UTC (rev 1532) +++ trunk/complement/explore/test/sockios/sockios_test.h 2007-02-26 16:38:34 UTC (rev 1533) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/13 10:23:29 ptr> +// -*- C++ -*- Time-stamp: <07/02/26 15:09:26 ptr> /* * @@ -37,6 +37,7 @@ void sigpipe(); void read0(); void read0_srv(); + void long_block_read(); void srv2_fork(); }; Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-02-21 17:57:04 UTC (rev 1532) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-02-26 16:38:34 UTC (rev 1533) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/07 11:00:07 ptr> +// -*- C++ -*- Time-stamp: <07/02/26 15:33:23 ptr> /* * @@ -47,6 +47,7 @@ test_case *read0_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0, instance ); test_case *read0_srv_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0_srv, instance ); + test_case *long_block_read_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_block_read, instance ); long_msg_tc->depends_on( init_tc ); long_msg_tc->depends_on( ctor_dtor_tc ); @@ -54,6 +55,7 @@ sigpipe_tc->depends_on( init_tc ); read0_tc->depends_on( sigpipe_tc ); read0_srv_tc->depends_on( sigpipe_tc ); + long_block_read_tc->depends_on( init_tc ); finit_tc->depends_on( init_tc ); add( init_tc ); @@ -62,5 +64,6 @@ add( sigpipe_tc ); add( read0_tc, 0, 5 ); add( read0_srv_tc ); + add( long_block_read_tc ); add( finit_tc ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |