Revision: 1512
http://svn.sourceforge.net/complement/?rev=1512&view=rev
Author: complement
Date: 2007-02-06 03:13:17 -0800 (Tue, 06 Feb 2007)
Log Message:
-----------
fix and simplify test
Modified Paths:
--------------
trunk/complement/explore/test/sockios/read0_on_exec.cc
Modified: trunk/complement/explore/test/sockios/read0_on_exec.cc
===================================================================
--- trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-06 10:47:44 UTC (rev 1511)
+++ trunk/complement/explore/test/sockios/read0_on_exec.cc 2007-02-06 11:13:17 UTC (rev 1512)
@@ -188,7 +188,7 @@
void close();
};
-static __Semaphore<true> *sem2;
+static Condition cnd6;
ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s )
{
@@ -198,7 +198,7 @@
BOOST_REQUIRE( s.good() );
pr_lock.unlock();
- sem2->post();
+ cnd6.set( true );
}
void ConnectionProcessor6::connect( std::sockstream& s )
@@ -214,17 +214,12 @@
void test_read0_srv()
{
- const char fname[] = "/tmp/sockios_test.shm";
try {
- xmt::shm_alloc<0> seg;
-
- seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 );
- xmt::allocator_shm<xmt::__Semaphore<true>,0> shm;
-
- sem2 = new ( shm.allocate( 1 ) ) xmt::__Semaphore<true>( 2 );
-
sockmgr_stream_MP<ConnectionProcessor6> srv( ::port );
+ BOOST_CHECK( srv.good() );
+ cnd6.set( false );
+
{
// It should work as before system call...
sockstream s( "localhost", ::port );
@@ -233,11 +228,15 @@
BOOST_CHECK( s.good() );
- sem2->wait();
+ cnd6.try_wait();
}
+ cnd6.set( false );
+
system( "echo > /dev/null" ); // <------ key line
+ BOOST_CHECK( srv.good() );
+
{
// ... as after system call.
sockstream s( "localhost", ::port );
@@ -246,19 +245,13 @@
BOOST_CHECK( s.good() );
- sem2->wait();
+ cnd6.try_wait();
}
BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call
srv.close();
-
srv.wait();
-
- sem2->~__Semaphore<true>();
- shm.deallocate( sem2, 1 );
- seg.deallocate();
- unlink( fname );
}
catch ( xmt::shm_bad_alloc& err ) {
BOOST_CHECK_MESSAGE( false, "error report: " << err.what() );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|