[complement-svn] SF.net SVN: complement: [1530] trunk/complement/explore/test/mt
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-02-19 11:41:44
|
Revision: 1530 http://svn.sourceforge.net/complement/?rev=1530&view=rev Author: complement Date: 2007-02-19 03:41:40 -0800 (Mon, 19 Feb 2007) Log Message: ----------- test for reuse of name of named object in shared memory segment Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-02-19 09:52:36 UTC (rev 1529) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-02-19 11:41:40 UTC (rev 1530) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/12 11:01:56 ptr> +// -*- C++ -*- Time-stamp: <07/02/19 14:36:01 ptr> /* * Copyright (c) 2006, 2007 @@ -783,6 +783,92 @@ } /* ****************************************************** + */ + +void mt_test::shm_named_obj_more() +{ + enum { + ObjName = 1 + }; + + try { + xmt::shm_name_mgr<1>& nm = seg1.name_mgr(); + + xmt::allocator_shm<xmt::__Condition<true>,1> shm; + + xmt::__Condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); + nm.named( fcnd, ObjName ); + fcnd.set( false ); + + try { + xmt::fork(); + + xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); + xmt::allocator_shm<xmt::__Condition<true>,1> shm_ch; + xmt::__Condition<true>& fcnd_ch = nm_ch.named<xmt::__Condition<true> >( ObjName ); + fcnd_ch.set( true ); + nm_ch.release<xmt::__Condition<true> >( ObjName ); + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + fcnd.try_wait(); + int stat; + BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + } + nm.release<xmt::__Condition<true> >( ObjName ); // fcnd should be destroyed here + + xmt::__Condition<true>& fcnd1 = *new ( shm.allocate( 1 ) ) xmt::__Condition<true>(); + nm.named( fcnd1, ObjName ); // ObjName should be free here + fcnd1.set( false ); + + try { + xmt::fork(); + + xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); + xmt::allocator_shm<xmt::__Condition<true>,1> shm_ch; + xmt::__Condition<true>& fcnd_ch = nm_ch.named<xmt::__Condition<true> >( ObjName ); + fcnd_ch.set( true ); + nm_ch.release<xmt::__Condition<true> >( ObjName ); + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + fcnd1.try_wait(); + int stat; + BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + } + nm.release<xmt::__Condition<true> >( ObjName ); // fcnd should be destroyed here + + xmt::allocator_shm<xmt::__Barrier<true>,1> shm_b; + xmt::__Barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__Barrier<true>(); + + nm.named( b, ObjName ); // ObjName should be free here + + try { + xmt::fork(); + + xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); + xmt::allocator_shm<xmt::__Barrier<true>,1> shm_ch; + xmt::__Barrier<true>& b_ch = nm_ch.named<xmt::__Barrier<true> >( ObjName ); + b_ch.wait(); + nm_ch.release<xmt::__Barrier<true> >( ObjName ); + + exit( 0 ); + } + catch ( xmt::fork_in_parent& child ) { + b.wait(); + int stat; + BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + } + nm.release<xmt::__Barrier<true> >( ObjName ); // barrier should be destroyed here + } + catch ( xmt::shm_bad_alloc& err ) { + BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + } +} + +/* ****************************************************** * Thread pool (aka ThreadMgr) test. * * Start 200 threads under ThreadMgr; check that all threads Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-02-19 09:52:36 UTC (rev 1529) +++ trunk/complement/explore/test/mt/mt_test.h 2007-02-19 11:41:40 UTC (rev 1530) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/09 15:56:27 ptr> +// -*- C++ -*- Time-stamp: <07/02/19 13:21:37 ptr> /* * Copyright (c) 2006, 2007 @@ -33,6 +33,8 @@ void shm_init(); void shm_finit(); + void shm_named_obj_more(); + private: // static xmt::Thread::ret_code thread_entry_call( void * ); // static int x; Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-19 09:52:36 UTC (rev 1529) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-02-19 11:41:40 UTC (rev 1530) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/12 11:24:11 ptr> +// -*- C++ -*- Time-stamp: <07/02/19 13:43:38 ptr> /* * Copyright (c) 2006, 2007 @@ -35,6 +35,7 @@ test_case *shm_alloc_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_alloc, instance ); test_case *fork_shm_tc = BOOST_CLASS_TEST_CASE( &mt_test::fork_shm, instance ); test_case *shm_nm_obj_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_named_obj, instance ); + test_case *shm_nm_obj_more_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_named_obj_more, instance ); test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); @@ -56,6 +57,7 @@ shm_nm_obj_tc->depends_on( fork_shm_tc ); shm_init_tc->depends_on( shm_alloc_tc ); + shm_nm_obj_more_tc->depends_on( shm_init_tc ); shm_finit_tc->depends_on( shm_init_tc ); add( barrier_tc, 0, 2 ); @@ -78,5 +80,6 @@ add( thr_mgr_tc ); add( shm_init_tc ); + add( shm_nm_obj_more_tc ); add( shm_finit_tc ); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |