Thread: [complement-svn] SF.net SVN: complement: [1739] trunk/complement/explore/lib/mt
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-09-18 09:31:47
|
Revision: 1739 http://complement.svn.sourceforge.net/complement/?rev=1739&view=rev Author: complement Date: 2007-09-18 02:31:26 -0700 (Tue, 18 Sep 2007) Log Message: ----------- test require sync with main thread, otherwise join may happens BEFORE thread call indeed (!!!) and _rip_id will be bad_thread_id and not joined (hmm, really bug of pthread_create in glibc 2.3.6?). Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/ut/mt_test.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:22:32 UTC (rev 1738) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-09-18 09:31:26 UTC (rev 1739) @@ -8,6 +8,10 @@ * libxmt: version 1.13.0 + * ut/mt_test.cc: test require sync with main thread, otherwise join may + happens BEFORE thread call indeed (!!!) and _rip_id will be bad_thread_id + and not joined (hmm, really bug of pthread_create in glibc 2.3.6?). + 2007-09-05 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: looks like non-POD return from thread is unstable, Modified: trunk/complement/explore/lib/mt/ut/mt_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-18 09:22:32 UTC (rev 1738) +++ trunk/complement/explore/lib/mt/ut/mt_test.cc 2007-09-18 09:31:26 UTC (rev 1739) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/09/05 00:31:04 ptr> +// -*- C++ -*- Time-stamp: <07/09/14 22:10:35 ptr> /* * Copyright (c) 2006, 2007 @@ -46,10 +46,15 @@ static int x = 0; -xmt::Thread::ret_t thread_entry_call( void * ) +xmt::Thread::ret_t thread_entry_call( void *p ) { + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); + b.wait(); + x = 1; + // cerr << "XXX" << endl; + return reinterpret_cast<xmt::Thread::ret_t>(2); } @@ -57,10 +62,19 @@ { EXAM_CHECK( x == 0 ); - xmt::Thread t( thread_entry_call ); + xmt::barrier b; - EXAM_CHECK( reinterpret_cast<int>(t.join()) == 2 ); + xmt::Thread t( thread_entry_call, &b ); + // cerr << t.good() << " " << t.is_join_req() << endl; + + // void *r = t.join(); + + // cerr << r << endl; + b.wait(); + + EXAM_CHECK( reinterpret_cast<int>( t.join() ) == 2 ); + EXAM_CHECK( x == 1 ); return EXAM_RESULT; @@ -83,10 +97,12 @@ xmt::barrier b; xmt::Thread t1( thread2_entry_call, &b ); - xmt::Thread t2( thread2_entry_call, &b ); + // xmt::Thread t2( thread2_entry_call, &b ); - EXAM_CHECK( reinterpret_cast<int>(t2.join()) == 1 ); + // EXAM_CHECK( reinterpret_cast<int>(t2.join()) == 1 ); // std::cerr << t2.join() << std::endl; + b.wait(); + EXAM_CHECK( reinterpret_cast<int>(t1.join()) == 1 ); return EXAM_RESULT; @@ -112,9 +128,10 @@ { xmt::barrier b; - xmt::Thread t1( thread2_entry_call, &b ); + // xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread3_entry_call, &b ); // .join()'s are in Thread's destructors + b.wait(); } return EXAM_RESULT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-03-06 19:48:58
|
Revision: 1830 http://complement.svn.sourceforge.net/complement/?rev=1830&view=rev Author: complement Date: 2008-03-06 11:45:17 -0800 (Thu, 06 Mar 2008) Log Message: ----------- ref to C++ 0x working draft Modified Paths: -------------- trunk/complement/explore/lib/mt/date_time.cc trunk/complement/explore/lib/mt/thread.cc Modified: trunk/complement/explore/lib/mt/date_time.cc =================================================================== --- trunk/complement/explore/lib/mt/date_time.cc 2008-03-06 19:42:31 UTC (rev 1829) +++ trunk/complement/explore/lib/mt/date_time.cc 2008-03-06 19:45:17 UTC (rev 1830) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/02/24 18:58:05 ptr> +// -*- C++ -*- Time-stamp: <08/03/02 14:45:29 ptr> /* * Copyright (c) 2002, 2006-2008 @@ -8,8 +8,8 @@ * * Derived from original <mt/time.h> of 'complement' project * [http://complement.sourceforge.net] - * to make it close to JTC1/SC22/WG21 working draft - * [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html] + * to make it close to JTC1/SC22/WG21 C++ 0x working draft + * [http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2008/n2521.pdf] */ #include <mt/date_time> Modified: trunk/complement/explore/lib/mt/thread.cc =================================================================== --- trunk/complement/explore/lib/mt/thread.cc 2008-03-06 19:42:31 UTC (rev 1829) +++ trunk/complement/explore/lib/mt/thread.cc 2008-03-06 19:45:17 UTC (rev 1830) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/02/25 16:08:25 ptr> +// -*- C++ -*- Time-stamp: <08/03/02 14:54:25 ptr> /* * Copyright (c) 1997-1999, 2002-2008 @@ -11,8 +11,8 @@ * * Derived from original <mt/xmt.h> of 'complement' project * [http://complement.sourceforge.net] - * to make it close to JTC1/SC22/WG21 working draft - * [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html] + * to make it close to JTC1/SC22/WG21 C++ 0x working draft + * [http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2008/n2521.pdf] */ #include <config/feature.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-07-01 14:42:06
|
Revision: 1937 http://complement.svn.sourceforge.net/complement/?rev=1937&view=rev Author: complement Date: 2008-07-01 07:42:03 -0700 (Tue, 01 Jul 2008) Log Message: ----------- fix generation of uid Fix not good: reopen file for every call Modified Paths: -------------- trunk/complement/explore/lib/mt/uid.cc trunk/complement/explore/lib/mt/ut/mt_test_suite.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.h Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-07-01 14:41:48 UTC (rev 1936) +++ trunk/complement/explore/lib/mt/uid.cc 2008-07-01 14:42:03 UTC (rev 1937) @@ -9,7 +9,7 @@ */ #include <mt/uid.h> -#include <mt/xmt.h> +#include <mt/mutex> #include <fstream> #include <sstream> #include <iomanip> @@ -21,6 +21,7 @@ using namespace std; using namespace xmt; +using namespace std::tr2; class __uid_init { @@ -34,21 +35,13 @@ uuid_type __uid_init::_host_id; char __uid_init::_host_id_str[48]; -class __uuid_init -{ - public: - __uuid_init(); +// ifstream _uuid; - static ifstream _uuid; -}; - -ifstream __uuid_init::_uuid; - __uid_init::__uid_init() { static mutex _lk; - scoped_lock lock( _lk ); + lock_guard<mutex> lock( _lk ); ifstream f( "/proc/sys/kernel/random/boot_id" ); string tmp; @@ -93,20 +86,10 @@ >> reinterpret_cast<unsigned&>(_host_id.u.b[15]); } -__uuid_init::__uuid_init() -{ - static mutex _lk; - - scoped_lock lock( _lk ); - - if ( !_uuid.is_open() ) { - _uuid.open( "/proc/sys/kernel/random/uuid" ); - } -} - } // namespace detail using namespace std; +using namespace std::tr2; const char *hostid_str() { @@ -122,15 +105,20 @@ std::string uid_str() { - static detail::__uuid_init _uid; - static mutex _lk; - scoped_lock lock( _lk ); + lock_guard<mutex> lock( _lk ); + // if ( !detail::_uuid.is_open() ) { + // detail::_uuid.open( "/proc/sys/kernel/random/uuid" ); + // } + + ifstream _uuid( "/proc/sys/kernel/random/uuid" ); + std::string tmp; - getline( _uid._uuid, tmp ); + // getline( detail::_uuid, tmp ).clear(); // clear eof bit + getline( _uuid, tmp ); return tmp; } Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-01 14:41:48 UTC (rev 1936) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-01 14:42:03 UTC (rev 1937) @@ -75,6 +75,7 @@ t.add( &mt_test_wg21::barrier, test_wg21, "mt_test_wg21::barrier" ); t.add( &mt_test_wg21::semaphore, test_wg21, "mt_test_wg21::semaphore" ); t.add( &mt_test_wg21::fork, test_wg21, "mt_test_wg21::fork" ); + t.add( &mt_test_wg21::uid, test_wg21, "mt_test_wg21::uid" ); return t.girdle(); }; Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-01 14:41:48 UTC (rev 1936) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-01 14:42:03 UTC (rev 1937) @@ -23,6 +23,10 @@ #include <sys/ipc.h> #include <sys/shm.h> +#include <mt/uid.h> + +#include <string> + int EXAM_IMPL(mt_test_wg21::date_time) { // using namespace std::tr2; @@ -314,3 +318,18 @@ return EXAM_RESULT; } +int EXAM_IMPL(mt_test_wg21::uid) +{ + std::string u1 = xmt::uid_str(); + + EXAM_CHECK( !u1.empty() ); + + std::string u2 = xmt::uid_str(); + + EXAM_CHECK( !u2.empty() ); + + EXAM_CHECK( u1 != u2 ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-01 14:41:48 UTC (rev 1936) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-01 14:42:03 UTC (rev 1937) @@ -25,6 +25,7 @@ int EXAM_DECL(barrier); int EXAM_DECL(semaphore); int EXAM_DECL(fork); + int EXAM_DECL(uid); private: // static xmt::Thread::ret_t thread_entry_call( void * ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-07-02 05:36:40
|
Revision: 1939 http://complement.svn.sourceforge.net/complement/?rev=1939&view=rev Author: complement Date: 2008-07-01 22:36:38 -0700 (Tue, 01 Jul 2008) Log Message: ----------- fix generation of uids; libxmt 2.0.5. Avoid fstream in uid generation: only 'read' need here: it atomic, that's why allow to skip mutexes. In shared memory test use tr2::condition_event_ip and tr2::barrier_ip (extention to wg21 draft). Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/uid.cc trunk/complement/explore/lib/mt/ut/Makefile trunk/complement/explore/lib/mt/ut/Makefile.inc trunk/complement/explore/lib/mt/ut/mt_test_suite.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.h trunk/complement/explore/lib/mt/ut/shm_test.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,3 +1,14 @@ +2008-07-02 Petr Ovtchenkov <pt...@is...> + + * uid.cc: fix generation of uids; + + * mt_test_suite.cc, mt_test_wg21.cc, mt_test_wg21.h: test + for uids; use options for test suite; + + * shm_test.cc: use WG21-style conditionals; + + * libxmt: bump revision to 2.0.5. + 2008-06-30 Petr Ovtchenkov <ye...@ya...> * shm.h: condition_event_ip may be used in shared memory; Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/Makefile.inc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,9 +1,9 @@ -# -*- Makefile -*- Time-stamp: <08/06/30 13:51:45 yeti> +# -*- Makefile -*- Time-stamp: <08/07/02 09:28:02 ptr> LIBNAME = xmt MAJOR = 2 MINOR = 0 -PATCH = 4 +PATCH = 5 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc callstack.cc system_error.cc thread.cc \ date_time.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/uid.cc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <08/06/06 21:23:34 yeti> +// -*- C++ -*- Time-stamp: <08/07/02 08:56:16 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2008 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -10,10 +10,11 @@ #include <mt/uid.h> #include <mt/mutex> -#include <fstream> #include <sstream> #include <iomanip> #include <cstring> +#include <unistd.h> +#include <fcntl.h> namespace xmt { @@ -29,26 +30,28 @@ __uid_init(); static uuid_type _host_id; - static char _host_id_str[48]; // 37 really + char _host_id_str[48]; // 37 really }; uuid_type __uid_init::_host_id; -char __uid_init::_host_id_str[48]; -// ifstream _uuid; +struct __uuid_init +{ + public: + __uuid_init(); + ~__uuid_init(); + int fd; +}; + __uid_init::__uid_init() { - static mutex _lk; + int fd = ::open( "/proc/sys/kernel/random/boot_id", O_RDONLY ); - lock_guard<mutex> lock( _lk ); - ifstream f( "/proc/sys/kernel/random/boot_id" ); + ::read( fd, _host_id_str, 36 ); + _host_id_str[36] = '\0'; + ::close( fd ); - string tmp; - getline( f, tmp ); - strcpy( _host_id_str, tmp.c_str() ); - - stringstream s; s << _host_id_str[0] << _host_id_str[1] << ' ' << _host_id_str[2] << _host_id_str[3] << ' ' @@ -86,6 +89,16 @@ >> reinterpret_cast<unsigned&>(_host_id.u.b[15]); } +__uuid_init::__uuid_init() +{ + fd = ::open( "/proc/sys/kernel/random/uuid", O_RDONLY ); +} + +__uuid_init::~__uuid_init() +{ + ::close( fd ); +} + } // namespace detail using namespace std; @@ -94,7 +107,7 @@ const char *hostid_str() { static detail::__uid_init _uid; - return detail::__uid_init::_host_id_str; + return _uid._host_id_str; } const xmt::uuid_type& hostid() @@ -105,22 +118,13 @@ std::string uid_str() { - static mutex _lk; + static detail::__uuid_init __uuid; - lock_guard<mutex> lock( _lk ); + char buf[36]; - // if ( !detail::_uuid.is_open() ) { - // detail::_uuid.open( "/proc/sys/kernel/random/uuid" ); - // } + ::read( __uuid.fd, buf, 36 ); - ifstream _uuid( "/proc/sys/kernel/random/uuid" ); - - std::string tmp; - - // getline( detail::_uuid, tmp ).clear(); // clear eof bit - getline( _uuid, tmp ); - - return tmp; + return std::string( buf, 36 ); } xmt::uuid_type uid() Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/Makefile 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <08/06/12 15:11:40 ptr> +# -*- Makefile -*- Time-stamp: <08/07/02 09:15:45 ptr> SRCROOT := ../../.. @@ -21,18 +21,18 @@ # endif LIBMT_DIR = ${CoMT_DIR}/lib/mt -# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +LIBMISC_DIR = ${CoMT_DIR}/lib/misc LIBFS_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/filesystem ifeq ($(OSNAME),linux) -release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +release-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -L${LIBMISC_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${LIBMISC_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +dbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -L${LIBMISC_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${LIBMISC_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} ifndef WITHOUT_STLPORT -stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +stldbg-shared: LDFLAGS += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBMISC_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${LIBMISC_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} endif endif @@ -49,10 +49,10 @@ endif -release-shared : LDLIBS = -lxmt -lexam -lboost_fs -dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg +release-shared : LDLIBS = -lxmt -lexam -lmisc -lboost_fs +dbg-shared : LDLIBS = -lxmtg -lexamg -lmiscg -lboost_fsg ifndef WITHOUT_STLPORT -stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg +stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lmiscstlg -lboost_fsstlg endif ifeq ($(OSNAME),freebsd) Modified: trunk/complement/explore/lib/mt/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile.inc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/Makefile.inc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,7 +1,7 @@ -# -*- makefile -*- Time-stamp: <08/03/26 10:12:36 ptr> +# -*- makefile -*- Time-stamp: <08/07/02 09:03:03 ptr> PRGNAME = mt_ut -SRC_CC = unit_test.cc timespec.cc \ +SRC_CC = timespec.cc \ signal-1.cc signal-3.cc \ mt_test.cc shm_test.cc mt_test_suite.cc \ mt_test_wg21.cc Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/03/26 10:12:21 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 09:24:48 ptr> /* * Copyright (c) 2006-2008 @@ -15,6 +15,9 @@ #include <config/feature.h> +#include <misc/opts.h> +#include <string> + int EXAM_DECL(timespec_diff); int EXAM_DECL(signal_1_test); // int EXAM_DECL(signal_2_test); @@ -24,7 +27,7 @@ // int EXAM_DECL( flock_test ); // int EXAM_DECL( lfs_test ); -int EXAM_IMPL(mt_test_suite) +int main( int argc, const char** argv ) { exam::test_suite t( "libxmt test" ); mt_test test; @@ -75,7 +78,58 @@ t.add( &mt_test_wg21::barrier, test_wg21, "mt_test_wg21::barrier" ); t.add( &mt_test_wg21::semaphore, test_wg21, "mt_test_wg21::semaphore" ); t.add( &mt_test_wg21::fork, test_wg21, "mt_test_wg21::fork" ); - t.add( &mt_test_wg21::uid, test_wg21, "mt_test_wg21::uid" ); + uid_test_wg21 test_wg21_uid; + + t.add( &uid_test_wg21::uid, test_wg21_uid, "uid_test_wg21::uid" ); + t.add( &uid_test_wg21::hostid, test_wg21_uid, "uid_test_wg21::hostid" ); + + Opts opts; + + opts.description( "test suite for 'sockios' framework" ); + opts.usage( "[options]" ); + + opts << option<bool>( "print this help message", 'h', "help" ) + << option<bool>( "list all test cases", 'l', "list" ) + << option<std::string>( "run tests by number", 'r', "run" )["0"] + << option<bool>( "print status of tests within test suite", 'v', "verbose" ) + << option<bool>( "trace checks", 't', "trace" ); + + try { + opts.parse( argc, argv ); + } + catch (...) { + opts.help( std::cerr ); + return 1; + } + + if ( opts.is_set( 'h' ) ) { + opts.help( std::cerr ); + return 0; + } + + if ( opts.is_set( 'l' ) ) { + t.print_graph( std::cerr ); + return 0; + } + + if ( opts.is_set( 'v' ) ) { + t.flags( t.flags() | exam::base_logger::verbose ); + } + + if ( opts.is_set( 't' ) ) { + t.flags( t.flags() | exam::base_logger::trace ); + } + + if ( opts.is_set( 'r' ) ) { + std::stringstream ss( opts.get<std::string>( 'r' ) ); + int n; + while ( ss >> n ) { + t.single( n ); + } + + return 0; + } + return t.girdle(); }; Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/03/26 01:53:46 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 09:21:04 ptr> /* * Copyright (c) 2006-2008 @@ -318,18 +318,39 @@ return EXAM_RESULT; } -int EXAM_IMPL(mt_test_wg21::uid) +int EXAM_IMPL(uid_test_wg21::uid) { std::string u1 = xmt::uid_str(); EXAM_CHECK( !u1.empty() ); + EXAM_CHECK( u1.length() == 36 ); + std::string u2 = xmt::uid_str(); EXAM_CHECK( !u2.empty() ); + EXAM_CHECK( u2.length() == 36 ); + EXAM_CHECK( u1 != u2 ); return EXAM_RESULT; } +int EXAM_IMPL(uid_test_wg21::hostid) +{ + std::string u1 = xmt::hostid_str(); + + EXAM_CHECK( !u1.empty() ); + + EXAM_CHECK( u1.length() == 36 ); + + std::string u2 = xmt::hostid_str(); + + EXAM_CHECK( !u2.empty() ); + + EXAM_CHECK( u1 == u2 ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/02/25 12:12:20 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 09:27:26 ptr> /* * Copyright (c) 2006-2008 @@ -14,7 +14,6 @@ #define FIT_EXAM #include <exam/suite.h> -// #include <mt/shm.h> class mt_test_wg21 { @@ -25,11 +24,17 @@ int EXAM_DECL(barrier); int EXAM_DECL(semaphore); int EXAM_DECL(fork); - int EXAM_DECL(uid); private: // static xmt::Thread::ret_t thread_entry_call( void * ); // static int x; }; +class uid_test_wg21 +{ + public: + int EXAM_DECL(uid); + int EXAM_DECL(hostid); +}; + #endif // __MT_TEST_WG21_H Modified: trunk/complement/explore/lib/mt/ut/shm_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/shm_test.cc 2008-07-02 05:36:21 UTC (rev 1938) +++ trunk/complement/explore/lib/mt/ut/shm_test.cc 2008-07-02 05:36:38 UTC (rev 1939) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <08/03/26 10:11:58 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 08:58:02 ptr> /* - * Copyright (c) 2006, 2007 + * Copyright (c) 2006-2008 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 @@ -10,7 +10,7 @@ #include "shm_test.h" -#include <mt/xmt.h> +#include <mt/condition_variable> #include <mt/shm.h> @@ -188,27 +188,29 @@ seg.allocate( fname, 1024, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); xmt::allocator_shm<char,0> shm; - xmt::__condition<true>& fcnd = *new( shm.allocate( sizeof(xmt::__condition<true>) ) ) xmt::__condition<true>(); - fcnd.set( false ); + std::tr2::condition_event_ip& fcnd = *new( shm.allocate( sizeof(std::tr2::condition_event_ip) ) ) std::tr2::condition_event_ip(); + try { xmt::fork(); try { // Child code - fcnd.try_wait(); + if ( fcnd.timed_wait( std::tr2::milliseconds( 800 ) ) ) { + exit( 0 ); + } } catch ( ... ) { } - exit( 0 ); + exit( 1 ); } catch ( xmt::fork_in_parent& child ) { try { EXAM_CHECK( child.pid() > 0 ); - fcnd.set( true ); + fcnd.notify_one(); int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); @@ -224,8 +226,8 @@ catch ( ... ) { } - (&fcnd)->~__condition<true>(); - shm.deallocate( reinterpret_cast<char *>(&fcnd), sizeof(xmt::__condition<true>) ); + (&fcnd)->~__condition_event<true>(); + shm.deallocate( reinterpret_cast<char *>(&fcnd), sizeof(std::tr2::condition_event_ip) ); seg.deallocate(); fs::remove( fname ); } @@ -251,11 +253,10 @@ seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); xmt::shm_name_mgr<0>& nm = seg.name_mgr(); - xmt::allocator_shm<xmt::__condition<true>,0> shm; + xmt::allocator_shm<std::tr2::condition_event_ip,0> shm; - xmt::__condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__condition<true>(); + std::tr2::condition_event_ip& fcnd = *new ( shm.allocate( 1 ) ) std::tr2::condition_event_ip(); nm.named( fcnd, test_Condition_Object ); - fcnd.set( false ); try { xmt::fork(); @@ -276,8 +277,8 @@ } xmt::shm_name_mgr<0>& nm_ch = seg_ch.name_mgr(); - xmt::__condition<true>& fcnd_ch = nm_ch.named<xmt::__condition<true> >( test_Condition_Object ); - fcnd_ch.set( true ); + std::tr2::condition_event_ip& fcnd_ch = nm_ch.named<std::tr2::condition_event_ip>( test_Condition_Object ); + fcnd_ch.notify_one(); } catch ( const xmt::shm_bad_alloc& err ) { EXAM_ERROR_ASYNC_F( err.what(), eflag ); @@ -295,7 +296,7 @@ try { EXAM_CHECK( child.pid() > 0 ); - fcnd.try_wait(); + EXAM_CHECK( fcnd.timed_wait( std::tr2::milliseconds( 800 ) ) ); int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); @@ -313,7 +314,7 @@ EXAM_ERROR( "Fail in fork" ); } - (&fcnd)->~__condition<true>(); + (&fcnd)->~__condition_event<true>(); shm.deallocate( &fcnd, 1 ); seg.deallocate(); fs::remove( fname ); @@ -359,11 +360,10 @@ try { xmt::shm_name_mgr<1>& nm = seg1.name_mgr(); - xmt::allocator_shm<xmt::__condition<true>,1> shm; + xmt::allocator_shm<std::tr2::condition_event_ip,1> shm; - xmt::__condition<true>& fcnd = *new ( shm.allocate( 1 ) ) xmt::__condition<true>(); + std::tr2::condition_event_ip& fcnd = *new ( shm.allocate( 1 ) ) std::tr2::condition_event_ip(); nm.named( fcnd, ObjName ); - fcnd.set( false ); try { xmt::fork(); @@ -372,10 +372,10 @@ try { 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 ); + xmt::allocator_shm<std::tr2::condition_event_ip,1> shm_ch; + std::tr2::condition_event_ip& fcnd_ch = nm_ch.named<std::tr2::condition_event_ip>( ObjName ); + fcnd_ch.notify_one(); + nm_ch.release<std::tr2::condition_event_ip>( ObjName ); } catch ( const std::invalid_argument& err ) { EXAM_ERROR_ASYNC_F( err.what(), eflag ); @@ -383,7 +383,7 @@ exit( eflag ); } catch ( xmt::fork_in_parent& child ) { - fcnd.try_wait(); + EXAM_CHECK( fcnd.timed_wait( std::tr2::milliseconds( 800 ) ) ); int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); if ( WIFEXITED(stat) ) { @@ -392,11 +392,10 @@ EXAM_ERROR( "child interrupted" ); } } - nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here + nm.release<std::tr2::condition_event_ip>( ObjName ); // fcnd should be destroyed here - xmt::__condition<true>& fcnd1 = *new ( shm.allocate( 1 ) ) xmt::__condition<true>(); + std::tr2::condition_event_ip& fcnd1 = *new ( shm.allocate( 1 ) ) std::tr2::condition_event_ip(); nm.named( fcnd1, ObjName ); // ObjName should be free here - fcnd1.set( false ); try { xmt::fork(); @@ -405,10 +404,10 @@ try { 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 ); + xmt::allocator_shm<std::tr2::condition_event_ip,1> shm_ch; + std::tr2::condition_event_ip& fcnd_ch = nm_ch.named<std::tr2::condition_event_ip>( ObjName ); + fcnd_ch.notify_one(); + nm_ch.release<std::tr2::condition_event_ip>( ObjName ); } catch ( const std::invalid_argument& err ) { EXAM_ERROR_ASYNC_F( err.what(), eflag ); @@ -417,7 +416,7 @@ exit( eflag ); } catch ( xmt::fork_in_parent& child ) { - fcnd1.try_wait(); + EXAM_CHECK( fcnd1.timed_wait( std::tr2::milliseconds( 800 ) ) ); int stat = -1; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); if ( WIFEXITED(stat) ) { @@ -426,10 +425,10 @@ EXAM_ERROR( "child interrupted" ); } } - nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here + nm.release<std::tr2::condition_event_ip>( 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>(); + xmt::allocator_shm<std::tr2::barrier_ip,1> shm_b; + std::tr2::barrier_ip& b = *new ( shm_b.allocate( 1 ) ) std::tr2::barrier_ip(); nm.named( b, ObjName ); // ObjName should be free here @@ -439,10 +438,10 @@ int eflag = 0; try { 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 ); + xmt::allocator_shm<std::tr2::barrier_ip,1> shm_ch; + std::tr2::barrier_ip& b_ch = nm_ch.named<std::tr2::barrier_ip>( ObjName ); b_ch.wait(); - nm_ch.release<xmt::__barrier<true> >( ObjName ); + nm_ch.release<std::tr2::barrier_ip>( ObjName ); } catch ( const std::invalid_argument& err ) { EXAM_ERROR_ASYNC_F( err.what(), eflag ); @@ -460,7 +459,7 @@ EXAM_ERROR( "child interrupted" ); } } - nm.release<xmt::__barrier<true> >( ObjName ); // barrier should be destroyed here + nm.release<std::tr2::barrier_ip>( ObjName ); // barrier should be destroyed here } catch ( xmt::shm_bad_alloc& err ) { EXAM_ERROR( err.what() ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-07-02 09:28:17
|
Revision: 1940 http://complement.svn.sourceforge.net/complement/?rev=1940&view=rev Author: complement Date: 2008-07-02 02:28:14 -0700 (Wed, 02 Jul 2008) Log Message: ----------- Merge branch 'master' of /export/hostel/pub/scm/complement Conflicts: complement/explore/lib/mt/ChangeLog complement/explore/lib/mt/uid.cc complement/explore/lib/mt/ut/mt_test_suite.cc complement/explore/lib/mt/ut/mt_test_wg21.cc complement/explore/lib/mt/ut/mt_test_wg21.h complement/explore/lib/mt/ut/shm_test.cc Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/uid.cc trunk/complement/explore/lib/mt/ut/mt_test_suite.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.h trunk/complement/explore/lib/mt/ut/shm_test.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,5 +1,7 @@ 2008-07-02 Petr Ovtchenkov <pt...@is...> + * uid.cc: fix wrong type cast; + * uid.cc: fix generation of uids; * mt_test_suite.cc, mt_test_wg21.cc, mt_test_wg21.h: test Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/uid.cc 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 08:56:16 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 13:15:01 yeti> /* * Copyright (c) 2006, 2008 @@ -71,22 +71,10 @@ << _host_id_str[34] << _host_id_str[35]; s >> hex - >> reinterpret_cast<unsigned&>(_host_id.u.b[0]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[1]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[2]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[3]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[4]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[5]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[6]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[7]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[8]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[9]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[10]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[11]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[12]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[13]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[14]) - >> reinterpret_cast<unsigned&>(_host_id.u.b[15]); + >> _host_id.u.b[0] >> _host_id.u.b[1] >> _host_id.u.b[2] >> _host_id.u.b[3] + >> _host_id.u.b[4] >> _host_id.u.b[5] >> _host_id.u.b[6] >> _host_id.u.b[7] + >> _host_id.u.b[8] >> _host_id.u.b[9] >> _host_id.u.b[10] >> _host_id.u.b[11] + >> _host_id.u.b[12] >> _host_id.u.b[13] >> _host_id.u.b[14] >> _host_id.u.b[15]; } __uuid_init::__uuid_init() @@ -99,6 +87,16 @@ ::close( fd ); } +__uuid_init::__uuid_init() +{ + fd = ::open( "/proc/sys/kernel/random/uuid", O_RDONLY ); +} + +__uuid_init::~__uuid_init() +{ + ::close( fd ); +} + } // namespace detail using namespace std; @@ -151,22 +149,10 @@ << tmp[34] << tmp[35]; s >> hex - >> reinterpret_cast<unsigned&>(id.u.b[0]) - >> reinterpret_cast<unsigned&>(id.u.b[1]) - >> reinterpret_cast<unsigned&>(id.u.b[2]) - >> reinterpret_cast<unsigned&>(id.u.b[3]) - >> reinterpret_cast<unsigned&>(id.u.b[4]) - >> reinterpret_cast<unsigned&>(id.u.b[5]) - >> reinterpret_cast<unsigned&>(id.u.b[6]) - >> reinterpret_cast<unsigned&>(id.u.b[7]) - >> reinterpret_cast<unsigned&>(id.u.b[8]) - >> reinterpret_cast<unsigned&>(id.u.b[9]) - >> reinterpret_cast<unsigned&>(id.u.b[10]) - >> reinterpret_cast<unsigned&>(id.u.b[11]) - >> reinterpret_cast<unsigned&>(id.u.b[12]) - >> reinterpret_cast<unsigned&>(id.u.b[13]) - >> reinterpret_cast<unsigned&>(id.u.b[14]) - >> reinterpret_cast<unsigned&>(id.u.b[15]); + >> id.u.b[0] >> id.u.b[1] >> id.u.b[2] >> id.u.b[3] + >> id.u.b[4] >> id.u.b[5] >> id.u.b[6] >> id.u.b[7] + >> id.u.b[8] >> id.u.b[9] >> id.u.b[10] >> id.u.b[11] + >> id.u.b[12] >> id.u.b[13] >> id.u.b[14] >> id.u.b[15]; return id; } Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 09:24:48 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 13:01:53 yeti> /* * Copyright (c) 2006-2008 @@ -81,8 +81,10 @@ uid_test_wg21 test_wg21_uid; - t.add( &uid_test_wg21::uid, test_wg21_uid, "uid_test_wg21::uid" ); - t.add( &uid_test_wg21::hostid, test_wg21_uid, "uid_test_wg21::hostid" ); + t.add( &uid_test_wg21::uid, test_wg21_uid, "uid_test_wg21::uid", + t.add( &uid_test_wg21::uidstr, test_wg21_uid, "uid_test_wg21::uidstr" ) ); + t.add( &uid_test_wg21::hostid, test_wg21_uid, "uid_test_wg21::hostid", + t.add( &uid_test_wg21::hostidstr, test_wg21_uid, "uid_test_wg21::hostidstr" ) ); Opts opts; Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 09:21:04 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 13:00:38 yeti> /* * Copyright (c) 2006-2008 @@ -318,7 +318,7 @@ return EXAM_RESULT; } -int EXAM_IMPL(uid_test_wg21::uid) +int EXAM_IMPL(uid_test_wg21::uidstr) { std::string u1 = xmt::uid_str(); @@ -337,7 +337,7 @@ return EXAM_RESULT; } -int EXAM_IMPL(uid_test_wg21::hostid) +int EXAM_IMPL(uid_test_wg21::hostidstr) { std::string u1 = xmt::hostid_str(); @@ -354,3 +354,22 @@ return EXAM_RESULT; } +int EXAM_IMPL(uid_test_wg21::hostid) +{ + xmt::uuid_type u1 = xmt::hostid(); + xmt::uuid_type u2 = xmt::hostid(); + + EXAM_CHECK( u1 == u2 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(uid_test_wg21::uid) +{ + xmt::uuid_type u1 = xmt::uid(); + xmt::uuid_type u2 = xmt::uid(); + + EXAM_CHECK( u1 != u2 ); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 09:27:26 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 12:59:27 yeti> /* * Copyright (c) 2006-2008 @@ -33,7 +33,9 @@ class uid_test_wg21 { public: + int EXAM_DECL(uidstr); int EXAM_DECL(uid); + int EXAM_DECL(hostidstr); int EXAM_DECL(hostid); }; Modified: trunk/complement/explore/lib/mt/ut/shm_test.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/shm_test.cc 2008-07-02 05:36:38 UTC (rev 1939) +++ trunk/complement/explore/lib/mt/ut/shm_test.cc 2008-07-02 09:28:14 UTC (rev 1940) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 08:58:02 ptr> +// -*- C++ -*- Time-stamp: <08/07/02 13:05:03 yeti> /* * Copyright (c) 2006-2008 @@ -336,7 +336,13 @@ seg1.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); } catch ( xmt::shm_bad_alloc& err ) { - EXAM_ERROR_ASYNC( err.what() ); + try { + seg1.allocate( fname1, 4*4096, 0, 0660 ); + } + catch ( xmt::shm_bad_alloc& err2 ) { + EXAM_ERROR_ASYNC( err2.what() ); + unlink( fname1 ); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-07-07 10:31:05
|
Revision: 1944 http://complement.svn.sourceforge.net/complement/?rev=1944&view=rev Author: complement Date: 2008-07-07 03:30:59 -0700 (Mon, 07 Jul 2008) Log Message: ----------- fixed bad conversion from string to binary for all uids; libxmt 2.0.7 Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/uid.cc trunk/complement/explore/lib/mt/ut/mt_test_suite.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc trunk/complement/explore/lib/mt/ut/mt_test_wg21.h Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-07-07 10:30:59 UTC (rev 1944) @@ -3,8 +3,13 @@ * uid.cc, uid.h: convert uid to string; output uid to ostream; - * libxmt: bump revision to 2.0.6. + * libxmt: bump revision to 2.0.6; + * uid.cc: fixed bad conversion from string form to binary + for all uids; + + * libxmt: bump revision to 2.0.7. + 2008-07-02 Petr Ovtchenkov <pt...@is...> * uid.cc: fix wrong type cast; Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/Makefile.inc 2008-07-07 10:30:59 UTC (rev 1944) @@ -3,7 +3,7 @@ LIBNAME = xmt MAJOR = 2 MINOR = 0 -PATCH = 6 +PATCH = 7 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc callstack.cc system_error.cc thread.cc \ date_time.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/uid.cc 2008-07-07 10:30:59 UTC (rev 1944) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/07 04:14:12 ptr> +// -*- C++ -*- Time-stamp: <08/07/07 14:19:23 yeti> /* * Copyright (c) 2006, 2008 @@ -25,13 +25,22 @@ { std::ios_base::fmtflags f = s.flags( 0 ); s << hex << setfill('0') - << setw(2) << uid.u.b[0] << setw(2) << uid.u.b[1] << setw(2) << uid.u.b[2] << setw(2) << uid.u.b[3] << '-' - << setw(2) << uid.u.b[4] << setw(2) << uid.u.b[5] << '-' - << setw(2) << uid.u.b[6] << setw(2) << uid.u.b[7] << '-' - << setw(2) << uid.u.b[8] << setw(2) << uid.u.b[9] << '-' - << setw(2) << uid.u.b[10] << setw(2) << uid.u.b[11] - << setw(2) << uid.u.b[12] << setw(2) << uid.u.b[13] - << setw(2) << uid.u.b[14] << setw(2) << uid.u.b[15]; + << setw(2) << static_cast<unsigned>(uid.u.b[0]) + << setw(2) << static_cast<unsigned>(uid.u.b[1]) + << setw(2) << static_cast<unsigned>(uid.u.b[2]) + << setw(2) << static_cast<unsigned>(uid.u.b[3]) << '-' + << setw(2) << static_cast<unsigned>(uid.u.b[4]) + << setw(2) << static_cast<unsigned>(uid.u.b[5]) << '-' + << setw(2) << static_cast<unsigned>(uid.u.b[6]) + << setw(2) << static_cast<unsigned>(uid.u.b[7]) << '-' + << setw(2) << static_cast<unsigned>(uid.u.b[8]) + << setw(2) << static_cast<unsigned>(uid.u.b[9]) << '-' + << setw(2) << static_cast<unsigned>(uid.u.b[10]) + << setw(2) << static_cast<unsigned>(uid.u.b[11]) + << setw(2) << static_cast<unsigned>(uid.u.b[12]) + << setw(2) << static_cast<unsigned>(uid.u.b[13]) + << setw(2) << static_cast<unsigned>(uid.u.b[14]) + << setw(2) << static_cast<unsigned>(uid.u.b[15]); s.flags( f ); return s; @@ -89,12 +98,30 @@ << _host_id_str[30] << _host_id_str[31] << ' ' << _host_id_str[32] << _host_id_str[33] << ' ' << _host_id_str[34] << _host_id_str[35]; - - s >> hex - >> _host_id.u.b[0] >> _host_id.u.b[1] >> _host_id.u.b[2] >> _host_id.u.b[3] - >> _host_id.u.b[4] >> _host_id.u.b[5] >> _host_id.u.b[6] >> _host_id.u.b[7] - >> _host_id.u.b[8] >> _host_id.u.b[9] >> _host_id.u.b[10] >> _host_id.u.b[11] - >> _host_id.u.b[12] >> _host_id.u.b[13] >> _host_id.u.b[14] >> _host_id.u.b[15]; + + s >> hex; + + unsigned v[16]; + + s >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7] + >> v[8] >> v[9] >> v[10] >> v[11] >> v[12] >> v[13] >> v[14] >> v[15]; + + _host_id.u.b[0] = v[0]; + _host_id.u.b[1] = v[1]; + _host_id.u.b[2] = v[2]; + _host_id.u.b[3] = v[3]; + _host_id.u.b[4] = v[4]; + _host_id.u.b[5] = v[5]; + _host_id.u.b[6] = v[6]; + _host_id.u.b[7] = v[7]; + _host_id.u.b[8] = v[8]; + _host_id.u.b[9] = v[9]; + _host_id.u.b[10] = v[10]; + _host_id.u.b[11] = v[11]; + _host_id.u.b[12] = v[12]; + _host_id.u.b[13] = v[13]; + _host_id.u.b[14] = v[14]; + _host_id.u.b[15] = v[15]; } } @@ -167,12 +194,30 @@ << tmp[32] << tmp[33] << ' ' << tmp[34] << tmp[35]; - s >> hex - >> id.u.b[0] >> id.u.b[1] >> id.u.b[2] >> id.u.b[3] - >> id.u.b[4] >> id.u.b[5] >> id.u.b[6] >> id.u.b[7] - >> id.u.b[8] >> id.u.b[9] >> id.u.b[10] >> id.u.b[11] - >> id.u.b[12] >> id.u.b[13] >> id.u.b[14] >> id.u.b[15]; + s >> hex; + unsigned v[16]; + + s >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7] + >> v[8] >> v[9] >> v[10] >> v[11] >> v[12] >> v[13] >> v[14] >> v[15]; + + id.u.b[0] = v[0]; + id.u.b[1] = v[1]; + id.u.b[2] = v[2]; + id.u.b[3] = v[3]; + id.u.b[4] = v[4]; + id.u.b[5] = v[5]; + id.u.b[6] = v[6]; + id.u.b[7] = v[7]; + id.u.b[8] = v[8]; + id.u.b[9] = v[9]; + id.u.b[10] = v[10]; + id.u.b[11] = v[11]; + id.u.b[12] = v[12]; + id.u.b[13] = v[13]; + id.u.b[14] = v[14]; + id.u.b[15] = v[15]; + return id; } Modified: trunk/complement/explore/lib/mt/ut/mt_test_suite.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/ut/mt_test_suite.cc 2008-07-07 10:30:59 UTC (rev 1944) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 13:01:53 yeti> +// -*- C++ -*- Time-stamp: <08/07/07 13:15:01 yeti> /* * Copyright (c) 2006-2008 @@ -83,8 +83,9 @@ t.add( &uid_test_wg21::uid, test_wg21_uid, "uid_test_wg21::uid", t.add( &uid_test_wg21::uidstr, test_wg21_uid, "uid_test_wg21::uidstr" ) ); - t.add( &uid_test_wg21::hostid, test_wg21_uid, "uid_test_wg21::hostid", - t.add( &uid_test_wg21::hostidstr, test_wg21_uid, "uid_test_wg21::hostidstr" ) ); + t.add( &uid_test_wg21::uidconv, test_wg21_uid, "uid_test_wg21::uidconv", + t.add( &uid_test_wg21::hostid, test_wg21_uid, "uid_test_wg21::hostid", + t.add( &uid_test_wg21::hostidstr, test_wg21_uid, "uid_test_wg21::hostidstr" ) ) ); Opts opts; Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.cc 2008-07-07 10:30:59 UTC (rev 1944) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 13:00:38 yeti> +// -*- C++ -*- Time-stamp: <08/07/07 14:23:07 yeti> /* * Copyright (c) 2006-2008 @@ -18,6 +18,7 @@ #include <typeinfo> #include <iostream> +#include <sstream> #include <sys/wait.h> #include <sys/ipc.h> @@ -385,3 +386,19 @@ return EXAM_RESULT; } + +int EXAM_IMPL(uid_test_wg21::uidconv) +{ + xmt::uuid_type u1 = xmt::hostid(); + std::string u2 = xmt::hostid_str(); + + EXAM_CHECK( static_cast<std::string>(u1) == u2 ); // <-- conversion to string + + std::stringstream s; + + s << u1; + + EXAM_CHECK( s.str() == u2 ); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/mt/ut/mt_test_wg21.h =================================================================== --- trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-07 06:39:32 UTC (rev 1943) +++ trunk/complement/explore/lib/mt/ut/mt_test_wg21.h 2008-07-07 10:30:59 UTC (rev 1944) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/07/02 12:59:27 yeti> +// -*- C++ -*- Time-stamp: <08/07/07 13:10:54 yeti> /* * Copyright (c) 2006-2008 @@ -37,6 +37,7 @@ int EXAM_DECL(uid); int EXAM_DECL(hostidstr); int EXAM_DECL(hostid); + int EXAM_DECL(uidconv); }; #endif // __MT_TEST_WG21_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |