Thread: [complement-svn] SF.net SVN: complement: [1617] trunk/complement/explore (Page 3)
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-07-17 06:29:47
|
Revision: 1617 http://svn.sourceforge.net/complement/?rev=1617&view=rev Author: complement Date: 2007-07-16 23:29:46 -0700 (Mon, 16 Jul 2007) Log Message: ----------- was introduced stack of test suites, functions for asynchronous checks; add macros for asynchronous checkes [in case when point can't be unambiguously associated with some test case] Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/suite.cc Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/include/exam/suite.h 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 23:07:02 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 09:47:24 ptr> #ifndef __suite_h #define __suite_h @@ -6,6 +6,7 @@ #include <iostream> #include <sstream> #include <map> +#include <stack> #include <boost/graph/adjacency_list.hpp> #include <string> #include <exception> @@ -205,7 +206,10 @@ void report( const char *, int, bool, const char * ); base_logger *set_global_logger( base_logger * ); base_logger *set_logger( base_logger * ); + void set_fail(); + static test_suite& top(); + private: enum { pass = 0, @@ -226,6 +230,7 @@ }; typedef std::map<vertex_t,test_case_collect> test_case_map_type; + int _last_state; test_case_map_type _test; base_logger::stat _stat; std::string _suite_name; @@ -233,6 +238,8 @@ static int _root_func( test_suite *, int = 0 ); static base_logger *logger; + + static std::stack<test_suite *> _stack; }; template <class TC> @@ -300,19 +307,25 @@ # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT __exam_counter # define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_CHECK_ASYNC(C) if ( !(C) ) { exam::test_suite::top().report( __FILE__, __LINE__, false, #C ); exam::test_suite::top().set_fail(); } else exam::test_suite::top().report( __FILE__, __LINE__, true, #C ) # define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) +# define EXAM_MESSAGE_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, true, M ) # define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) # define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 # define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 +# define EXAM_ERROR_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, false, M ); exam::test_suite::top().set_fail() #else # define EXAM_IMPL(F) F( exam::test_suite *, int ) # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT 0 # define EXAM_CHECK(C) +# define EXAM_CHECK_ASYNC(C) # define EXAM_MESSAGE(M) +# define EXAM_MESSAGE_ASYNC(M) # define EXAM_REQUIRE(C) # define EXAM_FAIL(M) # define EXAM_ERROR(M) +# define EXAM_ERROR_ASYNC(M) #endif Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,5 +1,9 @@ 2007-07-17 Petr Ovtchenkov <pt...@is...> + * suite.h, suite.cc: was introduced stack of test suites, functions + for asynchronous checks; add macros for asynchronous checkes + [in case when point can't be unambiguously associated with some test case]; + * suite.h, suite.cc: added multiple dependencies; * ut/exam_test_suite.cc, ut/exam_test_suite.h, ut/dummy_test.cc: Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 00:36:02 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 10:03:02 ptr> #include <exam/suite.h> #include <boost/graph/breadth_first_search.hpp> @@ -101,26 +101,33 @@ test_suite::test_suite( const string& name ) : root( add_vertex( white_color, g ) ), + _last_state( 0 ), _suite_name( name ), local_logger( logger ) { testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + + _stack.push( this ); } test_suite::test_suite( const char *name ) : root( add_vertex( white_color, g ) ), + _last_state( 0 ), _suite_name( name ), local_logger( logger ) { testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + + _stack.push( this ); } test_suite::~test_suite() { + _stack.pop(); for ( test_case_map_type::iterator i = _test.begin(); i != _test.end(); ++i ) { delete i->second.tc; } @@ -193,10 +200,25 @@ return local_logger->flags( f ); } +void test_suite::set_fail() +{ + _last_state = fail; +} + trivial_logger __trivial_logger_inst( cerr ); base_logger *test_suite::logger = &__trivial_logger_inst; +stack<test_suite *> test_suite::_stack; +test_suite& test_suite::top() +{ + if ( _stack.empty() ) { + throw runtime_error( "stack of test suites empty" ); + } + + return *_stack.top(); +} + base_logger *test_suite::set_global_logger( base_logger *new_logger ) { base_logger *tmp = logger; @@ -225,8 +247,15 @@ ++_stat.total; if ( _test[v].state == 0 ) { if ( (*_test[v].tc)( this, 0 ) == 0 ) { - ++_stat.passed; - local_logger->tc( base_logger::pass, _test[v].name ); + if ( _last_state == 0 ) { + ++_stat.passed; + local_logger->tc( base_logger::pass, _test[v].name ); + } else { + _test[v].state = fail; + ++_stat.failed; + local_logger->tc( base_logger::fail, _test[v].name ); + _last_state = 0; + } } else { _test[v].state = fail; ++_stat.failed; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 06:29:41
|
Revision: 1620 http://svn.sourceforge.net/complement/?rev=1620&view=rev Author: complement Date: 2007-07-17 23:29:40 -0700 (Tue, 17 Jul 2007) Log Message: ----------- boost unit test framework replaced by exam Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/test/sockios/ConnectionProcessor.cc trunk/complement/explore/test/sockios/ConnectionProcessor.h trunk/complement/explore/test/sockios/Makefile trunk/complement/explore/test/sockios/Makefile.inc trunk/complement/explore/test/sockios/bytes_in_socket.cc trunk/complement/explore/test/sockios/bytes_in_socket2.cc trunk/complement/explore/test/sockios/client-mw.cc trunk/complement/explore/test/sockios/client-mw.h trunk/complement/explore/test/sockios/client-wc.cc trunk/complement/explore/test/sockios/client-wc.h trunk/complement/explore/test/sockios/close_socket.cc trunk/complement/explore/test/sockios/message.cc trunk/complement/explore/test/sockios/message.h trunk/complement/explore/test/sockios/names.cc 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 trunk/complement/explore/test/sockios/sockios_test_suite.h trunk/complement/explore/test/sockios/unit_test.cc Removed Paths: ------------- trunk/complement/explore/test/sockios/client.cc trunk/complement/explore/test/sockios/client.h Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,3 +1,7 @@ +2007-07-17 Petr Ovtchenkov <pt...@is...> + + * test/mt: boost unit test framework was replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libxmt: version 1.11.0 Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,3 +1,7 @@ +2007-07-18 Petr Ovtchenkov <pt...@is...> + + * test/sockios: boost unit test framework replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libsockios: Version 1.12.0 Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,95 +1,113 @@ -// -*- C++ -*- Time-stamp: <06/07/08 00:13:31 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:17:29 ptr> /* * - * Copyright (c) 2002, 2003, 2005 + * Copyright (c) 2002, 2003, 2005, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include "ConnectionProcessor.h" #include <string> #include "message.h" +#include <sockios/sockmgr.h> + using namespace std; ConnectionProcessor::ConnectionProcessor( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt } void ConnectionProcessor::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); string msg; getline( s, msg ); - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } +// ****************** +int EXAM_IMPL(trivial_sockios_test::simple) +{ +#ifndef __FIT_NO_POLL + + std::sockmgr_stream_MP<ConnectionProcessor> srv( port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + std::sockstream sock( "localhost", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +// ****************** + ConnectionProcessor2::ConnectionProcessor2( std::sockstream& s ) : count( 0 ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt } void ConnectionProcessor2::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); string msg; @@ -97,46 +115,34 @@ switch ( count ) { case 0: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; case 1: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message1 ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message1 ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp1 << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; case 2: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message2 ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message2 ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp2 << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; default: - BOOST_ERROR( "Unexpected connection! count not 0, 1, 2!" ); + EXAM_ERROR_ASYNC( "Unexpected connection! count not 0, 1, 2!" ); break; } @@ -147,7 +153,5 @@ void ConnectionProcessor2::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.h =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,20 +1,12 @@ -// -*- C++ -*- Time-stamp: <06/07/08 00:13:11 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:08:07 ptr> /* * - * Copyright (c) 2002, 2005 + * Copyright (c) 2002, 2005, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __ConnectionProcessor_h @@ -41,6 +33,12 @@ void close(); }; +class trivial_sockios_test +{ + public: + int EXAM_DECL(simple); +}; + class ConnectionProcessor2 // { public: Modified: trunk/complement/explore/test/sockios/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/Makefile 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <03/08/15 12:46:45 ptr> +# -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -8,17 +8,19 @@ INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +DEFS += -D__FIT_EXAM LIBMT_DIR = ${CoMT_DIR}/lib/mt LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios -LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif -release-shared : LDLIBS = -lxmt -lsockios -lboost_test_utf -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lboost_test_utfstlg -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lboost_test_utfg +release-shared : LDLIBS = -lxmt -lsockios -lexam +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Modified: trunk/complement/explore/test/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/test/sockios/Makefile.inc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/Makefile.inc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/02/07 10:26:26 ptr> +# -*- makefile -*- Time-stamp: <07/07/18 08:37:31 ptr> PRGNAME = sockios_ut -SRC_CC = unit_test.cc ConnectionProcessor.cc message.cc client.cc client-mw.cc \ +SRC_CC = ConnectionProcessor.cc message.cc client-mw.cc \ client-wc.cc close_socket.cc bytes_in_socket.cc bytes_in_socket2.cc \ - names.cc sockios_test.cc sockios_test_suite.cc + names.cc sockios_test.cc sockios_test_suite.cc unit_test.cc Modified: trunk/complement/explore/test/sockios/bytes_in_socket.cc =================================================================== --- trunk/complement/explore/test/sockios/bytes_in_socket.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/bytes_in_socket.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:35:39 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:32:22 ptr> /* * @@ -17,10 +17,8 @@ * in supporting documentation. */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -41,7 +39,6 @@ */ extern int port; -extern xmt::mutex pr_lock; static condition cnd; @@ -56,11 +53,9 @@ ConnectionProcessor4::ConnectionProcessor4( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); #if 0 /* @@ -74,11 +69,9 @@ char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); - BOOST_CHECK( c == '0' ); + EXAM_CHECK( c == '0' ); #endif } @@ -86,43 +79,35 @@ { static int count = 0; - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); if ( count++ == 0 ) { - BOOST_CHECK( c == '0' ); + EXAM_CHECK_ASYNC( c == '0' ); } else { cnd.set( true ); - BOOST_CHECK( c == '3' ); + EXAM_CHECK_ASYNC( c == '3' ); } - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor4::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } -void test_more_bytes_in_socket() +int EXAM_IMPL(test_more_bytes_in_socket) { // #ifndef __FIT_NO_POLL cnd.set( false ); @@ -140,4 +125,6 @@ // #else // BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); // #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/bytes_in_socket2.cc =================================================================== --- trunk/complement/explore/test/sockios/bytes_in_socket2.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/bytes_in_socket2.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -2,17 +2,15 @@ /* * - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -32,7 +30,6 @@ */ extern int port; -extern xmt::mutex pr_lock; static condition cnd; @@ -47,11 +44,9 @@ ConnectionProcessor7::ConnectionProcessor7( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // connect( s ); // cerr << "Server see connection\n"; // Be silent, avoid interference @@ -59,48 +54,38 @@ char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); - BOOST_CHECK( c == '0' ); + EXAM_CHECK_ASYNC( c == '0' ); } void ConnectionProcessor7::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); cnd.set( true ); - BOOST_CHECK( c == '3' ); + EXAM_CHECK_ASYNC( c == '3' ); - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor7::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } -void test_more_bytes_in_socket2() +int EXAM_IMPL(test_more_bytes_in_socket2) { // #ifndef __FIT_NO_POLL cnd.set( false ); @@ -118,4 +103,6 @@ // #else // BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); // #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-mw.cc =================================================================== --- trunk/complement/explore/test/sockios/client-mw.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-mw.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -17,7 +17,7 @@ * in supporting documentation. */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include <string> #include <sockios/sockstream> @@ -29,15 +29,13 @@ #include "message.h" using namespace std; -using namespace __impl; +using namespace xmt; -void ClientMassWrite::client_proc() +int EXAM_IMPL(ClientMassWrite::client_proc) { using namespace test_area; - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE( "Client start" ); for ( int i_close = 0; i_close < ni2; ++i_close ) { std::sockstream sock( "localhost", ::port ); @@ -45,11 +43,9 @@ sock.write( bin_buff1, bin_buff1_size ); } - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); + EXAM_CHECK( sock.good() ); } - pr_lock.lock(); - BOOST_MESSAGE( "Client end" ); - pr_lock.unlock(); + EXAM_MESSAGE( "Client end" ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-mw.h =================================================================== --- trunk/complement/explore/test/sockios/client-mw.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-mw.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -20,12 +20,14 @@ #ifndef __ClientMassWrite_h #define __ClientMassWrite_h +#include <exam/suite.h> + // Clients simulator class ClientMassWrite { public: - static void client_proc(); + static int EXAM_DECL(client_proc); }; #endif // __ClientMassWrite_h Modified: trunk/complement/explore/test/sockios/client-wc.cc =================================================================== --- trunk/complement/explore/test/sockios/client-wc.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-wc.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,14 +1,14 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:34:07 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:46:23 ptr> /* - * Copyright (c) 2004, 2006 + * Copyright (c) 2004, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include <string> #include <sockios/sockstream> @@ -93,18 +93,14 @@ cnd.try_wait(); - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client start" ); std::sockstream sock( "localhost", ::port ); string buf; getline( sock, buf ); - pr_lock.lock(); - BOOST_CHECK( buf == "hello" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( buf == "hello" ); // xmt::delay( xmt::timespec( 5, 0 ) ); @@ -120,20 +116,16 @@ char a; sock.read( &a, 1 ); - pr_lock.lock(); - BOOST_CHECK( !sock.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( !sock.good() ); srv_p->close(); - pr_lock.lock(); - BOOST_MESSAGE( "Client end" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client end" ); return rt; } -void srv_close_connection_test() +int EXAM_IMPL(srv_close_connection_test) { Thread srv( server_proc ); cnd_close.set( false ); @@ -141,4 +133,6 @@ client.join(); srv.join(); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-wc.h =================================================================== --- trunk/complement/explore/test/sockios/client-wc.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-wc.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,25 +1,19 @@ -// -*- C++ -*- Time-stamp: <05/12/01 20:30:10 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 09:20:14 ptr> /* * - * Copyright (c) 2004 + * Copyright (c) 2004, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __client_wc_h #define __client_wc_h -void srv_close_connection_test(); +#include <exam/suite.h> +int EXAM_DECL(srv_close_connection_test); + #endif // __client_wc_h Deleted: trunk/complement/explore/test/sockios/client.cc =================================================================== --- trunk/complement/explore/test/sockios/client.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,251 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/07/11 12:56:11 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2005, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#include <boost/test/test_tools.hpp> - -#include <string> -#include <sockios/sockstream> -#include <iostream> -#include <iomanip> -#include <list> -#include <mt/xmt.h> - -#include "client.h" -#include "message.h" - -using namespace std; -using namespace xmt; - -void Client::client1() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_nonlocal_ack() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - - // in_addr hostaddr( findhost( hostname().c_str() ) ); - sockaddr hostaddr; - - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - BOOST_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.any; // .inet.sin_addr; - break; - } - } - BOOST_CHECK( i != ifaces.end() ); - - // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); - std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); - string srv_line; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_nonlocal_nac() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - // server listen only primary host's IP, not 127.0.0.1 - std::sockstream sock( /* "localhost" */ "127.0.0.1", ::port ); - - pr_lock.lock(); - BOOST_CHECK( !sock.is_open() ); - pr_lock.unlock(); -} - -void Client::client_local_ack() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - - std::sockstream sock( "127.0.0.1", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::udp_client1() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port, sock_base::sock_dgram ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_dup() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - - { - std::sockstream sock2; - sock2.attach( sock.rdbuf()->fd() ); - - sock2 << ::message1 << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - BOOST_CHECK( sock2.good() ); - pr_lock.unlock(); - - srv_line.clear(); - getline( sock2, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - BOOST_CHECK( sock2.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp1 ); - - BOOST_MESSAGE( "Subclient close connection (subclient's end of life)" ); - pr_lock.unlock(); - } - - sock << ::message2 << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - srv_line.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp2 ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - - // sock.close(); // no needs, that will done in sock destructor -} Deleted: trunk/complement/explore/test/sockios/client.h =================================================================== --- trunk/complement/explore/test/sockios/client.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,36 +0,0 @@ -// -*- C++ -*- Time-stamp: <05/12/20 09:52:15 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2005 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#ifndef __Client_h -#define __Client_h - -// Clients simulator - -class Client -{ - public: - static void client1(); - static void client_nonlocal_ack(); - static void client_nonlocal_nac(); - static void client_local_ack(); - static void udp_client1(); - static void client_dup(); -}; - -#endif // __Client_h Modified: trunk/complement/explore/test/sockios/close_socket.cc =================================================================== --- trunk/complement/explore/test/sockios/close_socket.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/close_socket.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -17,10 +17,8 @@ * in supporting documentation. */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -41,7 +39,6 @@ */ extern int port; -extern xmt::mutex pr_lock; class ConnectionProcessor3 // dummy variant { @@ -54,11 +51,9 @@ ConnectionProcessor3::ConnectionProcessor3( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); connect( s ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt @@ -68,11 +63,9 @@ void ConnectionProcessor3::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // string msg; @@ -81,26 +74,20 @@ s.write( &c, 1 ); s.flush(); // cnd2.set( true ); - pr_lock.lock(); - // BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + // EXAM_CHECK_EQUAL( msg, ::message ); + EXAM_CHECK_ASYNC( s.good() ); // s << ::message_rsp << endl; // server's response - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor3::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } condition cnd1; @@ -114,22 +101,20 @@ cnd1.set( true ); - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client start" ); - BOOST_REQUIRE( psock->good() ); + EXAM_CHECK_ASYNC( psock->good() ); char c = '0'; psock->read( &c, 1 ); - BOOST_CHECK( c == '1' ); + EXAM_CHECK_ASYNC( c == '1' ); cnd2.set( true ); psock->read( &c, 1 ); return rt; } -void test_client_close_socket() +int EXAM_IMPL(test_client_close_socket) { #ifndef __FIT_NO_POLL sockmgr_stream_MP<ConnectionProcessor3> srv( port ); // start server @@ -156,6 +141,8 @@ srv.close(); // close server, so we don't wait server termination on next line srv.wait(); // Wait for server stop to serve clients connections #else - BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); + EXAM_ERROR( "select-based sockmgr not implemented on this platform" ); #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/message.cc =================================================================== --- trunk/complement/explore/test/sockios/message.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/message.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -33,8 +33,6 @@ int port = 2048; -xmt::mutex pr_lock; - namespace test_area { int bin_buff1_size = 0; Modified: trunk/complement/explore/test/sockios/message.h =================================================================== --- trunk/complement/explore/test/sockios/message.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/message.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -37,10 +37,6 @@ extern int port; -extern xmt::mutex pr_lock; - -#define OUT_MSG(msg) pr_lock.lock(); cerr << msg << endl; pr_lock.unlock() - namespace test_area { extern int bin_buff1_size; Modified: trunk/complement/explore/test/sockios/names.cc =================================================================== --- trunk/complement/explore/test/sockios/names.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/names.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -11,7 +11,7 @@ #include "sockios_test.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> #include <sockios/sockstream> #include <sockios/sockmgr.h> @@ -20,69 +20,74 @@ #include <arpa/inet.h> -using namespace boost::unit_test_framework; using namespace std; /* ************************************************************ */ -void names_sockios_test::hostname_test() +int EXAM_IMPL(names_sockios_test::hostname_test) { unsigned long local = htonl( 0x7f000001 ); // 127.0.0.1 #ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( local, 0x0100007f ); + EXAM_CHECK( local == 0x0100007f ); #endif #ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( local, 0x7f000001 ); + EXAM_CHECK( local == 0x7f000001 ); #endif - BOOST_CHECK_EQUAL( std::hostname( local ), "localhost [127.0.0.1]" ); + EXAM_CHECK( std::hostname( local ) == "localhost [127.0.0.1]" ); #ifdef __unix char buff[1024]; gethostname( buff, 1024 ); - BOOST_CHECK_EQUAL( std::hostname(), buff ); + EXAM_CHECK( std::hostname() == buff ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::service_test() +int EXAM_IMPL(names_sockios_test::service_test) { #ifdef __unix - BOOST_CHECK( std::service( "ftp", "tcp" ) == 21 ); - BOOST_CHECK( std::service( 7, "udp" ) == "echo" ); + EXAM_CHECK( std::service( "ftp", "tcp" ) == 21 ); + EXAM_CHECK( std::service( 7, "udp" ) == "echo" ); #else BOOST_ERROR( "requests for service (/etc/services) not implemented on this platform" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test1() +int EXAM_IMPL(names_sockios_test::hostaddr_test1) { #ifdef __unix in_addr addr = std::findhost( "localhost" ); # ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x0100007f ); + EXAM_CHECK( addr.s_addr == 0x0100007f ); # endif # ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x7f000001 ); + EXAM_CHECK( addr.s_addr == 0x7f000001 ); # endif #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test2() +int EXAM_IMPL(names_sockios_test::hostaddr_test2) { #ifdef __unix list<in_addr> haddrs; @@ -97,16 +102,18 @@ } } - BOOST_CHECK( localhost_found == true ); + EXAM_CHECK( localhost_found == true ); #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test3() +int EXAM_IMPL(names_sockios_test::hostaddr_test3) { #ifdef __unix list<sockaddr> haddrs; @@ -132,9 +139,11 @@ } } - BOOST_CHECK( localhost_found == true ); + EXAM_CHECK( localhost_found == true ); #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/sockios_test.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:33:49 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 09:22:46 ptr> /* * @@ -12,7 +12,7 @@ #include "sockios_test.h" #include "message.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> #include <sockios/sockstream> #include <sockios/sockmgr.h> @@ -21,36 +21,23 @@ #include <sys/wait.h> #include <signal.h> -using namespace boost::unit_test_framework; using namespace std; -const char fname[] = "/tmp/sockios_test.shm"; -xmt::shm_alloc<0> seg; -xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; -xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; - -sockios_test::sockios_test() +sockios_test::sockios_test() : + fname( "/tmp/sockios_test.shm" ) { -} - -sockios_test::~sockios_test() -{ -} - -void sockios_test::init() -{ try { - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + seg.allocate( fname.c_str(), 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); } catch ( const xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } } -void sockios_test::finit() +sockios_test::~sockios_test() { seg.deallocate(); - unlink( fname ); + unlink( fname.c_str() ); } /* ************************************************************ */ @@ -82,7 +69,7 @@ int Cnt::cnt = 0; int Cnt::visits = 0; -void sockios_test::ctor_dtor() +int EXAM_IMPL(sockios_test::ctor_dtor) { // Check, that number of ctors of Cnt is the same as number of called dtors // i.e. all created Cnt was released. @@ -92,18 +79,18 @@ { sockstream s1( "localhost", port ); - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); s1 << "1234" << endl; - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); while ( Cnt::get_visits() == 0 ) { xmt::Thread::yield(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 1 ); + EXAM_CHECK( Cnt::cnt == 1 ); Cnt::lock.unlock(); } @@ -111,13 +98,13 @@ srv.wait(); Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::visits = 0; Cnt::lock.unlock(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); { @@ -127,23 +114,23 @@ sockstream s1( "localhost", port ); sockstream s2( "localhost", port ); - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); - BOOST_CHECK( s2.good() ); - BOOST_CHECK( s2.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); + EXAM_CHECK( s2.good() ); + EXAM_CHECK( s2.is_open() ); s1 << "1234" << endl; s2 << "1234" << endl; - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); - BOOST_CHECK( s2.good() ); - BOOST_CHECK( s2.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); + EXAM_CHECK( s2.good() ); + EXAM_CHECK( s2.is_open() ); while ( Cnt::get_visits() < 2 ) { xmt::Thread::yield(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 2 ); + EXAM_CHECK( Cnt::cnt == 2 ); Cnt::lock.unlock(); } @@ -151,13 +138,15 @@ srv.wait(); Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); + + return EXAM_RESULT; } /* ************************************************************ */ @@ -225,7 +214,7 @@ #endif } -void sockios_test::sigpipe() +int EXAM_IMPL(sockios_test::sigpipe) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -290,8 +279,10 @@ shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ */ @@ -331,7 +322,7 @@ xmt::__condition<true> *long_msg_processor::cnd; -void sockios_test::long_msg() +int EXAM_IMPL(sockios_test::long_msg) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -387,8 +378,10 @@ shm_cnd.deallocate( &srv_cnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ @@ -441,9 +434,9 @@ ConnectionProcessor5::ConnectionProcessor5( std::sockstream& s ) { // pr_lock.lock(); - // BOOST_MESSAGE( "Server seen connection" ); + // EXAM_MESSAGE( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); // pr_lock.unlock(); // cerr << "ConnectionProcessor5::ConnectionProcessor5\n"; @@ -462,7 +455,7 @@ void ConnectionProcessor5::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } @@ -478,15 +471,15 @@ cnd.set( true ); // Note: due to this is another process then main, boost can report // about errors here, but don't count error it in summary, if it occur! - BOOST_CHECK( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line - BOOST_CHECK( buff == 1 ); + EXAM_CHECK_ASYNC( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line + EXAM_CHECK_ASYNC( buff == 1 ); // cerr << "Read pass" << endl; rt.iword = 0; return rt; } -void sockios_test::read0() +int EXAM_IMPL(sockios_test::read0) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -536,7 +529,7 @@ shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } } @@ -558,9 +551,9 @@ ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s ) { // pr_lock.lock(); - // BOOST_MESSAGE( "Server seen connection" ); + // EXAM_MESSAGE( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); // pr_lock.unlock(); cnd.set( true ); @@ -573,16 +566,16 @@ void ConnectionProcessor6::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } -void sockios_test::read0_srv() +int EXAM_IMPL(sockios_test::read0_srv) { try { sockmgr_stream_MP<ConnectionProcessor6> srv( ::port ); - BOOST_CHECK( srv.good() ); + EXAM_CHECK( srv.good() ); ConnectionProcessor6::cnd.set( false ); { @@ -591,7 +584,7 @@ s << "1" << endl; - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); ConnectionProcessor6::cnd.try_wait(); } @@ -600,7 +593,7 @@ system( "echo > /dev/null" ); // <------ key line - BOOST_CHECK( srv.good() ); + EXAM_CHECK( srv.good() ); { // ... as after system call. @@ -608,19 +601,21 @@ s << "1" << endl; - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); ConnectionProcessor6::cnd.try_wait(); } - BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call + EXAM_CHECK( srv.good() ); // server must correctly process interrupt during system call srv.close(); srv.wait(); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ */ @@ -640,7 +635,7 @@ LongBlockReader::LongBlockReader( std::sockstream& s ) { - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); } void LongBlockReader::connect( std::sockstream& s ) @@ -657,23 +652,23 @@ void LongBlockReader::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } -void sockios_test::long_block_read() +int EXAM_IMPL(sockios_test::long_block_read) { LongBlockReader::cnd.set( false ); sockmgr_stream_MP<LongBlockReader> srv( ::port ); - BOOST_REQUIRE( srv.good() ); + EXAM_REQUIRE( srv.good() ); sockstream s; s.open( "localhost", ::port ); - BOOST_REQUIRE( s.good() ); + EXAM_REQUIRE( s.good() ); char buf[1024]; @@ -682,7 +677,7 @@ } s.flush(); - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); s.close(); LongBlockReader::cnd.try_wait(); Modified: trunk/complement/explore/test/sockios/sockios_test.h =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/02/26 15:09:26 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:52:26 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006, 2007 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -12,34 +12,41 @@ #ifndef __sockios_test_h #define __sockios_test_h +#include <exam/suite.h> +#include <mt/shm.h> + struct names_sockios_test { - void hostname_test(); - void service_test(); + int EXAM_DECL(hostname_test); + int EXAM_DECL(service_test); - void hostaddr_test1(); - void hostaddr_test2(); - void hostaddr_test3(); + int EXAM_DECL(hostaddr_test1); + int EXAM_DECL(hostaddr_test2); + int EXAM_DECL(hostaddr_test3); }; -struct sockios_test +class sockios_test { + public: sockios_test(); ~sockios_test(); - void init(); - void finit(); + int EXAM_DECL(ctor_dtor); - void ctor_dtor(); + int EXAM_DECL(long_msg); - void long_msg(); + int EXAM_DECL(sigpipe); + int EXAM_DECL(read0); + int EXAM_DECL(read0_srv); + int EXAM_DECL(long_block_read); - void sigpipe(); - void read0(); - void read0_srv(); - void long_block_read(); + int EXAM_DECL(srv2_fork); - void srv2_fork(); + private: + const std::string fname; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; }; #endif // __sockios_test_h Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/02/26 15:33:23 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:23:40 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006, 2007 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -12,58 +12,386 @@ #include "sockios_test_suite.h" #include "sockios_test.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; +#include <iostream> +#include <list> +#include <mt/xmt.h> +#include <sockios/sockstream> +#include <sockios/sockmgr.h> -sockios_test_suite::sockios_test_suite() : - test_suite( "sockios library test suite" ) +#include "message.h" + +#include "ConnectionProcessor.h" + +#include "client-wc.h" + +using namespace std; + +int EXAM_IMPL(test_client_server_poll_nonlocal_ack) { - boost::shared_ptr<names_sockios_test> names_instance( new names_sockios_test() ); +#ifndef __FIT_NO_POLL + try { - test_case *hostname_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostname_test, names_instance ); - test_case *service_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::service_test, names_instance ); + // Oh, this trick not work well: hostname may be assigned to 127.0.0.1 too... + // I need list of interfaces... - test_case *hostaddr1_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test1, names_instance ); - test_case *hostaddr2_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test2, names_instance ); - test_case *hostaddr3_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test3, names_instance ); + // take primary host IP: + in_addr hostaddr( findhost( hostname().c_str() ) ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); - add( hostname_tc ); - add( service_tc ); + // server not listen localhost, but listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server - add( hostaddr1_tc ); - add( hostaddr2_tc ); - add( hostaddr3_tc ); + EXAM_CHECK( srv.is_open() ); + EXAM_CHECK( srv.good() ); + { + EXAM_MESSAGE( "Client start" ); - boost::shared_ptr<sockios_test> instance( new sockios_test() ); - test_case *init_tc = BOOST_CLASS_TEST_CASE( &sockios_test::init, instance ); - test_case *finit_tc = BOOST_CLASS_TEST_CASE( &sockios_test::finit, instance ); + // in_addr hostaddr( findhost( hostname().c_str() ) ); + sockaddr hostaddr; - test_case *ctor_dtor_tc = BOOST_CLASS_TEST_CASE( &sockios_test::ctor_dtor, instance ); - test_case *long_msg_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_msg, instance ); - test_case *sigpipe_tc = BOOST_CLASS_TEST_CASE( &sockios_test::sigpipe, instance ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); - 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 ); + // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); + std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); + string srv_line; - long_msg_tc->depends_on( init_tc ); - long_msg_tc->depends_on( ctor_dtor_tc ); - sigpipe_tc->depends_on( ctor_dtor_tc ); - 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 ); + EXAM_CHECK( sock.good() ); - add( init_tc ); - add( ctor_dtor_tc ); - add( long_msg_tc ); - add( sigpipe_tc ); - add( read0_tc, 0, 5 ); - add( read0_srv_tc ); - add( long_block_read_tc ); - add( finit_tc ); + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; } + +int EXAM_IMPL(test_client_server_poll_nonlocal_nac) +{ +#ifndef __FIT_NO_POLL + try { + // take primary host IP: + in_addr hostaddr( findhost( hostname().c_str() ) ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); + + // server not listen localhost, but listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + + // in_addr hostaddr( findhost( hostname().c_str() ) ); + sockaddr hostaddr; + + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); + + // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); + std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); + string srv_line; + + EXAM_CHECK( sock.good() ); + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int EXAM_IMPL(test_client_server_poll_local_ack) +{ +#ifndef __FIT_NO_POLL + try { + // server listen localhost (127.0.0.1), but not listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( 0x7f000001, port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + + std::sockstream sock( "127.0.0.1", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int generator_1() +{ + static int i = 0; + + return i++; +} + +#include "client-mw.h" + +int EXAM_IMPL(test_mass_processing_poll) +{ +#ifndef __FIT_NO_POLL + using namespace test_area; + + EXAM_REQUIRE( bin_buff1_size == 0 ); // test integrity of test suite + EXAM_REQUIRE( bin_buff1 == 0 ); // test integrity of test suite + + bin_buff1_size = 48; + bin_buff1 = new char [bin_buff1_size]; + EXAM_REQUIRE( bin_buff1 != 0 ); + generate_n( bin_buff1, bin_buff1_size, generator_1 ); + + ni1 = 10; + ni2 = 5; + + delete bin_buff1; + bin_buff1 = 0; + bin_buff1_size = 0; +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int EXAM_IMPL(test_shared_socket) +{ +#ifndef __FIT_NO_POLL + sockmgr_stream_MP<ConnectionProcessor2> srv( port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + std::sockstream sock( "localhost", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + + { + std::sockstream sock2; + sock2.attach( sock.rdbuf()->fd() ); + + sock2 << ::message1 << endl; + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + srv_line.clear(); + getline( sock2, srv_line ); + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + EXAM_CHECK( srv_line == ::message_rsp1 ); + + EXAM_MESSAGE( "Subclient close connection (subclient's end of life)" ); + } + + ... [truncated message content] |
From: <com...@us...> - 2007-07-18 12:01:46
|
Revision: 1627 http://svn.sourceforge.net/complement/?rev=1627&view=rev Author: complement Date: 2007-07-18 05:01:38 -0700 (Wed, 18 Jul 2007) Log Message: ----------- boost unit test framework replaced by exam Modified Paths: -------------- trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/test/stem/Echo.cc trunk/complement/explore/test/stem/Echo.h trunk/complement/explore/test/stem/Makefile trunk/complement/explore/test/stem/NameService.cc trunk/complement/explore/test/stem/NameService.h trunk/complement/explore/test/stem/Node.cc trunk/complement/explore/test/stem/Node.h trunk/complement/explore/test/stem/NodeDL.h trunk/complement/explore/test/stem/dl/Makefile trunk/complement/explore/test/stem/dl/loadable_stem.cc trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,3 +1,7 @@ +2007-07-18 Petr Ovtchenkov <pt...@is...> + + * test/stem: boost unit test framework replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libstem: library version 4.6.0 Modified: trunk/complement/explore/test/stem/Echo.cc =================================================================== --- trunk/complement/explore/test/stem/Echo.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Echo.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <06/11/29 13:02:34 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -13,10 +13,8 @@ #include <stem/NetTransport.h> #include <stem/EvManager.h> -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - using namespace stem; StEMecho::StEMecho() @@ -83,7 +81,7 @@ void EchoClient::handler1( const stem::Event& ev ) { - BOOST_CHECK( ev.value() == mess ); + EXAM_CHECK_ASYNC( ev.value() == mess ); cnd.set(true); } @@ -131,7 +129,7 @@ void PeerClient::handler1( const stem::Event& ev ) { - BOOST_CHECK( ev.value() == mess ); + EXAM_CHECK( ev.value() == mess ); cnd.set(true); } Modified: trunk/complement/explore/test/stem/Echo.h =================================================================== --- trunk/complement/explore/test/stem/Echo.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Echo.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <07/07/11 21:45:09 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Makefile 2007-07-18 12:01:38 UTC (rev 1627) @@ -10,22 +10,22 @@ include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include LIBMT_DIR = ${CoMT_DIR}/lib/mt LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif -release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf -ldl -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg -ldl -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg -ldl +release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/test/stem/NameService.cc =================================================================== --- trunk/complement/explore/test/stem/NameService.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NameService.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,17 +1,13 @@ // -*- C++ -*- Time-stamp: <06/11/29 10:50:21 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - #include <iostream> #include <functional> #include <iterator> Modified: trunk/complement/explore/test/stem/NameService.h =================================================================== --- trunk/complement/explore/test/stem/NameService.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NameService.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <07/07/11 21:47:37 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/Node.cc =================================================================== --- trunk/complement/explore/test/stem/Node.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Node.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,19 +2,13 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <iostream> - #include "Node.h" using namespace std; Modified: trunk/complement/explore/test/stem/Node.h =================================================================== --- trunk/complement/explore/test/stem/Node.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Node.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,7 +2,7 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/NodeDL.h =================================================================== --- trunk/complement/explore/test/stem/NodeDL.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NodeDL.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,7 +2,7 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/dl/Makefile =================================================================== --- trunk/complement/explore/test/stem/dl/Makefile 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/dl/Makefile 2007-07-18 12:01:38 UTC (rev 1627) @@ -11,7 +11,7 @@ include ${SRCROOT}/Makefiles/gmake/top.mak LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include #LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} Modified: trunk/complement/explore/test/stem/dl/loadable_stem.cc =================================================================== --- trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,17 +2,13 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -// #include <boost/test/unit_test.hpp> - -// using namespace boost::unit_test_framework; - #include "../NodeDL.h" using namespace stem; @@ -33,15 +29,12 @@ NodeDL::~NodeDL() { - // cnd.wait(); } void NodeDL::handler1( const stem::Event& ) { - // std::cerr << "I am here 1\n"; v = 1; cnd.set(true); - // std::cerr << "I am here 2\n"; } void NodeDL::wait() @@ -71,15 +64,12 @@ NewNodeDL::~NewNodeDL() { - // cnd.wait(); } void NewNodeDL::handler1( const stem::Event& ) { - // std::cerr << "I am here 1\n"; v = 1; cnd.set(true); - // std::cerr << "I am here 2\n"; } void NewNodeDL::wait() Modified: trunk/complement/explore/test/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/unit_test.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,17 +1,15 @@ // -*- C++ -*- Time-stamp: <07/07/12 00:48:50 ptr> /* - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <mt/xmt.h> #include <mt/shm.h> @@ -42,29 +40,35 @@ using namespace std; -struct stem_test +class stem_test { + public: + stem_test(); + ~stem_test(); + void shm_init(); void shm_finit(); - void basic1(); - void basic2(); - void basic1new(); - void basic2new(); - void dl(); - void ns(); + int EXAM_DECL(basic1); + int EXAM_DECL(basic2); + int EXAM_DECL(basic1new); + int EXAM_DECL(basic2new); + int EXAM_DECL(dl); + int EXAM_DECL(ns); - void echo(); - void echo_net(); - void net_echo(); - void peer(); - void boring_manager(); + int EXAM_DECL(echo); + int EXAM_DECL(echo_net); + int EXAM_DECL(net_echo); + int EXAM_DECL(peer); + int EXAM_DECL(boring_manager); static xmt::Thread::ret_code thr1( void * ); static xmt::Thread::ret_code thr1new( void * ); + + private: }; -void stem_test::basic1() +int EXAM_IMPL(stem_test::basic1) { Node node( 2000 ); @@ -74,20 +78,24 @@ node.Send( ev ); node.wait(); - BOOST_CHECK_EQUAL( node.v, 1 ); + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; } -void stem_test::basic2() +int EXAM_IMPL(stem_test::basic2) { Node node( 2000 ); xmt::Thread t1( thr1 ); - t1.join(); + EXAM_CHECK( t1.join().iword == 0 ); node.wait(); - BOOST_CHECK_EQUAL( node.v, 1 ); + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; } xmt::Thread::ret_code stem_test::thr1( void * ) @@ -105,7 +113,7 @@ return rt; } -void stem_test::basic1new() +int EXAM_IMPL(stem_test::basic1new) { NewNode *node = new NewNode( 2000 ); @@ -116,11 +124,13 @@ node->wait(); - BOOST_CHECK_EQUAL( node->v, 1 ); + EXAM_CHECK( node->v == 1 ); delete node; + + return EXAM_RESULT; } -void stem_test::basic2new() +int EXAM_IMPL(stem_test::basic2new) { NewNode *node = new NewNode( 2000 ); @@ -129,8 +139,10 @@ t1.join(); node->wait(); - BOOST_CHECK_EQUAL( node->v, 1 ); + EXAM_CHECK( node->v == 1 ); delete node; + + return EXAM_RESULT; } xmt::Thread::ret_code stem_test::thr1new( void * ) @@ -150,24 +162,24 @@ return rt; } -void stem_test::dl() +int EXAM_IMPL(stem_test::dl) { void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= - BOOST_REQUIRE( lh != NULL ); + EXAM_REQUIRE( lh != NULL ); void *(*f)(unsigned); void (*g)(void *); void (*w)(void *); int (*v)(void *); *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); - BOOST_REQUIRE( f != NULL ); + EXAM_REQUIRE( f != NULL ); *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); - BOOST_REQUIRE( g != NULL ); + EXAM_REQUIRE( g != NULL ); *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); - BOOST_REQUIRE( w != NULL ); + EXAM_REQUIRE( w != NULL ); *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); - BOOST_REQUIRE( v != NULL ); + EXAM_REQUIRE( v != NULL ); NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); stem::Event ev( NODE_EV2 ); @@ -175,13 +187,15 @@ node->Send( ev ); w( reinterpret_cast<void *>(node) ); - BOOST_CHECK_EQUAL( v(reinterpret_cast<void *>(node)), 1 ); + EXAM_CHECK( v(reinterpret_cast<void *>(node)) == 1 ); g( reinterpret_cast<void *>(node) ); dlclose( lh ); + + return EXAM_RESULT; } -void stem_test::ns() +int EXAM_IMPL(stem_test::ns) { Node node( 2003, "Node" ); Naming nm; @@ -195,11 +209,11 @@ // this is sample of all inline find: Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "ns" ); - BOOST_CHECK( i->first.hid == xmt::hostid() ); - BOOST_CHECK( i->first.pid == getpid() ); - BOOST_CHECK( i->first.addr == stem::ns_addr ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "ns" ); + EXAM_CHECK( i->first.hid == xmt::hostid() ); + EXAM_CHECK( i->first.pid == getpid() ); + EXAM_CHECK( i->first.addr == stem::ns_addr ); // well, but for few seaches declare and reuse functors: equal_to<string> eq; @@ -210,20 +224,20 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first.addr == 2003 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->first == nm.self_glid() ); - BOOST_CHECK( i->second.length() == 0 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->first == nm.self_glid() ); + EXAM_CHECK( i->second.length() == 0 ); nm.lst.clear(); nm.reset(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( stem::ns_addr ); @@ -234,32 +248,34 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); - BOOST_CHECK( i == nm.lst.end() ); + EXAM_CHECK( i == nm.lst.end() ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first.addr == 2003 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - BOOST_CHECK( i == nm.lst.end() ); + EXAM_CHECK( i == nm.lst.end() ); nm.lst.clear(); nm.reset(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); evname.value() = "No-such-name"; nm.Send( evname ); nm.wait(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); + + return EXAM_RESULT; } -void stem_test::echo() +int EXAM_IMPL(stem_test::echo) { try { sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); @@ -269,8 +285,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery + EXAM_CHECK( zero != stem::badaddr ); + EXAM_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery EchoClient node; @@ -291,6 +307,8 @@ } catch ( ... ) { } + + return EXAM_RESULT; } const char fname[] = "/tmp/stem_test.shm"; @@ -298,23 +316,23 @@ xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; -void stem_test::shm_init() +stem_test::stem_test() { try { seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); } catch ( const xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } } -void stem_test::shm_finit() +stem_test::~stem_test() { seg.deallocate(); unlink( fname ); } -void stem_test::echo_net() +int EXAM_IMPL(stem_test::echo_net) { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); fcnd.set( false ); @@ -329,8 +347,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); // NetTransportMgr should detect external delivery + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery EchoClient node; @@ -360,7 +378,7 @@ fcnd.set( true ); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); srv.close(); srv.wait(); @@ -373,11 +391,13 @@ shm_cnd.deallocate( &fcnd, 1 ); // cerr << "Fine\n"; + + return EXAM_RESULT; } // same as echo_net(), but server in child process -void stem_test::net_echo() +int EXAM_IMPL(stem_test::net_echo) { try { xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); @@ -396,7 +416,7 @@ // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); // echo.manager()->settrs( &std::cerr ); - BOOST_REQUIRE( srv.good() ); + EXAM_CHECK_ASYNC( srv.good() ); c.set( true ); // ok, server listen b.wait(); // server may go away @@ -418,8 +438,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_REQUIRE( mgr.good() ); - BOOST_REQUIRE( zero != stem::badaddr ); + EXAM_REQUIRE( mgr.good() ); + EXAM_REQUIRE( zero != stem::badaddr ); EchoClient node; stem::Event ev( NODE_EV_ECHO ); @@ -436,7 +456,7 @@ b.wait(); // server may go away int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } (&c)->~__condition<true>(); @@ -445,8 +465,10 @@ shm_b.deallocate( &b, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } extern "C" { @@ -456,7 +478,7 @@ } -void stem_test::peer() +int EXAM_IMPL(stem_test::peer) { /* * Scheme: @@ -515,9 +537,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); - BOOST_CHECK( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -527,13 +549,13 @@ stem::gaddr_type ga( c1.manager()->reflect( zero ) ); - BOOST_CHECK( ga.addr == 0 ); - BOOST_CHECK( ga.pid != -1 ); + EXAM_CHECK_ASYNC( ga.addr == 0 ); + EXAM_CHECK_ASYNC( ga.pid != -1 ); ga.addr = stem::ns_addr; // this will be global address of ns of the same process // as zero - BOOST_CHECK( c1.manager()->reflect( ga ) != stem::badaddr ); + EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( c1.manager()->reflect( ga ) ); @@ -551,8 +573,8 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); } while ( i == nm.lst.end() ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "c2@here" ); + EXAM_CHECK_ASYNC( i != nm.lst.end() ); + EXAM_CHECK_ASYNC( i->second == "c2@here" ); stem::addr_type pa = c1.manager()->reflect( i->first ); if ( pa == stem::badaddr ) { // unknown yet @@ -563,7 +585,7 @@ } } - BOOST_CHECK( pa != stem::badaddr ); + EXAM_CHECK_ASYNC( pa != stem::badaddr ); if ( pa != stem::badaddr ) { stem::Event pe( NODE_EV_ECHO ); @@ -615,9 +637,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); - BOOST_CHECK( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -659,9 +681,11 @@ shm_cnd.deallocate( &pcnd, 1 ); (&scnd)->~__condition<true>(); shm_cnd.deallocate( &scnd, 1 ); + + return EXAM_RESULT; } -void stem_test::boring_manager() +int EXAM_IMPL(stem_test::boring_manager) { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); fcnd.set( false ); @@ -709,81 +733,43 @@ (&fcnd)->~__condition<true>(); shm_cnd.deallocate( &fcnd, 1 ); + + return EXAM_RESULT; } // ----------------- // ----------------- -struct stem_test_suite : - public test_suite +int EXAM_DECL(stem_test_suite); + +int EXAM_IMPL(stem_test_suite) { - stem_test_suite(); -}; + exam::test_suite::test_case_type tc[4]; + exam::test_suite t( "libsteam test suite" ); + stem_test test; -stem_test_suite::stem_test_suite() : - test_suite( "StEM test suite" ) -{ - boost::shared_ptr<stem_test> instance( new stem_test() ); + tc[1] = t.add( &stem_test::basic2, test, "basic2", + tc[0] = t.add( &stem_test::basic1, test, "basic1" ) ); - test_case *basic1_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic1, instance ); - test_case *basic2_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic2, instance ); - test_case *basic1n_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic1new, instance ); - test_case *basic2n_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic2new, instance ); - test_case *dl_tc = BOOST_CLASS_TEST_CASE( &stem_test::dl, instance ); - test_case *ns_tc = BOOST_CLASS_TEST_CASE( &stem_test::ns, instance ); - test_case *echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo, instance ); - test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_init, instance ); - test_case *echo_net_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo_net, instance ); - test_case *net_echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::net_echo, instance ); - test_case *peer_tc = BOOST_CLASS_TEST_CASE( &stem_test::peer, instance ); - test_case *boring_manager_tc = BOOST_CLASS_TEST_CASE( &stem_test::boring_manager, instance ); - test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_finit, instance ); + tc[2] = t.add( &stem_test::basic1new, test, "basic1new", tc[0] ); - basic2_tc->depends_on( basic1_tc ); - basic1n_tc->depends_on( basic1_tc ); - basic2n_tc->depends_on( basic2_tc ); - basic2n_tc->depends_on( basic1n_tc ); - dl_tc->depends_on( basic2n_tc ); - ns_tc->depends_on( basic1_tc ); + t.add( &stem_test::dl, test, "dl", + t.add( &stem_test::basic2new, test, "basic2new", tc + 1, tc + 3 ) ); + t.add( &stem_test::ns, test, "ns", tc[0] ); - echo_tc->depends_on( basic2_tc ); - echo_net_tc->depends_on( shm_init_tc ); - echo_net_tc->depends_on( echo_tc ); - net_echo_tc->depends_on( shm_init_tc ); - net_echo_tc->depends_on( echo_net_tc ); - peer_tc->depends_on( echo_tc ); - peer_tc->depends_on( shm_init_tc ); - boring_manager_tc->depends_on( peer_tc ); - boring_manager_tc->depends_on( shm_init_tc ); - shm_finit_tc->depends_on( shm_init_tc ); + t.add( &stem_test::net_echo, test, "net echo", + t.add( &stem_test::echo_net, test, "echo_net", + tc[3] = t.add( &stem_test::echo, test, "echo", tc[1] ) ) ); - add( basic1_tc ); - add( basic2_tc ); - add( basic1n_tc ); - add( basic2n_tc ); - add( dl_tc ); - add( ns_tc ); + t.add( &stem_test::boring_manager, test, "boring_manager", + t.add( &stem_test::peer, test, "peer", tc[3] ) ); - add( echo_tc ); - add( shm_init_tc ); - add( echo_net_tc ); - add( net_echo_tc ); - add( peer_tc ); - add( boring_manager_tc ); - add( shm_finit_tc ); + return t.girdle(); } -test_suite *init_unit_test_suite( int argc, char **argv ) +int main( int, char ** ) { - // test_suite *ts = BOOST_TEST_SUITE( "libstem test" ); - - // ts->add( new stem_test_suite() ); - - // ts->add( BOOST_TEST_CASE( &send_test ) ); - // ts->add( BOOST_TEST_CASE( &send2_test ) ); - - // return ts; - return new stem_test_suite(); + return stem_test_suite(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 16:30:52
|
Revision: 1629 http://svn.sourceforge.net/complement/?rev=1629&view=rev Author: complement Date: 2007-07-18 09:30:49 -0700 (Wed, 18 Jul 2007) Log Message: ----------- add guards, hide dangerous objects exposition; FIT_EXAM -> __FIT_EXAM Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/exam_test_suite.h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-18 12:17:22 UTC (rev 1628) +++ trunk/complement/explore/include/exam/suite.h 2007-07-18 16:30:49 UTC (rev 1629) @@ -11,7 +11,8 @@ #include <string> #include <exception> -#include "logger.h" +#include <mt/xmt.h> +#include <exam/logger.h> enum vertex_testcase_t { vertex_testcase }; @@ -204,12 +205,10 @@ int flags( int ); bool is_trace(); void report( const char *, int, bool, const char * ); + static void report_async( const char *, int, bool, const char * ); base_logger *set_global_logger( base_logger * ); base_logger *set_logger( base_logger * ); - void set_fail(); - static test_suite& top(); - private: enum { pass = 0, @@ -221,6 +220,7 @@ vertex_t root; vertex_testcase_map_t testcase; base_logger *local_logger; + xmt::mutex _lock_ll; struct test_case_collect { @@ -238,8 +238,10 @@ static int _root_func( test_suite *, int = 0 ); static base_logger *logger; + static xmt::mutex _lock_gl; static std::stack<test_suite *> _stack; + static xmt::mutex _lock_stack; }; template <class TC> @@ -302,27 +304,27 @@ } // namespace exam -#ifdef FIT_EXAM +#ifdef __FIT_EXAM # define EXAM_IMPL(F) F( exam::test_suite *__exam_ts, int __exam_counter ) # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT __exam_counter # define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) -# define EXAM_CHECK_ASYNC(C) if ( !(C) ) { exam::test_suite::top().report( __FILE__, __LINE__, false, #C ); exam::test_suite::top().set_fail(); } else exam::test_suite::top().report( __FILE__, __LINE__, true, #C ) +# define EXAM_CHECK_ASYNC(C) if ( !(C) ) { exam::test_suite::report_async( __FILE__, __LINE__, false, #C ); } else exam::test_suite::report_async( __FILE__, __LINE__, true, #C ) # define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) -# define EXAM_MESSAGE_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, true, M ) +# define EXAM_MESSAGE_ASYNC(M) exam::test_suite::report_async( __FILE__, __LINE__, true, M ) # define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) # define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 # define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 -# define EXAM_ERROR_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, false, M ); exam::test_suite::top().set_fail() +# define EXAM_ERROR_ASYNC(M) exam::test_suite::report_async( __FILE__, __LINE__, false, M ) #else # define EXAM_IMPL(F) F( exam::test_suite *, int ) # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT 0 -# define EXAM_CHECK(C) -# define EXAM_CHECK_ASYNC(C) +# define EXAM_CHECK(C) (C) +# define EXAM_CHECK_ASYNC(C) (C) # define EXAM_MESSAGE(M) # define EXAM_MESSAGE_ASYNC(M) -# define EXAM_REQUIRE(C) +# define EXAM_REQUIRE(C) (C) # define EXAM_FAIL(M) # define EXAM_ERROR(M) # define EXAM_ERROR_ASYNC(M) Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-18 12:17:22 UTC (rev 1628) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-18 16:30:49 UTC (rev 1629) @@ -12,6 +12,7 @@ using namespace std; using namespace boost; using namespace detail; +using namespace xmt; namespace detail { @@ -109,6 +110,7 @@ _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + scoped_lock lk( _lock_stack ); _stack.push( this ); } @@ -122,12 +124,16 @@ _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + scoped_lock lk( _lock_stack ); _stack.push( this ); } test_suite::~test_suite() { + scoped_lock lk( _lock_stack ); _stack.pop(); + lk.unlock(); + for ( test_case_map_type::iterator i = _test.begin(); i != _test.end(); ++i ) { delete i->second.tc; } @@ -187,42 +193,38 @@ int test_suite::flags() { - return local_logger->flags(); + scoped_lock lk( _lock_ll ); + int tmp = local_logger->flags(); + return tmp; } bool test_suite::is_trace() { - return local_logger->is_trace(); + scoped_lock lk( _lock_ll ); + bool tmp = local_logger->is_trace(); + return tmp; } int test_suite::flags( int f ) { - return local_logger->flags( f ); + scoped_lock lk( _lock_ll ); + int tmp = local_logger->flags( f ); + return tmp; } -void test_suite::set_fail() -{ - _last_state = fail; -} - trivial_logger __trivial_logger_inst( cerr ); base_logger *test_suite::logger = &__trivial_logger_inst; stack<test_suite *> test_suite::_stack; +mutex test_suite::_lock_stack; +mutex test_suite::_lock_gl; -test_suite& test_suite::top() -{ - if ( _stack.empty() ) { - throw runtime_error( "stack of test suites empty" ); - } - - return *_stack.top(); -} - base_logger *test_suite::set_global_logger( base_logger *new_logger ) { + scoped_lock glk( _lock_gl ); base_logger *tmp = logger; logger = new_logger; + scoped_lock lk( _lock_ll ); if ( tmp == local_logger ) { // if local_logger was identical to logger, switch it too local_logger = logger; } @@ -231,6 +233,7 @@ base_logger *test_suite::set_logger( base_logger *new_logger ) { + scoped_lock lk( _lock_ll ); base_logger *tmp = local_logger; local_logger = new_logger; return tmp; @@ -238,9 +241,24 @@ void test_suite::report( const char *file, int line, bool cnd, const char *expr ) { + if ( !cnd ) { + _last_state = fail; + } + scoped_lock lk( _lock_ll ); local_logger->report( file, line, cnd, expr ); } +void test_suite::report_async( const char *file, int line, bool cnd, const char *expr ) +{ + scoped_lock lk( _lock_stack ); + + if ( _stack.empty() ) { + throw runtime_error( "stack of test suites empty" ); + } + + _stack.top()->report( file, line, cnd, expr ); +} + void test_suite::run_test_case( test_suite::vertex_t v ) { try { @@ -249,20 +267,25 @@ if ( (*_test[v].tc)( this, 0 ) == 0 ) { if ( _last_state == 0 ) { ++_stat.passed; + scoped_lock lk( _lock_ll ); local_logger->tc( base_logger::pass, _test[v].name ); } else { _test[v].state = fail; ++_stat.failed; + scoped_lock lk( _lock_ll ); local_logger->tc( base_logger::fail, _test[v].name ); _last_state = 0; } } else { _test[v].state = fail; ++_stat.failed; + scoped_lock lk( _lock_ll ); local_logger->tc( base_logger::fail, _test[v].name ); + _last_state = 0; } } else { ++_stat.skipped; + scoped_lock lk( _lock_ll ); local_logger->tc( base_logger::skip, _test[v].name ); } } @@ -272,6 +295,7 @@ catch ( ... ) { ++_stat.failed; _test[v].state = fail; + scoped_lock lk( _lock_ll ); local_logger->tc( base_logger::fail, _test[v].name ); } } Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2007-07-18 12:17:22 UTC (rev 1628) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-07-18 16:30:49 UTC (rev 1629) @@ -7,5 +7,6 @@ # INCLUDES += -I${BOOST_DIR} INCLUDES += -I${CoMT_INCLUDE_DIR} +DEFS += -D__FIT_EXAM LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.h =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-18 12:17:22 UTC (rev 1628) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-18 16:30:49 UTC (rev 1629) @@ -3,8 +3,6 @@ #ifndef __exam_test_suite_h #define __exam_test_suite_h -#define FIT_EXAM - #include <exam/suite.h> #include <string> #include <sstream> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-21 05:47:40
|
Revision: 1634 http://svn.sourceforge.net/complement/?rev=1634&view=rev Author: complement Date: 2007-07-20 22:47:37 -0700 (Fri, 20 Jul 2007) Log Message: ----------- boost graph removed; libexam: version 0.2.0 Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/Makefile.inc trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/exam_test_suite.cc Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/include/exam/suite.h 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 09:47:24 ptr> +// -*- C++ -*- Time-stamp: <07/07/21 09:06:00 ptr> #ifndef __suite_h #define __suite_h @@ -7,19 +7,16 @@ #include <sstream> #include <map> #include <stack> -#include <boost/graph/adjacency_list.hpp> #include <string> #include <exception> +#include <stdexcept> +#include <list> +#include <vector> +#include <algorithm> #include <mt/xmt.h> #include <exam/logger.h> -enum vertex_testcase_t { vertex_testcase }; - -namespace boost { - BOOST_INSTALL_PROPERTY( vertex, testcase ); -} // namespace boost - namespace exam { class test_suite; @@ -159,16 +156,8 @@ class test_suite { private: - typedef boost::property<vertex_testcase_t,int> TestCaseProperty; - typedef boost::property<boost::vertex_color_t, boost::default_color_type, TestCaseProperty> VColorProperty; + typedef unsigned vertex_t; - typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, VColorProperty > graph_t; - typedef boost::graph_traits<graph_t>::vertex_iterator vertex_iterator_t; - - typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; - typedef boost::property_map<graph_t,boost::vertex_color_t>::type vertex_color_map_t; - typedef boost::property_map<graph_t,vertex_testcase_t>::type vertex_testcase_map_t; - public: typedef int (*func_type)( test_suite *, int ); typedef vertex_t test_case_type; @@ -194,13 +183,9 @@ int girdle( test_case_type start ); int girdle() - { return girdle( root ); } + { return girdle( 0 ); } int run( test_suite *, int count = 0 ); - void run_test_case( vertex_t v ); - void check_test_case( vertex_t u, vertex_t v ); - void clean_test_case_state( vertex_t v ); - int flags(); int flags( int ); bool is_trace(); @@ -216,9 +201,6 @@ skip = 2 }; - graph_t g; - vertex_t root; - vertex_testcase_map_t testcase; base_logger *local_logger; xmt::mutex _lock_ll; @@ -229,12 +211,20 @@ std::string name; }; + typedef std::pair<vertex_t,vertex_t> edge_t; + typedef std::pair<vertex_t,unsigned> weight_t; typedef std::map<vertex_t,test_case_collect> test_case_map_type; + vertex_t _count; + std::list<edge_t> _edges; + std::vector<weight_t> _vertices; int _last_state; test_case_map_type _test; base_logger::stat _stat; std::string _suite_name; + void run_test_case( vertex_t v ); + static bool vertices_compare( weight_t, weight_t ); + static int _root_func( test_suite *, int = 0 ); static base_logger *logger; @@ -247,8 +237,9 @@ template <class TC> test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name ) { - vertex_t v = boost::add_vertex( boost::white_color, g); - boost::add_edge( root, v, g ); + vertex_t v = ++_count; + _edges.push_back( std::make_pair( 0, v ) ); + _vertices.push_back( std::make_pair( v, 1 ) ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; _test[v].name = name; @@ -260,10 +251,16 @@ template <class InputIter> test_suite::test_case_type test_suite::add( test_suite::func_type f, const std::string& name, InputIter first, InputIter last ) { - vertex_t v = boost::add_vertex( boost::white_color, g); + vertex_t v = ++_count; + unsigned weight = 1; while ( first != last ) { - boost::add_edge( *first++, v, g ); + if ( *first >= _count ) { + throw std::logic_error( "bad test dependency" ); + } + weight += _vertices[*first].second; + _edges.push_back( std::make_pair( *first++, v ) ); } + _vertices.push_back( std::make_pair( v, weight ) ); _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; _test[v].name = name; @@ -275,8 +272,12 @@ template <class TC> test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) { - vertex_t v = boost::add_vertex( boost::white_color, g); - boost::add_edge( depends, v, g ); + vertex_t v = ++_count; + if ( depends >= _count ) { + throw std::logic_error( "bad test dependency" ); + } + _edges.push_back( std::make_pair( depends, v ) ); + _vertices.push_back( std::make_pair( v, _vertices[depends].second + 1 ) ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; _test[v].name = name; @@ -288,10 +289,16 @@ template <class TC, class InputIter> test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, InputIter first, InputIter last ) { - vertex_t v = boost::add_vertex( boost::white_color, g); + vertex_t v = ++_count; + unsigned weight = 1; while ( first != last ) { - boost::add_edge( *first++, v, g ); + if ( *first >= _count ) { + throw std::logic_error( "bad test dependency" ); + } + weight += _vertices[*first].second; + _edges.push_back( std::make_pair( *first++, v ) ); } + _vertices.push_back( std::make_pair( v, weight ) ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; _test[v].name = name; Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,3 +1,11 @@ +2007-07-21 Petr Ovtchenkov <pt...@is...> + + * suite.h, suite.cc: boost graph removed; + + * ut/exam_test_suite.cc: problem with multiple dependencies resolved. + + * libexam: version 0.2.0 + 2007-07-17 Petr Ovtchenkov <pt...@is...> * suite.h, suite.cc: was introduced stack of test suites, functions Modified: trunk/complement/explore/lib/exam/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/Makefile.inc 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/lib/exam/Makefile.inc 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,7 +1,7 @@ -# -*- Makefile -*- Time-stamp: <07/07/16 00:51:47 ptr> +# -*- Makefile -*- Time-stamp: <07/07/21 09:21:58 ptr> LIBNAME = exam MAJOR = 0 -MINOR = 1 +MINOR = 2 PATCH = 0 SRC_CC = logger.cc suite.cc Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,11 +1,12 @@ -// -*- C++ -*- Time-stamp: <07/07/17 10:03:02 ptr> +// -*- C++ -*- Time-stamp: <07/07/21 09:13:17 ptr> #include <exam/suite.h> -#include <boost/graph/breadth_first_search.hpp> #include <stack> #include <cstdio> #include <iostream> +#include <algorithm> +#include <functional> namespace exam { @@ -14,85 +15,7 @@ using namespace detail; using namespace xmt; -namespace detail { -template <class Tag> -struct vertex_recorder : - public base_visitor<vertex_recorder<Tag> > -{ - typedef Tag event_filter; - - vertex_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Vertex, class Graph> - void operator()(Vertex v, const Graph& g) - { _suite.run_test_case( v ); } - - test_suite& _suite; -}; - -template <class Tag> -vertex_recorder<Tag> record_vertexes(test_suite& ts, Tag) -{ return vertex_recorder<Tag>(ts); } - -template <class Tag> -struct skip_recorder : - public base_visitor<skip_recorder<Tag> > -{ - typedef Tag event_filter; - - skip_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Edge, class Graph> - void operator()(Edge e, const Graph& g) - { - // typename graph_traits<Graph>::vertex_descriptor u = boost::source( e, g ); - // typename graph_traits<Graph>::vertex_descriptor v = boost::target( e, g ); - // boost::out_edges( v, g ); - // for () { - _suite.check_test_case( boost::source( e, g ), boost::target( e, g ) ); - // } - } - - test_suite& _suite; -}; - -template <class Tag> -skip_recorder<Tag> record_skip(test_suite& ts, Tag) -{ return skip_recorder<Tag>(ts); } - -template <class Tag> -struct white_recorder : - public base_visitor<white_recorder<Tag> > -{ - typedef Tag event_filter; - - white_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Vertex, class Graph> - void operator()(Vertex v, const Graph& g) - { - // std::cerr << "On vertex " << v << std::endl; - // boost::put( boost::vertex_color, g, v, white_color ); - _suite.clean_test_case_state( v ); - } - - test_suite& _suite; -}; - -template <class Tag> -white_recorder<Tag> record_white(test_suite& ts, Tag) -{ return white_recorder<Tag>(ts); } - - -} // namespace detail - int EXAM_IMPL(test_suite::_root_func) { throw init_exception(); @@ -101,28 +24,28 @@ } test_suite::test_suite( const string& name ) : - root( add_vertex( white_color, g ) ), - _last_state( 0 ), - _suite_name( name ), - local_logger( logger ) + _count(0), + _last_state( 0 ), + _suite_name( name ), + local_logger( logger ) { - testcase = get( vertex_testcase, g ); - _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); - _test[root].state = 0; + _vertices.push_back( std::make_pair( 0, 0 ) ); + _test[0].tc = detail::make_test_case( detail::call( _root_func ) ); + _test[0].state = 0; scoped_lock lk( _lock_stack ); _stack.push( this ); } test_suite::test_suite( const char *name ) : - root( add_vertex( white_color, g ) ), - _last_state( 0 ), - _suite_name( name ), - local_logger( logger ) + _count(0), + _last_state( 0 ), + _suite_name( name ), + local_logger( logger ) { - testcase = get( vertex_testcase, g ); - _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); - _test[root].state = 0; + _vertices.push_back( std::make_pair( 0, 0 ) ); + _test[0].tc = detail::make_test_case( detail::call( _root_func ) ); + _test[0].state = 0; scoped_lock lk( _lock_stack ); _stack.push( this ); @@ -139,28 +62,38 @@ } } +bool test_suite::vertices_compare( test_suite::weight_t l, test_suite::weight_t r ) +{ + return l.second < r.second; +} + int test_suite::girdle( test_suite::test_case_type start ) { - stack<vertex_t> buffer; - vertex_color_map_t color = get( vertex_color, g ); + if ( start > _count ) { + throw std::logic_error( "bad start point" ); + } - // detail::white_recorder<on_initialize_vertex> vis( *this ); - // - // vertex_iterator_t i, i_end; + sort( _vertices.begin(), _vertices.end(), vertices_compare ); - // for ( tie(i, i_end) = vertices(g); i != i_end; ++i ) { - // // vis.initialize_vertex( *i, g ); - // put( color, *i, white_color ); - // } + vector<weight_t>::iterator from; _stat = base_logger::stat(); + for( vector<weight_t>::iterator i = _vertices.begin(); i != _vertices.end(); ++i ) { + if ( i->first == start ) { + from = i; + } + _test[i->first].state = 0; + } local_logger->begin_ts(); - breadth_first_search( g, start, buffer, - make_bfs_visitor( - make_pair( record_white(*this,on_initialize_vertex()), - make_pair( record_vertexes(*this,on_discover_vertex()), - record_skip(*this,on_examine_edge()) ) ) ), - color ); + for( vector<weight_t>::iterator i = from; i != _vertices.end(); ++i ) { + for( std::list<edge_t>::const_iterator j = _edges.begin(); j != _edges.end(); ++j ) { + if ( j->second == i->first && _test[j->first].state != 0 ) { + _test[j->second].state = skip; + } + } + run_test_case( i->first ); + } + local_logger->end_ts(); local_logger->result( _stat, _suite_name ); @@ -169,8 +102,9 @@ test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) { - vertex_t v = add_vertex( white_color, g); - add_edge( root, v, g ); + vertex_t v = ++_count; + _edges.push_back( std::make_pair( 0, v ) ); + _vertices.push_back( std::make_pair( v, 1 ) ); _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; _test[v].name = name; @@ -181,8 +115,12 @@ test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name, test_suite::test_case_type depends ) { - vertex_t v = add_vertex( white_color, g); - add_edge( depends, v, g ); + vertex_t v = ++_count; + if ( depends >= _count ) { + throw std::logic_error( "bad test dependency" ); + } + _edges.push_back( std::make_pair( depends, v ) ); + _vertices.push_back( std::make_pair( v, _vertices[depends].second + 1 ) ); _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; _test[v].name = name; @@ -300,21 +238,9 @@ } } -void test_suite::check_test_case( test_suite::vertex_t u, test_suite::vertex_t v ) -{ - if ( _test[u].state != 0 ) { - _test[v].state = skip; - } -} - -void test_suite::clean_test_case_state( vertex_t v ) -{ - _test[v].state = 0; -} - int test_suite::run( test_suite *, int ) { - return girdle( root ); + return girdle( 0 ); } Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,11 +1,10 @@ -# -*- Makefile -*- Time-stamp: <07/07/05 09:31:15 ptr> +# -*- Makefile -*- Time-stamp: <07/07/21 09:01:38 ptr> SRCROOT := ../../.. include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -# INCLUDES += -I${BOOST_DIR} INCLUDES += -I${CoMT_INCLUDE_DIR} DEFS += -D__FIT_EXAM Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-20 06:10:55 UTC (rev 1633) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-21 05:47:37 UTC (rev 1634) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 00:38:11 ptr> +// -*- C++ -*- Time-stamp: <07/07/21 09:01:26 ptr> #include "exam_test_suite.h" @@ -220,15 +220,15 @@ tcx[1] = t.add( func_good2, "function 2 good", tc, tc + 2 ); t.add( func_good3, "function 3 good", tcx, tcx + 2 ); // <-- problem - logger.flags( exam::base_logger::verbose ); + // logger.flags( exam::base_logger::verbose ); t.girdle(); - logger.flags( 0 ); + // logger.flags( 0 ); - // EXAM_REQUIRE( buff.str() == r9 ); + EXAM_REQUIRE( buff.str() == r9 ); - std::cerr << "%%%\n"; - std::cerr << buff.str() << std::endl; - std::cerr << "%%%\n"; + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; return EXAM_RESULT; } @@ -266,16 +266,16 @@ dummy_test.cc:16: fail: false\n\ dummy_test.cc:17: pass: true\n\ FAIL member function fail\n\ +dummy_test.cc:33: pass: true\n\ SKIP function fail\n\ -dummy_test.cc:33: pass: true\n\ *** FAIL exam self test, fail function (+2-1~1/4) ***\n"; const std::string exam_basic_test::r6 = "\ PASS member function good\n\ dummy_test.cc:16: fail: false\n\ FAIL member function fail\n\ + PASS function good\n\ SKIP function fail\n\ - PASS function good\n\ *** FAIL exam self test, fail function (+2-1~1/4) ***\n"; const std::string exam_basic_test::r7 = "\ @@ -299,6 +299,7 @@ FAIL function fail\n\ dummy_test.cc:16: fail: false\n\ FAIL member function fail\n\ + SKIP function 3 good\n\ *** FAIL exam self test, fail function (+3-2~1/6) ***\n"; int EXAM_IMPL(exam_self_test) @@ -312,7 +313,7 @@ t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); exam::test_suite::test_case_type d2 = t.add( &exam_basic_test::multiple_dep, exam_basic, "multiple dependencies", d ); - // t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); + t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); return t.girdle(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-27 10:11:00
|
Revision: 1646 http://complement.svn.sourceforge.net/complement/?rev=1646&view=rev Author: complement Date: 2007-07-27 03:10:55 -0700 (Fri, 27 Jul 2007) Log Message: ----------- operator of format output of gaddr_type is public now and situated in the EvPack.cc, declared in the Event.h in namespace std; libstem vertion bumped to 4.6.1 Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/EvPack.cc trunk/complement/explore/lib/stem/Makefile.inc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-07-27 04:04:28 UTC (rev 1645) +++ trunk/complement/explore/include/stem/Event.h 2007-07-27 10:10:55 UTC (rev 1646) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/30 20:11:30 ptr> +// -*- C++ -*- Time-stamp: <07/07/27 09:41:46 ptr> /* * @@ -652,6 +652,12 @@ } // namespace stem +namespace std { + +ostream& operator <<( ostream& o, const stem::gaddr_type& g ); + +} // namespace std + namespace EDS = stem; #endif Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-07-27 04:04:28 UTC (rev 1645) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-07-27 10:10:55 UTC (rev 1646) @@ -1,3 +1,11 @@ +2007-07-27 Petr Ovtchenkov <pt...@is...> + + * Event.h, EvManager.cc, EvPack.cc: operator of format output + of gaddr_type is public now and situated in the EvPack.cc, + declared in the Event.h in namespace std. + + * libstem: library version 4.6.1 + 2007-07-18 Petr Ovtchenkov <pt...@is...> * test/stem: boost unit test framework replaced by exam. Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-07-27 04:04:28 UTC (rev 1645) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-07-27 10:10:55 UTC (rev 1646) @@ -42,8 +42,6 @@ std::string EvManager::inv_key_str( "invalid key" ); -std::ostream& operator <<( std::ostream& s, const gaddr_type& ga ); - __FIT_DECLSPEC EvManager::EvManager() : _low( beglocaddr ), _high( endlocaddr ), @@ -653,6 +651,7 @@ } +#if 0 std::ostream& operator <<( ostream& s, const gaddr_type& ga ) { ios_base::fmtflags f = s.flags( 0 ); @@ -682,6 +681,7 @@ return s; } +#endif __FIT_DECLSPEC std::ostream& EvManager::dump( std::ostream& s ) const { Modified: trunk/complement/explore/lib/stem/EvPack.cc =================================================================== --- trunk/complement/explore/lib/stem/EvPack.cc 2007-07-27 04:04:28 UTC (rev 1645) +++ trunk/complement/explore/lib/stem/EvPack.cc 2007-07-27 10:10:55 UTC (rev 1646) @@ -15,10 +15,30 @@ #include "stem/Event.h" #include <iterator> #include <iostream> +#include <iomanip> #include <string> #include <algorithm> #include <stdint.h> +namespace std { + +ostream& operator <<( ostream& o, const stem::gaddr_type& g ) +{ + ios_base::fmtflags f = o.flags( 0 ); + + o << hex << setfill( '0' ) + << setw(8) << g.hid.u.l[0] + << setw(8) << g.hid.u.l[1] + << '-' << dec << g.pid << '-' + << hex << setfill( '0' ) << setw(8) << g.addr; + + o.flags( f ); + + return o; +} + +} // namespace std + namespace stem { using namespace std; Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-07-27 04:04:28 UTC (rev 1645) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-07-27 10:10:55 UTC (rev 1646) @@ -3,7 +3,7 @@ LIBNAME = stem MAJOR = 4 MINOR = 6 -PATCH = 0 +PATCH = 1 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:06:09
|
Revision: 1657 http://complement.svn.sourceforge.net/complement/?rev=1657&view=rev Author: complement Date: 2007-08-02 23:06:03 -0700 (Thu, 02 Aug 2007) Log Message: ----------- select appropriate TR1 type_traits implementation or use own, if not good one found [initial release] Modified Paths: -------------- trunk/complement/explore/lib/misc/ChangeLog Added Paths: ----------- trunk/complement/explore/include/misc/type_traits.h Added: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h (rev 0) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-03 06:06:03 UTC (rev 1657) @@ -0,0 +1,164 @@ +// -*- C++ -*- Time-stamp: <07/08/03 08:59:36 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License version 3.0 + * + */ + +#ifndef __misc_type_traits_h +#define __misc_type_traits_h + +#ifndef __config_feature_h +#include <config/feature.h> +#endif + +#if !defined(STLPORT) /* || (_STLPORT_VERSION < 50200) */ + +// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, +// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, +// while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead +# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) + +namespace std { + +namespace tr1 { + +template <class _Tp, _Tp __v> +struct integral_constant +{ + static const _Tp value = __v; + // enum { value = __v }; + + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; +}; + +typedef integral_constant<bool, true> true_type; +typedef integral_constant<bool, false> false_type; + +#define __SPEC_(C,T,B) \ +template <> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL(C,T,B) \ +__SPEC_(C,T,B); \ +__SPEC_(C,const T,B); \ +__SPEC_(C,volatile T,B); \ +__SPEC_(C,const volatile T,B) + +#define __SPEC_1(C,T,B) \ +template <class _Tp> \ +struct C<T> : \ + public integral_constant<bool, B> \ +{ } + +#define __SPEC_FULL1(C,T,B) \ +__SPEC_1(C,T,B); \ +__SPEC_1(C,const T,B); \ +__SPEC_1(C,volatile T,B); \ +__SPEC_1(C,const volatile T,B) + +template <class _Tp> +struct is_void : + public false_type +{ }; + +__SPEC_FULL(is_void,bool,true); + +template <class _Tp> +struct is_integral : + public false_type +{ }; + +__SPEC_FULL(is_integral,bool,true); +__SPEC_FULL(is_integral,char,true); +__SPEC_FULL(is_integral,signed char,true); +__SPEC_FULL(is_integral,unsigned char,true); +__SPEC_FULL(is_integral,wchar_t,true); +__SPEC_FULL(is_integral,short,true); +__SPEC_FULL(is_integral,unsigned short,true); +__SPEC_FULL(is_integral,int,true); +__SPEC_FULL(is_integral,unsigned int,true); +__SPEC_FULL(is_integral,long,true); +__SPEC_FULL(is_integral,unsigned long,true); +__SPEC_FULL(is_integral,long long,true); +__SPEC_FULL(is_integral,unsigned long long,true); + +template <class _Tp> +struct is_floating_point : + public false_type +{ }; + +__SPEC_FULL(is_floating_point,float,true); +__SPEC_FULL(is_floating_point,double,true); +__SPEC_FULL(is_floating_point,long double,true); + +template <class _Tp> +struct is_arithmetic : + public integral_constant<bool, (is_integral<_Tp>::value + || is_floating_point<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_pointer : + public false_type +{ }; + +__SPEC_FULL1(is_pointer,_Tp *,true); + +template <class _Tp> +struct is_scalar : + public integral_constant<bool, (is_arithmetic<_Tp>::value + /* || is_enum<_Tp>::value */ + || is_pointer<_Tp>::value + /* || is_member_pointer<_Tp>::value */ )> +{ }; + +template <class _Tp> +struct remove_all_extents +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Size> +struct remove_all_extents<_Tp[_Size]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template<typename _Tp> +struct remove_all_extents<_Tp[]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template <class _Tp> +struct is_pod : + public integral_constant<bool, (is_void<_Tp>::value + || is_scalar<typename remove_all_extents<_Tp>::type>::value)> +{ }; + +#undef __SPEC_FULL +#undef __SPEC_ +#undef __SPEC_FULL1 +#undef __SPEC_1 + +} // namespace tr1 + +} // namespace std + +# else // __GLIBCXX__ && (__GNUC__ >= 4) +# include <tr1/type_traits> +# endif + +#else // STLPORT +# include <type_traits> +#endif + +#endif // __misc_type_traits_h + Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2007-07-27 12:03:29 UTC (rev 1656) +++ trunk/complement/explore/lib/misc/ChangeLog 2007-08-03 06:06:03 UTC (rev 1657) @@ -1,3 +1,8 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * type_traits.h: select appropriate TR1 type_traits implementation + or use own, if not good one found [initial release]. + 2007-02-28 Petr Ovtchenkov <pt...@is...> * tfstream: fstream-like interface to unique temporary file; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:17:42
|
Revision: 1658 http://complement.svn.sourceforge.net/complement/?rev=1658&view=rev Author: complement Date: 2007-08-02 23:17:38 -0700 (Thu, 02 Aug 2007) Log Message: ----------- let's try don't include boost's -I if macro not defined---mysterious behaviour otherwise happens Modified Paths: -------------- trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/test/mt/Makefile Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 06:06:03 UTC (rev 1657) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 06:17:38 UTC (rev 1658) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 14:58:35 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 09:12:25 ptr> SRCROOT := ../.. @@ -9,9 +9,9 @@ dbg-shared: DEFS += -D__FIT_STEM_TRACE=1 -ifdef WITHOUT_STLPORT -INCLUDES += -I${BOOST_INCLUDE_DIR} -else +ifndef WITHOUT_STLPORT +# INCLUDES += -I${BOOST_INCLUDE_DIR} +# else stldbg-shared: DEFS += -D__FIT_STEM_TRACE=1 endif Modified: trunk/complement/explore/test/mt/Makefile =================================================================== --- trunk/complement/explore/test/mt/Makefile 2007-08-03 06:06:03 UTC (rev 1657) +++ trunk/complement/explore/test/mt/Makefile 2007-08-03 06:17:38 UTC (rev 1658) @@ -7,7 +7,10 @@ include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif DEFS += -D__FIT_EXAM # temporary, before dums fix strings: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:28:15
|
Revision: 1659 http://complement.svn.sourceforge.net/complement/?rev=1659&view=rev Author: complement Date: 2007-08-02 23:27:59 -0700 (Thu, 02 Aug 2007) Log Message: ----------- add typedefs shared_mutex, shared_recursive_mutex; change ipc_sharable on is_ipc_sharable, use TR1 type_traits technique; add tricks to compile without STLport Modified Paths: -------------- trunk/complement/explore/include/mt/shm.h trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/lib/mt/ChangeLog Modified: trunk/complement/explore/include/mt/shm.h =================================================================== --- trunk/complement/explore/include/mt/shm.h 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/include/mt/shm.h 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:38:41 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:47:53 ptr> /* * Copyright (c) 2006, 2007 @@ -21,7 +21,7 @@ #include <stdexcept> #include <algorithm> -#include <stl/type_traits.h> +#include <misc/type_traits.h> #include <mt/xmt.h> @@ -64,41 +64,45 @@ }; template <class T> -struct ipc_sharable -{ - typedef typename std::__type_traits<T>::is_POD_type is_ipc_sharable; -}; +struct is_ipc_sharable : + public std::tr1::false_type +{ }; -template <> -struct ipc_sharable<xmt::__condition<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#define __SPEC_(C,T,B) \ +template <> \ +struct C<T > : \ + public std::tr1::integral_constant<bool, B> \ +{ } -template <> -struct ipc_sharable<xmt::__semaphore<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#define __SPEC_FULL(C,T,B) \ +__SPEC_(C,T,B); \ +__SPEC_(C,volatile T,B); -template <> -struct ipc_sharable<xmt::__barrier<true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +__SPEC_FULL(is_ipc_sharable,bool,true); +__SPEC_FULL(is_ipc_sharable,char,true); +__SPEC_FULL(is_ipc_sharable,signed char,true); +__SPEC_FULL(is_ipc_sharable,unsigned char,true); +__SPEC_FULL(is_ipc_sharable,wchar_t,true); +__SPEC_FULL(is_ipc_sharable,short,true); +__SPEC_FULL(is_ipc_sharable,unsigned short,true); +__SPEC_FULL(is_ipc_sharable,int,true); +__SPEC_FULL(is_ipc_sharable,unsigned int,true); +__SPEC_FULL(is_ipc_sharable,long,true); +__SPEC_FULL(is_ipc_sharable,unsigned long,true); +__SPEC_FULL(is_ipc_sharable,long long,true); +__SPEC_FULL(is_ipc_sharable,unsigned long long,true); +__SPEC_FULL(is_ipc_sharable,float,true); +__SPEC_FULL(is_ipc_sharable,double,true); +__SPEC_FULL(is_ipc_sharable,long double,true); +__SPEC_FULL(is_ipc_sharable,xmt::__condition<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::__semaphore<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::__barrier<true>,true); +__SPEC_FULL(is_ipc_sharable,xmt::shared_mutex,true); +__SPEC_FULL(is_ipc_sharable,xmt::shared_recursive_mutex,true); -template <> -struct ipc_sharable<xmt::__mutex<false,true> > -{ - typedef std::__true_type is_ipc_sharable; -}; +#undef __SPEC_FULL +#undef __SPEC_ -template <> -struct ipc_sharable<xmt::__mutex<true,true> > -{ - typedef std::__true_type is_ipc_sharable; -}; - template <int _Inst> class shm_alloc; namespace detail { @@ -633,7 +637,7 @@ }; template <> -class __allocator_shm<std::__false_type> +class __allocator_shm<std::tr1::false_type> { private: __allocator_shm() @@ -641,19 +645,35 @@ }; template <> -class __allocator_shm<std::__true_type> +class __allocator_shm<std::tr1::true_type> { public: __allocator_shm() { } }; +#ifndef STLPORT + +template <class _Tp, class TRD > +inline void __destroy_aux(_Tp *p, const TRD& /* has_trivial_destructor */) +{ } + +template <class _Tp> +inline void __destroy_aux(_Tp *p, const std::tr1::false_type& /* has_trivial_destructor */) +{ p->~_Tp(); } + +template <class _Tp> +inline void __destroy_aux(_Tp *p, const std::tr1::true_type& /* has_trivial_destructor */) +{ } + +#endif // !STLPORT + } // namespace detail template <class _Tp, int _Inst> class allocator_shm : public shm_alloc<_Inst>, - private detail::__allocator_shm<typename ipc_sharable<_Tp>::is_ipc_sharable> + private detail::__allocator_shm<typename is_ipc_sharable<_Tp>::type> { public: typedef shm_alloc<_Inst> chunk_type; @@ -723,10 +743,22 @@ { return chunk_type::max_size() / sizeof(value_type); } void construct(pointer __p, const_reference __val) - { _STLP_STD::_Copy_Construct(__p, __val); } + { +#ifdef STLPORT + _STLP_STD::_Copy_Construct(__p, __val); +#else + new (__p) _Tp(__val); +#endif + } void destroy(pointer __p) - { _STLP_STD::_Destroy(__p); } + { +#ifdef STLPORT + _STLP_STD::_Destroy(__p); +#else + detail::__destroy_aux(__p,std::tr1::has_trivial_destructor<value_type>::value); +#endif + } }; Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/include/mt/xmt.h 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:37:57 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:47:08 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -895,6 +895,8 @@ typedef __mutex<false,false> mutex; typedef __mutex<true,false> recursive_mutex; +typedef __mutex<false,true> shared_mutex; +typedef __mutex<true,true> shared_recursive_mutex; #ifdef __FIT_RWLOCK typedef __rw_mutex<false> rw_mutex; #endif // __FIT_RWLOCK Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 06:17:38 UTC (rev 1658) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 06:27:59 UTC (rev 1659) @@ -1,3 +1,13 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * test/mt/Makefile: let's try don't include boost's -I if macro + not defined---mysterious behaviour otherwise happens; + + * xmt.h: add typedefs shared_mutex, shared_recursive_mutex; + + * shm.h: change ipc_sharable on is_ipc_sharable, use TR1 type_traits + technique; add tricks to compile without STLport. + 2007-07-17 Petr Ovtchenkov <pt...@is...> * test/mt: boost unit test framework was replaced by exam. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 06:31:40
|
Revision: 1660 http://complement.svn.sourceforge.net/complement/?rev=1660&view=rev Author: complement Date: 2007-08-02 23:31:38 -0700 (Thu, 02 Aug 2007) Log Message: ----------- use TR1 type_traits technique; add tricks to compile without STLport Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/EvPack.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/Event.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/07/27 09:41:46 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 08:19:34 ptr> /* * - * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1995-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -26,53 +26,11 @@ #include <sstream> #include <stdint.h> +#include <misc/type_traits.h> #include <stem/EvPack.h> #include <mt/uid.h> #include <mt/xmt.h> -#ifndef STLPORT -#include <bits/cpp_type_traits.h> - -// libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, -// libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, -// while libstdc++ v3, 20050921 (4.0.2) not; use boost's staff instead -# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ > 3)) -#include <boost/type_traits.hpp> - -//bool to type -template <int _Is> -struct __bool2type -{ typedef __true_type _Ret; }; - -template <> -struct __bool2type<1> { typedef __true_type _Ret; }; - -template <> -struct __bool2type<0> { typedef __false_type _Ret; }; - -template <class _Tp> -struct __type_traits { - enum { trivial_constructor = ::boost::has_trivial_constructor<_Tp>::value }; - typedef typename __bool2type<trivial_constructor>::_Ret has_trivial_default_constructor; - - enum { trivial_copy = ::boost::has_trivial_copy<_Tp>::value }; - typedef typename __bool2type<trivial_copy>::_Ret has_trivial_copy_constructor; - - enum { trivial_assign = ::boost::has_trivial_assign<_Tp>::value }; - typedef typename __bool2type<trivial_assign>::_Ret has_trivial_assignment_operator; - - enum { trivial_destructor = ::boost::has_trivial_destructor<_Tp>::value }; - typedef typename __bool2type<trivial_destructor>::_Ret has_trivial_destructor; - - enum { pod = ::boost::is_pod<_Tp>::value }; - typedef typename __bool2type<pod>::_Ret is_POD_type; -}; -# else -# include <bits/type_traits.h> -# endif // __GLIBCXX__ - -#endif - namespace stem { typedef uint32_t addr_type; @@ -84,16 +42,6 @@ extern const addr_type ns_addr; extern const code_type badcode; -#ifdef STLPORT -using std::__true_type; -using std::__false_type; -using std::__type_traits; -#else -using ::__true_type; -using ::__false_type; -using ::__type_traits; -#endif - struct gaddr_type : public __pack_base { @@ -220,8 +168,8 @@ // Forward declarations template <class D, class POD > class __Event_base_aux; -template <class D> class __Event_base_aux<D,__true_type>; -template <class D> class __Event_base_aux<D,__false_type>; +template <class D> class __Event_base_aux<D,std::tr1::true_type>; +template <class D> class __Event_base_aux<D,std::tr1::false_type>; template <class D> class Event_base; @@ -267,7 +215,7 @@ }; template <class D> -class __Event_base_aux<D,__true_type> : +class __Event_base_aux<D,std::tr1::true_type> : public __Event_Base { public: @@ -318,7 +266,7 @@ }; template <class D> -class __Event_base_aux<D,__false_type> : +class __Event_base_aux<D,std::tr1::false_type> : public __Event_Base { public: @@ -369,7 +317,7 @@ }; template <> -class __Event_base_aux<std::string,__false_type> : +class __Event_base_aux<std::string,std::tr1::false_type> : public __Event_Base { public: @@ -420,7 +368,7 @@ }; template <> -class __Event_base_aux<void,__true_type> : +class __Event_base_aux<void,std::tr1::true_type> : public __Event_Base { public: @@ -456,26 +404,26 @@ template <class D> class Event_base : - public __Event_base_aux<D,typename __type_traits<D>::is_POD_type> + public __Event_base_aux<D,typename std::tr1::is_pod<D>::type> { private: - typedef __Event_base_aux<D,typename __type_traits<D>::is_POD_type> _Base; + typedef __Event_base_aux<D,typename std::tr1::is_pod<D>::type> _Base; public: Event_base() : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>() + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c ) { } Event_base( code_type c, const D& d ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( c, d ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<D,typename __type_traits<D>::is_POD_type>( e, e._data ) + __Event_base_aux<D,typename std::tr1::is_pod<D>::type>( e, e._data ) { } void net_pack( Event& s ) const; @@ -487,26 +435,26 @@ template <> class Event_base<std::string> : - public __Event_base_aux<std::string,__false_type> + public __Event_base_aux<std::string,std::tr1::false_type> { private: - typedef __Event_base_aux<std::string,__false_type> _Base; + typedef __Event_base_aux<std::string,std::tr1::false_type> _Base; public: Event_base() : - __Event_base_aux<std::string,__false_type>() + __Event_base_aux<std::string,std::tr1::false_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<std::string,__false_type>( c ) + __Event_base_aux<std::string,std::tr1::false_type>( c ) { } Event_base( code_type c, const std::string& d ) : - __Event_base_aux<std::string,__false_type>( c, d ) + __Event_base_aux<std::string,std::tr1::false_type>( c, d ) { } Event_base( const Event_base& e ) : - __Event_base_aux<std::string,__false_type>( e, e._data ) + __Event_base_aux<std::string,std::tr1::false_type>( e, e._data ) { } void net_pack( Event& s ) const @@ -549,7 +497,6 @@ template <class D> void Event_base<D>::net_pack( Event& s ) const { - // std::cerr << "**1\n"; s.code( _Base::_code ); s.dest( _Base::_dst ); s.src( _Base::_src ); @@ -568,7 +515,6 @@ _Base::_flags = s.flags() & ~(__Event_Base::conv | __Event_Base::expand); std::istringstream ss( s.value() ); _Base::net_unpack( ss ); - // std::cerr << "**2 " << std::hex << _Base::flags() << std::dec << std::endl; } template <class D> @@ -582,7 +528,6 @@ std::ostringstream ss; _Base::pack( ss ); s.value() = ss.str(); - // std::cerr << "**3 " << std::hex << s.flags() << std::dec << std::endl; } template <class D> @@ -595,28 +540,27 @@ // _Base::unsetf( __Event_Base::expand ); std::istringstream ss( s.value() ); _Base::unpack( ss ); - // std::cerr << "**4 " << std::hex << _Base::flags() << std::dec << std::endl; } template <> class Event_base<void> : - public __Event_base_aux<void,__true_type> + public __Event_base_aux<void,std::tr1::true_type> { private: - typedef __Event_base_aux<void,__true_type> _Base; + typedef __Event_base_aux<void,std::tr1::true_type> _Base; public: Event_base() : - __Event_base_aux<void,__true_type>() + __Event_base_aux<void,std::tr1::true_type>() { } explicit Event_base( code_type c ) : - __Event_base_aux<void,__true_type>( c ) + __Event_base_aux<void,std::tr1::true_type>( c ) { } __FIT_EXPLICIT Event_base( const Event_base& e ) : - __Event_base_aux<void,__true_type>( e ) + __Event_base_aux<void,std::tr1::true_type>( e ) { } void net_pack( Event& s ) const Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/include/stem/EventHandler.h 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/08 17:24:21 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:01:32 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -509,7 +509,7 @@ typedef HistoryContainer::iterator h_iterator; typedef HistoryContainer::const_iterator const_h_iterator; -_STLP_TEMPLATE_NULL +template <> class __EvHandler<EventHandler,h_iterator > { public: @@ -669,7 +669,7 @@ } } -_STLP_TEMPLATE_NULL +template <> inline void __EvTableLoader<EventHandler>( EventHandler::table_type *, EventHandler * ) { } Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,3 +1,13 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * Makefile: let's try don't include boost's -I if macro + not defined---mysterious behaviour otherwise happens; + + * Event.h, EvManager.cc, EvPack.cc: use TR1 type_traits technique; + add tricks to compile without STLport; + + * EventHandler.h: remove STLport's macro. + 2007-07-27 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc, EvPack.cc: operator of format output Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 18:53:45 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:20:31 ptr> /* * @@ -685,10 +685,10 @@ __FIT_DECLSPEC std::ostream& EvManager::dump( std::ostream& s ) const { - ios_base::fmtflags f = s.flags( 0 ); + ios_base::fmtflags f = s.flags( ios_base::hex | ios_base::showbase ); s << "Local map:\n"; - s << hex << showbase; + // s << hex << showbase; { scoped_lock lk( _lock_heap ); Modified: trunk/complement/explore/lib/stem/EvPack.cc =================================================================== --- trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:27:59 UTC (rev 1659) +++ trunk/complement/explore/lib/stem/EvPack.cc 2007-08-03 06:31:38 UTC (rev 1660) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <06/11/24 17:19:05 ptr> +// -*- C++ -*- Time-stamp: <07/08/03 09:22:05 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -24,9 +24,9 @@ ostream& operator <<( ostream& o, const stem::gaddr_type& g ) { - ios_base::fmtflags f = o.flags( 0 ); + ios_base::fmtflags f = o.flags( ios_base::hex ); - o << hex << setfill( '0' ) + o << setfill( '0' ) << setw(8) << g.hid.u.l[0] << setw(8) << g.hid.u.l[1] << '-' << dec << g.pid << '-' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 13:35:29
|
Revision: 1664 http://complement.svn.sourceforge.net/complement/?rev=1664&view=rev Author: complement Date: 2007-08-03 06:35:27 -0700 (Fri, 03 Aug 2007) Log Message: ----------- remove private keyword for dummy, to make gcc 3.3.6 happy Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-08-03 10:42:32 UTC (rev 1663) +++ trunk/complement/explore/include/exam/suite.h 2007-08-03 13:35:27 UTC (rev 1664) @@ -60,7 +60,6 @@ virtual int f( test_suite *, int count = 0 ) { return count; } - private: virtual ~dummy() { } }; Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-08-03 10:42:32 UTC (rev 1663) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-08-03 13:35:27 UTC (rev 1664) @@ -1,3 +1,7 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * suite.h: remove private keyword for dummy, to make gcc 3.3.6 happy. + 2007-07-21 Petr Ovtchenkov <pt...@is...> * suite.h, suite.cc: boost graph removed; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 13:38:21
|
Revision: 1665 http://complement.svn.sourceforge.net/complement/?rev=1665&view=rev Author: complement Date: 2007-08-03 06:38:19 -0700 (Fri, 03 Aug 2007) Log Message: ----------- workaround for file openmode for libstdc++ shipped with gcc 3.3.6 Modified Paths: -------------- trunk/complement/explore/include/sockios/sockstream trunk/complement/explore/lib/sockios/ChangeLog Modified: trunk/complement/explore/include/sockios/sockstream =================================================================== --- trunk/complement/explore/include/sockios/sockstream 2007-08-03 13:35:27 UTC (rev 1664) +++ trunk/complement/explore/include/sockios/sockstream 2007-08-03 13:38:19 UTC (rev 1665) @@ -386,11 +386,15 @@ basic_sockbuf() : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) // hmm, 3.3.6 + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { @@ -406,11 +410,15 @@ sock_base::protocol prot = sock_base::inet, const timespec *timeout = 0 ) : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { @@ -421,11 +429,15 @@ sock_base::protocol prot = sock_base::inet, const timespec *timeout = 0 ) : _fd( -1 ), -#ifndef STLPORT +#if !defined(STLPORT) && defined(__GNUC__) +#if ((__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4))) + _mode( ios_base::openmode(__ios_flags::_S_in | __ios_flags::_S_out) ), +#else // 4.1.1 _mode( _S_in | _S_out ), -#else +#endif // __GNUC__ +#else // STLPORT _mode( 0 ), -#endif +#endif // STLPORT _bbuf(0), _ebuf(0), _allocated( true ) // , _doclose( true ) { Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 13:35:27 UTC (rev 1664) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 13:38:19 UTC (rev 1665) @@ -1,3 +1,8 @@ +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * include/sockios/sockstream: workaround for file openmode + for libstdc++ shipped with gcc 3.3.6. + 2007-07-18 Petr Ovtchenkov <pt...@is...> * test/sockios: boost unit test framework replaced by exam. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 14:08:21
|
Revision: 1667 http://complement.svn.sourceforge.net/complement/?rev=1667&view=rev Author: complement Date: 2007-08-03 07:08:20 -0700 (Fri, 03 Aug 2007) Log Message: ----------- fix targets for case without STLport; fix typo Modified Paths: -------------- trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/test/sockios/Makefile trunk/complement/explore/test/stem/Makefile trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -10,8 +10,6 @@ dbg-shared: DEFS += -D__FIT_STEM_TRACE=1 ifndef WITHOUT_STLPORT -# INCLUDES += -I${BOOST_INCLUDE_DIR} -# else stldbg-shared: DEFS += -D__FIT_STEM_TRACE=1 endif @@ -19,7 +17,9 @@ $(MAKE) -C ../../test/stem (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 +ifndef WITHOUT_STLPORT (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 +endif check-release-shared: release-shared $(MAKE) -C ../../test/stem release-shared Modified: trunk/complement/explore/test/sockios/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/sockios/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -1,13 +1,15 @@ # -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> SRCROOT := ../.. -COMPILER_NAME := gcc include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include +ifdef BOOST_DIR +INCLUDES += -I$(BOOST_INCLUDE_DIR) +endif DEFS += -D__FIT_EXAM LIBMT_DIR = ${CoMT_DIR}/lib/mt @@ -17,10 +19,14 @@ ifeq ($(OSNAME),linux) release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lexam +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +endif dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Modified: trunk/complement/explore/test/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/stem/Makefile 2007-08-03 14:08:20 UTC (rev 1667) @@ -1,7 +1,6 @@ # -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> SRCROOT := ../.. -COMPILER_NAME := gcc EXTRA_POST := dl-rel EXTRA_POST_DBG := dl-dbg @@ -20,12 +19,16 @@ ifeq ($(OSNAME),linux) release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl +endif dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/test/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 13:53:54 UTC (rev 1666) +++ trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 14:08:20 UTC (rev 1667) @@ -805,7 +805,7 @@ { exam::test_suite::test_case_type tc[4]; - exam::test_suite t( "libsteam test suite" ); + exam::test_suite t( "libstem test suite" ); stem_test test; tc[1] = t.add( &stem_test::basic2, test, "basic2", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 18:26:46
|
Revision: 1668 http://complement.svn.sourceforge.net/complement/?rev=1668&view=rev Author: complement Date: 2007-08-03 11:26:43 -0700 (Fri, 03 Aug 2007) Log Message: ----------- change unit tests location Added Paths: ----------- trunk/complement/explore/lib/mt/ut/ Removed Paths: ------------- trunk/complement/explore/test/mt/ Copied: trunk/complement/explore/lib/mt/ut (from rev 1667, trunk/complement/explore/test/mt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 19:46:49
|
Revision: 1669 http://complement.svn.sourceforge.net/complement/?rev=1669&view=rev Author: complement Date: 2007-08-03 12:46:45 -0700 (Fri, 03 Aug 2007) Log Message: ----------- tests moved to ut Modified Paths: -------------- trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile trunk/complement/explore/lib/sockios/ut/Makefile trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Added Paths: ----------- trunk/complement/explore/lib/sockios/ut/ Removed Paths: ------------- trunk/complement/explore/test/sockios/ Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,8 +1,10 @@ 2007-08-03 Petr Ovtchenkov <pt...@is...> * include/sockios/sockstream: workaround for file openmode - for libstdc++ shipped with gcc 3.3.6. + for libstdc++ shipped with gcc 3.3.6; + * ../../test/sockios: moved to ut. + 2007-07-18 Petr Ovtchenkov <pt...@is...> * test/sockios: boost unit test framework replaced by exam. Modified: trunk/complement/explore/lib/sockios/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/Makefile 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 14:59:53 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:06:18 ptr> SRCROOT := ../.. @@ -8,24 +8,29 @@ INCLUDES += -I$(SRCROOT)/include check: all-shared - $(MAKE) -C ../../test/sockios - (cd ../../test/sockios; ${OUTPUT_DIR}/sockios_ut) || exit 1 - (cd ../../test/sockios; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 - (cd ../../test/sockios; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 + $(MAKE) -C ut + (cd ut; ${OUTPUT_DIR}/sockios_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 +ifndef WITHOUT_STLPORT + (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 +endif check-release-shared: release-shared - $(MAKE) -C ../../test/sockios release-shared - (cd ../../test/sockios; ${OUTPUT_DIR}/sockios_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/sockios_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/sockios dbg-shared - (cd ../../test/sockios; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/sockios stldbg-shared - (cd ../../test/sockios; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 endif depend:: - $(MAKE) -C ../../test/sockios depend + $(MAKE) -C ut depend + +clean:: + $(MAKE) -C ut clean Copied: trunk/complement/explore/lib/sockios/ut (from rev 1668, trunk/complement/explore/test/sockios) Modified: trunk/complement/explore/lib/sockios/ut/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/sockios/ut/Makefile 2007-08-03 19:46:45 UTC (rev 1669) @@ -1,6 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:06:43 ptr> -SRCROOT := ../.. +SRCROOT := ../../.. include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak Modified: trunk/complement/explore/test/virtual_time/test/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 19:46:45 UTC (rev 1669) @@ -21,10 +21,12 @@ void handler( const stem::Event& ); void VTNewMember( const stem::Event& ); + void VTOutMember( const stem::Event& ); void wait(); std::string msg; int count; + int ocount; private: xmt::condition cnd; @@ -36,21 +38,24 @@ VTDummy::VTDummy() : VTHandler(), - count(0) + count(0), + ocount(0) { cnd.set( false ); } VTDummy::VTDummy( stem::addr_type id ) : VTHandler( id ), - count(0) + count(0), + ocount(0) { cnd.set( false ); } VTDummy::VTDummy( stem::addr_type id, const char *info ) : VTHandler( id, info ), - count(0) + count(0), + ocount(0) { cnd.set( false ); } @@ -73,6 +78,12 @@ ++count; } +void VTDummy::VTOutMember( const stem::Event& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + void VTDummy::wait() { cnd.try_wait(); @@ -172,6 +183,9 @@ EXAM_CHECK( dummy2.msg == "yet more" ); EXAM_CHECK( dummy1.msg == "" ); + EXAM_CHECK( dummy1.ocount == 1 ); + EXAM_CHECK( dummy2.ocount == 1 ); + return EXAM_RESULT; } Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-03 19:46:45 UTC (rev 1669) @@ -608,15 +608,22 @@ pair<gid_map_type::iterator,gid_map_type::iterator> range = grmap.equal_range( grp ); + vt_map_type::iterator i = vtmap.find( oid ); while ( range.first != range.second ) { if ( range.first->second == oid ) { grmap.erase( range.first++ ); } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::Event ev( VTS_OUT_MEMBER ); + ev.dest( j->second.stem_addr() ); + ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + Forward( ev ); + } ++range.first; } } - vt_map_type::iterator i = vtmap.find( oid ); if ( i != vtmap.end() ) { if ( i->second.rm_group( grp ) ) { // no groups more vtmap.erase( i ); @@ -720,8 +727,13 @@ { } +void VTHandler::VTOutMember( const stem::Event& ) +{ +} + DEFINE_RESPONSE_TABLE( VTHandler ) EV_EDS( ST_NULL, VTS_NEW_MEMBER, VTNewMember ) + EV_EDS( ST_NULL, VTS_OUT_MEMBER, VTOutMember ) END_RESPONSE_TABLE } // namespace vt Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-03 19:46:45 UTC (rev 1669) @@ -292,6 +292,7 @@ void VTSend( const stem::Event& e ); virtual void VTNewMember( const stem::Event& e ); + virtual void VTOutMember( const stem::Event& e ); template <class D> void VTSend( const stem::Event_base<D>& e ) @@ -306,6 +307,7 @@ #define MESS 0x300 #define VTS_NEW_MEMBER 0x301 +#define VTS_OUT_MEMBER 0x302 } // namespace vt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-03 20:05:07
|
Revision: 1670 http://complement.svn.sourceforge.net/complement/?rev=1670&view=rev Author: complement Date: 2007-08-03 13:05:01 -0700 (Fri, 03 Aug 2007) Log Message: ----------- moved to ut Modified Paths: -------------- trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Makefile trunk/complement/explore/lib/stem/ut/Makefile trunk/complement/explore/lib/stem/ut/dl/Makefile Added Paths: ----------- trunk/complement/explore/lib/stem/ut/ trunk/complement/explore/lib/stem/ut/stem/ Removed Paths: ------------- trunk/complement/explore/lib/stem/ut/stem/Convert.cc trunk/complement/explore/lib/stem/ut/stem/Convert.h trunk/complement/explore/lib/stem/ut/stem/Echo.cc trunk/complement/explore/lib/stem/ut/stem/Echo.h trunk/complement/explore/lib/stem/ut/stem/Makefile trunk/complement/explore/lib/stem/ut/stem/Makefile.inc trunk/complement/explore/lib/stem/ut/stem/NameService.cc trunk/complement/explore/lib/stem/ut/stem/NameService.h trunk/complement/explore/lib/stem/ut/stem/Node.cc trunk/complement/explore/lib/stem/ut/stem/Node.h trunk/complement/explore/lib/stem/ut/stem/NodeDL.h trunk/complement/explore/lib/stem/ut/stem/dl/ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc trunk/complement/explore/test/stem/ Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 19:46:45 UTC (rev 1669) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-03 20:05:01 UTC (rev 1670) @@ -6,8 +6,10 @@ * Event.h, EvManager.cc, EvPack.cc: use TR1 type_traits technique; add tricks to compile without STLport; - * EventHandler.h: remove STLport's macro. + * EventHandler.h: remove STLport's macro; + * ../../test/stem: moved to ut. + 2007-07-27 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc, EvPack.cc: operator of format output Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-08-03 19:46:45 UTC (rev 1669) +++ trunk/complement/explore/lib/stem/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 09:12:25 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:31 ptr> SRCROOT := ../.. @@ -14,26 +14,26 @@ endif check: all-shared - $(MAKE) -C ../../test/stem - (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 - (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + $(MAKE) -C ut + (cd ut; ${OUTPUT_DIR}/stem_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 ifndef WITHOUT_STLPORT - (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 endif check-release-shared: release-shared - $(MAKE) -C ../../test/stem release-shared - (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/stem_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/stem dbg-shared - (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/stem stldbg-shared - (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 endif -depend:: - $(MAKE) -C ../../test/stem depend +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Copied: trunk/complement/explore/lib/stem/ut (from rev 1668, trunk/complement/explore/test/stem) Modified: trunk/complement/explore/lib/stem/ut/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,6 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:05 ptr> -SRCROOT := ../.. +SRCROOT := ../../.. EXTRA_POST := dl-rel EXTRA_POST_DBG := dl-dbg @@ -18,18 +18,24 @@ LIBEXAM_DIR = ${CoMT_DIR}/lib/exam ifeq ($(OSNAME),linux) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + ifndef WITHOUT_STLPORT + stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} + endif + dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + endif release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl endif -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/lib/stem/ut/dl/Makefile =================================================================== --- trunk/complement/explore/test/stem/dl/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/dl/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,7 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:13:04 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:59:51 ptr> -SRCROOT := ../../.. -COMPILER_NAME := gcc +SRCROOT := ../../../.. DBG_SUFFIX := STLDBG_SUFFIX := @@ -15,14 +14,19 @@ #LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} +dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -dbg-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} +endif #release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf release-shared: LDLIBS = -lstem #stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg -stldbg-shared: LDLIBS = -lstemstlg #dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg dbg-shared: LDLIBS = -lstemg +ifndef WITHOUT_STLPORT +stldbg-shared: LDLIBS = -lstemstlg +endif + #LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR}:${CoMT_LIB_DIR} Copied: trunk/complement/explore/lib/stem/ut/stem (from rev 1668, trunk/complement/explore/test/stem) Property changes on: trunk/complement/explore/lib/stem/ut/stem ___________________________________________________________________ Name: svn:ignore + .make.depend obj *.dvi *.lot *.lof *.loc Deleted: trunk/complement/explore/lib/stem/ut/stem/Convert.cc =================================================================== --- trunk/complement/explore/test/stem/Convert.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,104 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:05:52 ptr> - -/* - * - * Copyright (c) 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Convert.h" - -void mess::pack( std::ostream& s ) const -{ - __pack( s, super_id ); - __pack( s, message ); -} - -void mess::net_pack( std::ostream& s ) const -{ - __net_pack( s, super_id ); - __net_pack( s, message ); -} - -void mess::unpack( std::istream& s ) -{ - __unpack( s, super_id ); - __unpack( s, message ); -} - -void mess::net_unpack( std::istream& s ) -{ - __net_unpack( s, super_id ); - __net_unpack( s, message ); -} - -Convert::Convert() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::Convert( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::Convert( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - v( 0 ) -{ - cnd.set( false ); -} - -Convert::~Convert() -{ - // cnd.wait(); -} - -void Convert::handler0() -{ - v = -1; - cnd.set(true); -} - -void Convert::handler1( const stem::Event& ) -{ - v = 1; - cnd.set(true); -} - -void Convert::handler2( const stem::Event_base<mess>& ev ) -{ - v = ev.value().super_id; - m2 = ev.value().message; - - cnd.set(true); -} - -void Convert::handler3( const mess& m ) -{ - v = m.super_id; - m3 = m.message; - - cnd.set(true); -} - -void Convert::wait() -{ - cnd.try_wait(); - - cnd.set( false ); -} - -DEFINE_RESPONSE_TABLE( Convert ) - EV_VOID( ST_NULL, CONV_EV0, handler0 ) - EV_EDS( ST_NULL, CONV_EV1, handler1 ) - EV_Event_base_T_( ST_NULL, CONV_EV2, handler2, mess ) - EV_T_( ST_NULL, CONV_EV3, handler3, mess ) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Convert.h =================================================================== --- trunk/complement/explore/test/stem/Convert.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,74 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:03:52 ptr> - -/* - * - * Copyright (c) 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Convert_h -#define __Convert_h - -#include <mt/xmt.h> - -#include <stem/Event.h> -#include <stem/EventHandler.h> - -#include <stdint.h> -#include <string> - -struct mess : - public stem::__pack_base -{ - void pack( std::ostream& s ) const; - void net_pack( std::ostream& s ) const; - void unpack( std::istream& s ); - void net_unpack( std::istream& s ); - - mess() - { } - mess( const mess& m ) : - super_id( m.super_id ), - message( m.message ) - { } - - int32_t super_id; - std::string message; -}; - -class Convert : - public stem::EventHandler -{ - public: - Convert(); - Convert( stem::addr_type id ); - Convert( stem::addr_type id, const char *info ); - ~Convert(); - - void handler0(); - void handler1( const stem::Event& ); - void handler2( const stem::Event_base<mess>& ); - void handler3( const mess& ); - - void wait(); - - int v; - - std::string m2; - std::string m3; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Convert, stem::EventHandler ); -}; - -#define CONV_EV0 0x909 -#define CONV_EV1 0x90a -#define CONV_EV2 0x90b -#define CONV_EV3 0x90c - -#endif // __Convert_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Echo.cc =================================================================== --- trunk/complement/explore/test/stem/Echo.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,144 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/11/29 13:02:34 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Echo.h" - -#include <stem/NetTransport.h> -#include <stem/EvManager.h> - -#include <exam/suite.h> - -using namespace stem; - -StEMecho::StEMecho() -{ -} - -StEMecho::StEMecho( addr_type id ) : - EventHandler( id ) -{ -} - -StEMecho::StEMecho( addr_type id, const char *info ) : - EventHandler( id, info ) -{ -} - -void StEMecho::echo( const Event& ev ) -{ - Event eev( ev.code() ); - eev.value() = ev.value(); - - eev.dest( ev.src() ); - - Send( eev ); -} - -void StEMecho::regme( const stem::Event& ev ) -{ - // cerr << "Echo\n"; - manager()->change_announce( ev.src(), ev.value() ); - cnd.set( true ); -} - -DEFINE_RESPONSE_TABLE( StEMecho ) - EV_EDS( 0, NODE_EV_ECHO, echo ) - EV_EDS( 0, NODE_EV_REGME, regme ) -END_RESPONSE_TABLE - -EchoClient::EchoClient() : - EventHandler(), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::EchoClient( stem::addr_type id ) : - EventHandler( id ), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::EchoClient( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - mess( "echo string" ) -{ - cnd.set( false ); -} - -EchoClient::~EchoClient() -{ - // cnd.wait(); -} - -void EchoClient::handler1( const stem::Event& ev ) -{ - EXAM_CHECK_ASYNC( ev.value() == mess ); - cnd.set(true); -} - -void EchoClient::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( EchoClient ) - EV_EDS(0,NODE_EV_ECHO,handler1) -END_RESPONSE_TABLE - -PeerClient::PeerClient() : - EventHandler(), - mess( "peer client" ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( stem::addr_type id ) : - EventHandler( id ), - mess( "peer client" ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( const char *info ) : - EventHandler( info ), - mess( info ) -{ - cnd.set( false ); -} - -PeerClient::PeerClient( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - mess( info ) -{ - cnd.set( false ); -} - -PeerClient::~PeerClient() -{ - // cnd.wait(); -} - -void PeerClient::handler1( const stem::Event& ev ) -{ - EXAM_CHECK_ASYNC( ev.value() == mess ); - - cnd.set(true); -} - -void PeerClient::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( PeerClient ) - EV_EDS(0,NODE_EV_ECHO,handler1) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Echo.h =================================================================== --- trunk/complement/explore/test/stem/Echo.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,83 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:45:09 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Echo_h -#define __Echo_h - -#include <string> -#include <mt/xmt.h> -#include <stem/EventHandler.h> -// #include <stem/Names.h> -// #include <list> - -class StEMecho : - public stem::EventHandler -{ - public: - StEMecho(); - StEMecho( stem::addr_type id ); - StEMecho( stem::addr_type id, const char * ); - - void echo( const stem::Event& ); - void regme( const stem::Event& ); - - xmt::condition cnd; - - private: - DECLARE_RESPONSE_TABLE( StEMecho, stem::EventHandler ); -}; - -class EchoClient : - public stem::EventHandler -{ - public: - EchoClient(); - EchoClient( stem::addr_type id ); - EchoClient( stem::addr_type id, const char *info ); - ~EchoClient(); - - void handler1( const stem::Event& ); - - void wait(); - - const std::string mess; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( EchoClient, stem::EventHandler ); -}; - -class PeerClient : - public stem::EventHandler -{ - public: - PeerClient(); - PeerClient( stem::addr_type id ); - PeerClient( const char *info ); - PeerClient( stem::addr_type id, const char *info ); - ~PeerClient(); - - void handler1( const stem::Event& ); - - void wait(); - - const std::string mess; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( PeerClient, stem::EventHandler ); -}; - -#define NODE_EV_ECHO 0x903 -#define NODE_EV_REGME 0x904 - -#endif // __Echo_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,48 +0,0 @@ -# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> - -SRCROOT := ../.. - -EXTRA_POST := dl-rel -EXTRA_POST_DBG := dl-dbg -EXTRA_POST_STLDBG := dl-stldbg - -include Makefile.inc -include ${SRCROOT}/Makefiles/gmake/top.mak - -INCLUDES += -I$(SRCROOT)/include -DEFS += -D__FIT_EXAM - -LIBMT_DIR = ${CoMT_DIR}/lib/mt -LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios -LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -LIBEXAM_DIR = ${CoMT_DIR}/lib/exam - -ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -ifndef WITHOUT_STLPORT -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -endif -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} -endif - -release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl -ifndef WITHOUT_STLPORT -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl -endif -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl - -# dbg-shared: DEFS += -DDEBUG - -PHONY += dl-rel dl-dbg dl-stldbg - -dl-rel: - ${MAKE} -C dl release-shared - -dl-dbg: - ${MAKE} -C dl dbg-shared - -dl-stldbg: - ${MAKE} -C dl stldbg-shared - -depend clean distclean mostlyclean maintainer-clean:: - ${MAKE} -C dl $@ Deleted: trunk/complement/explore/lib/stem/ut/stem/Makefile.inc =================================================================== --- trunk/complement/explore/test/stem/Makefile.inc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile.inc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,8 +0,0 @@ -# -*- makefile -*- Time-stamp: <07/07/20 00:14:24 ptr> - -PRGNAME = stem_ut -SRC_CC = unit_test.cc \ - Node.cc \ - NameService.cc \ - Echo.cc \ - Convert.cc Deleted: trunk/complement/explore/lib/stem/ut/stem/NameService.cc =================================================================== --- trunk/complement/explore/test/stem/NameService.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,61 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/11/29 10:50:21 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include <iostream> -#include <functional> -#include <iterator> - -#include <stem/EDSEv.h> -#include "NameService.h" - -using namespace std; -using namespace stem; -using namespace xmt; - -Naming::Naming() : - EventHandler() -{ - cnd.set( false ); -} - -Naming::Naming( stem::addr_type id ) : - EventHandler( id ) -{ - cnd.set( false ); -} - -Naming::~Naming() -{ - // cnd.wait(); -} - -void Naming::names_list( const nsrecords_type& nr ) -{ - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); - - cnd.set(true); -} - -void Naming::names_name( const nsrecords_type& nr ) -{ - copy( nr.container.begin(), nr.container.end(), back_insert_iterator<nsrecords_type::container_type>(lst) ); - - cnd.set(true); -} - -void Naming::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( Naming ) - EV_T_(0,EV_STEM_NS_LIST,names_list,nsrecords_type) - EV_T_(0,EV_STEM_NS_NAME,names_name,nsrecords_type) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/NameService.h =================================================================== --- trunk/complement/explore/test/stem/NameService.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,44 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:37 ptr> - -/* - * Copyright (c) 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __NameService_h -#define __NameService_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> -#include <stem/Names.h> -#include <list> - -class Naming : - public stem::EventHandler -{ - public: - Naming(); - Naming( stem::addr_type id ); - ~Naming(); - - typedef stem::NameRecords<stem::gaddr_type,std::string> nsrecords_type; - - void names_list( const nsrecords_type& ); - void names_name( const nsrecords_type& ); - - void wait(); - void reset() - { cnd.set( false ); } - - nsrecords_type::container_type lst; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Naming, stem::EventHandler ); -}; - -#endif // __NameService_h Deleted: trunk/complement/explore/lib/stem/ut/stem/Node.cc =================================================================== --- trunk/complement/explore/test/stem/Node.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Node.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,97 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/09/29 23:23:57 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include "Node.h" - -using namespace std; -using namespace stem; -using namespace xmt; - -Node::Node() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -Node::Node( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -Node::Node( stem::addr_type id, const char *info ) : - EventHandler( id, info ), - v( 0 ) -{ - cnd.set( false ); -} - -Node::~Node() -{ - // cnd.wait(); -} - -void Node::handler1( const stem::Event& ) -{ - // std::cerr << "I am here 1\n"; - v = 1; - cnd.set(true); - // std::cerr << "I am here 2\n"; -} - -void Node::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( Node ) - EV_EDS(0,NODE_EV1,handler1) -END_RESPONSE_TABLE - -// the same as Node, just another class - -NewNode::NewNode() : - EventHandler(), - v( 0 ) -{ - cnd.set( false ); -} - -NewNode::NewNode( stem::addr_type id ) : - EventHandler( id ), - v( 0 ) -{ - cnd.set( false ); -} - -NewNode::~NewNode() -{ - // cnd.wait(); -} - -void NewNode::handler1( const stem::Event& ) -{ - // std::cerr << "I am here 1\n"; - v = 1; - cnd.set(true); - // std::cerr << "I am here 2\n"; -} - -void NewNode::wait() -{ - cnd.try_wait(); -} - -DEFINE_RESPONSE_TABLE( NewNode ) - EV_EDS(0,NODE_EV1,handler1) -END_RESPONSE_TABLE Deleted: trunk/complement/explore/lib/stem/ut/stem/Node.h =================================================================== --- trunk/complement/explore/test/stem/Node.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/Node.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,62 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:25 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __Node_h -#define __Node_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> - -class Node : - public stem::EventHandler -{ - public: - Node(); - Node( stem::addr_type id ); - Node( stem::addr_type id, const char *info ); - ~Node(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( Node, stem::EventHandler ); -}; - -// the same as Node, just another class -class NewNode : - public stem::EventHandler -{ - public: - NewNode(); - NewNode( stem::addr_type id ); - ~NewNode(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NewNode, stem::EventHandler ); -}; - -#define NODE_EV1 0x900 - -#endif // __Node_h Deleted: trunk/complement/explore/lib/stem/ut/stem/NodeDL.h =================================================================== --- trunk/complement/explore/test/stem/NodeDL.h 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/NodeDL.h 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,66 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:47:58 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#ifndef __NodeDL_h -#define __NodeDL_h - -#include <mt/xmt.h> -#include <stem/EventHandler.h> - -class NodeDL : - public stem::EventHandler -{ - public: - NodeDL(); - NodeDL( stem::addr_type id ); - ~NodeDL(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NodeDL, stem::EventHandler ); -}; - -// the same as Node, just another class -class NewNodeDL : - public stem::EventHandler -{ - public: - NewNodeDL(); - NewNodeDL( stem::addr_type id ); - ~NewNodeDL(); - - void handler1( const stem::Event& ); - - void wait(); - - int v; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( NewNodeDL, stem::EventHandler ); -}; - -#define NODE_EV2 0x901 - -extern "C" void *create_NewNodeDL( unsigned ); -extern "C" void wait_NewNodeDL( void * ); -extern "C" int v_NewNodeDL( void * ); -extern "C" void destroy_NewNodeDL( void * ); - -#endif // __NodeDL_h Deleted: trunk/complement/explore/lib/stem/ut/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-08-03 18:26:43 UTC (rev 1668) +++ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc 2007-08-03 20:05:01 UTC (rev 1670) @@ -1,835 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/20 00:21:37 ptr> - -/* - * Copyright (c) 2002, 2003, 2006, 2007 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License version 3.0 - * - */ - -#include <exam/suite.h> - -#include <iostream> -#include <mt/xmt.h> -#include <mt/shm.h> - -#include <stem/EventHandler.h> -#include <stem/Names.h> -#include <stem/EDSEv.h> - -#include "Node.h" -#include "NodeDL.h" -#include "NameService.h" - -#include <dlfcn.h> - -#include "Echo.h" -#include "Convert.h" - -#include <stem/NetTransport.h> -#include <stem/EvManager.h> -#include <sockios/sockmgr.h> - -#ifndef STLPORT -#include <ext/functional> -using namespace __gnu_cxx; -#endif - -#include <sys/wait.h> - -#include <signal.h> - -using namespace std; - -class stem_test -{ - public: - stem_test(); - ~stem_test(); - - int EXAM_DECL(basic1); - int EXAM_DECL(basic2); - int EXAM_DECL(basic1new); - int EXAM_DECL(basic2new); - int EXAM_DECL(dl); - int EXAM_DECL(ns); - - int EXAM_DECL(echo); - int EXAM_DECL(echo_net); - int EXAM_DECL(net_echo); - int EXAM_DECL(peer); - int EXAM_DECL(boring_manager); - int EXAM_DECL(convert); - - static xmt::Thread::ret_code thr1( void * ); - static xmt::Thread::ret_code thr1new( void * ); - - private: -}; - -int EXAM_IMPL(stem_test::basic1) -{ - Node node( 2000 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node.Send( ev ); - - node.wait(); - EXAM_CHECK( node.v == 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::basic2) -{ - Node node( 2000 ); - - xmt::Thread t1( thr1 ); - - EXAM_CHECK( t1.join().iword == 0 ); - - node.wait(); - - EXAM_CHECK( node.v == 1 ); - - return EXAM_RESULT; -} - -xmt::Thread::ret_code stem_test::thr1( void * ) -{ - xmt::Thread::ret_code rt; - rt.iword = 0; - - Node node( 2001 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node.Send( ev ); - - return rt; -} - -int EXAM_IMPL(stem_test::basic1new) -{ - NewNode *node = new NewNode( 2000 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node->Send( ev ); - - node->wait(); - - EXAM_CHECK( node->v == 1 ); - delete node; - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::basic2new) -{ - NewNode *node = new NewNode( 2000 ); - - xmt::Thread t1( thr1new ); - - t1.join(); - - node->wait(); - EXAM_CHECK( node->v == 1 ); - delete node; - - return EXAM_RESULT; -} - -xmt::Thread::ret_code stem_test::thr1new( void * ) -{ - xmt::Thread::ret_code rt; - rt.iword = 0; - - NewNode *node = new NewNode( 2001 ); - - EDS::Event ev( NODE_EV1 ); - - ev.dest( 2000 ); - node->Send( ev ); - - delete node; - - return rt; -} - -int EXAM_IMPL(stem_test::dl) -{ - void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= - - EXAM_REQUIRE( lh != NULL ); - void *(*f)(unsigned); - void (*g)(void *); - void (*w)(void *); - int (*v)(void *); - - *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); - EXAM_REQUIRE( f != NULL ); - *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); - EXAM_REQUIRE( g != NULL ); - *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); - EXAM_REQUIRE( w != NULL ); - *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); - EXAM_REQUIRE( v != NULL ); - - NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); - stem::Event ev( NODE_EV2 ); - ev.dest( 2002 ); - node->Send( ev ); - - w( reinterpret_cast<void *>(node) ); - EXAM_CHECK( v(reinterpret_cast<void *>(node)) == 1 ); - - g( reinterpret_cast<void *>(node) ); - dlclose( lh ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::ns) -{ - Node node( 2003, "Node" ); - Naming nm; - - stem::Event ev( EV_STEM_GET_NS_LIST ); - ev.dest( stem::ns_addr ); - nm.Send( ev ); - - nm.wait(); - - // this is sample of all inline find: - Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "ns" ); - EXAM_CHECK( i->first.hid == xmt::hostid() ); - EXAM_CHECK( i->first.pid == getpid() ); - EXAM_CHECK( i->first.addr == stem::ns_addr ); - - // well, but for few seaches declare and reuse functors: - equal_to<string> eq; - equal_to<stem::gaddr_type> eqa; - - select1st<pair<stem::gaddr_type,string> > first; - select2nd<pair<stem::gaddr_type,string> > second; - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "Node" ); - EXAM_CHECK( i->first.addr == 2003 ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->first == nm.self_glid() ); - EXAM_CHECK( i->second.length() == 0 ); - - nm.lst.clear(); - nm.reset(); - - EXAM_CHECK( nm.lst.empty() ); - - stem::Event evname( EV_STEM_GET_NS_NAME ); - evname.dest( stem::ns_addr ); - evname.value() = "Node"; - nm.Send( evname ); - - nm.wait(); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); - - EXAM_CHECK( i == nm.lst.end() ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - - EXAM_CHECK( i != nm.lst.end() ); - EXAM_CHECK( i->second == "Node" ); - EXAM_CHECK( i->first.addr == 2003 ); - - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - - EXAM_CHECK( i == nm.lst.end() ); - - nm.lst.clear(); - nm.reset(); - - EXAM_CHECK( nm.lst.empty() ); - - evname.value() = "No-such-name"; - nm.Send( evname ); - - nm.wait(); - - EXAM_CHECK( nm.lst.empty() ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::echo) -{ - try { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - stem::NetTransportMgr mgr; - - StEMecho echo( 0, "echo service"); // <= zero! - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_CHECK( zero != stem::badaddr ); - EXAM_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery - - EchoClient node; - - stem::Event ev( NODE_EV_ECHO ); - - ev.dest( zero ); - ev.value() = node.mess; - - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - - srv.close(); - srv.wait(); - } - catch ( ... ) { - } - - return EXAM_RESULT; -} - -const char fname[] = "/tmp/stem_test.shm"; -xmt::shm_alloc<0> seg; -xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; -xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; - -stem_test::stem_test() -{ - try { - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); - } - catch ( const xmt::shm_bad_alloc& err ) { - EXAM_ERROR_ASYNC( err.what() ); - } -} - -stem_test::~stem_test() -{ - seg.deallocate(); - unlink( fname ); -} - -int EXAM_IMPL(stem_test::echo_net) -{ - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - try { - xmt::fork(); - - try { - stem::NetTransportMgr mgr; - - fcnd.try_wait(); - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery - - EchoClient node; - - stem::Event ev( NODE_EV_ECHO ); - - ev.dest( zero ); - ev.value() = node.mess; - - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - try { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - - StEMecho echo( 0, "echo service"); // <= zero! - - fcnd.set( true ); - - int stat; - EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - - srv.close(); - srv.wait(); - } - catch ( ... ) { - } - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - - // cerr << "Fine\n"; - - return EXAM_RESULT; -} - -// same as echo_net(), but server in child process - -int EXAM_IMPL(stem_test::net_echo) -{ - try { - xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); - xmt::__condition<true>& c = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - - c.set( false ); - - try { - xmt::fork(); - - // server part - { - std::sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); - StEMecho echo( 0, "echo service"); - - // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); - // echo.manager()->settrs( &std::cerr ); - - EXAM_CHECK_ASYNC( srv.good() ); - c.set( true ); // ok, server listen - - b.wait(); // server may go away - - srv.close(); - srv.wait(); - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - // client part - - stem::NetTransportMgr mgr; - // mgr.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch | stem::EvManager::tracefault ); - // mgr.manager()->settrs( &std::cerr ); - - c.try_wait(); // wait server start - - stem::addr_type zero = mgr.open( "localhost", 6995 ); - - EXAM_REQUIRE( mgr.good() ); - EXAM_REQUIRE( zero != stem::badaddr ); - - EchoClient node; - stem::Event ev( NODE_EV_ECHO ); - ev.dest( zero ); - - ev.value() = node.mess; - node.Send( ev ); - - node.wait(); - - mgr.close(); - mgr.join(); - - b.wait(); // server may go away - - int stat; - EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - } - - (&c)->~__condition<true>(); - shm_cnd.deallocate( &c, 1 ); - (&b)->~__barrier<true>(); - shm_b.deallocate( &b, 1 ); - } - catch ( xmt::shm_bad_alloc& err ) { - EXAM_ERROR( err.what() ); - } - - return EXAM_RESULT; -} - -extern "C" { - -static void dummy_signal_handler( int ) -{ } - -} - -int EXAM_IMPL(stem_test::peer) -{ - /* - * Scheme: - * / NetTransport / c1 - * Local Event Manager - NetTransportMgr - c2 - * \ echo - * Due to all objects in the same process space, - * c1, c2 and echo in different processes. - * - * The logical scheme is: - * - * / c1 - * echo - * \ c2 - * - * (c1 <-> c2, through 'echo') - */ - - pid_t fpid; - - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - xmt::__condition<true>& pcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - pcnd.set( false ); - - xmt::__condition<true>& scnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - scnd.set( false ); - - try { - // Client 1 - xmt::fork(); -#if 0 - struct sigaction action; - struct sigaction old_action; - action.sa_flags = 0; - action.sa_handler = &dummy_signal_handler; - sigemptyset( &action.sa_mask ); - - sigaction( SIGFPE, &action, &old_action ); - sigaction( SIGTRAP, &action, &old_action ); - sigaction( SIGSEGV, &action, &old_action ); - sigaction( SIGBUS, &action, &old_action ); - sigaction( SIGABRT, &action, &old_action ); - sigaction( SIGALRM, &action, &old_action ); -#endif - - try { - stem::NetTransportMgr mgr; - - PeerClient c1( "c1 local" ); // c1 client - Naming nm; - - fcnd.try_wait(); - - stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server - // It done like it should on client side - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address - - stem::Event ev( NODE_EV_REGME ); - ev.dest( zero ); - - ev.value() = "c1@here"; - c1.Send( ev ); // 'register' c1 client on 'echo' server - - stem::gaddr_type ga( c1.manager()->reflect( zero ) ); - - EXAM_CHECK_ASYNC( ga.addr == 0 ); - EXAM_CHECK_ASYNC( ga.pid != -1 ); - - ga.addr = stem::ns_addr; // this will be global address of ns of the same process - // as zero - - EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); - - stem::Event evname( EV_STEM_GET_NS_NAME ); - evname.dest( c1.manager()->reflect( ga ) ); - evname.value() = "c2@here"; - - pcnd.try_wait(); - - Naming::nsrecords_type::const_iterator i; - - do { - nm.reset(); - nm.lst.clear(); - nm.Send( evname ); - nm.wait(); - i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - } while ( i == nm.lst.end() ); - - EXAM_CHECK_ASYNC( i != nm.lst.end() ); - EXAM_CHECK_ASYNC( i->second == "c2@here" ); - - stem::addr_type pa = c1.manager()->reflect( i->first ); - if ( pa == stem::badaddr ) { // unknown yet - pa = c1.manager()->SubscribeRemote( i->first, i->second ); - if ( pa == stem::badaddr ) { // it still unknown, transport not found - // hint: use transport as object zero used - pa = c1.manager()->SubscribeRemote( c1.manager()->transport( zero ), i->first, i->second ); - } - } - - EXAM_CHECK_ASYNC( pa != stem::badaddr ); - - if ( pa != stem::badaddr ) { - stem::Event pe( NODE_EV_ECHO ); - pe.dest( pa ); - pe.value() = "c2 local"; // <<-- mess is like name ... | - // . - c1.Send( pe ); - } - - scnd.try_wait(); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - fpid = child.pid(); - } - - try { - // Client 2 - xmt::fork(); - -#if 0 - struct sigaction action; - struct sigaction old_action; - action.sa_flags = 0; - action.sa_handler = &dummy_signal_handler; - sigemptyset( &action.sa_mask ); - - sigaction( SIGFPE, &action, &old_action ); - sigaction( SIGTRAP, &action, &old_action ); - sigaction( SIGSEGV, &action, &old_action ); - sigaction( SIGBUS, &action, &old_action ); - sigaction( SIGABRT, &action, &old_action ); - sigaction( SIGALRM, &action, &old_action ); -#endif - - try { - stem::NetTransportMgr mgr; - // ^ - PeerClient c2( "c2 local" ); // <<--- name the same as mess expected ... | - - fcnd.try_wait(); - stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server - // It done like it should on client side - - EXAM_CHECK_ASYNC( zero != stem::badaddr ); - EXAM_CHECK_ASYNC( zero != 0 ); - EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address - - stem::Event ev( NODE_EV_REGME ); - ev.dest( zero ); - - ev.value() = "c2@here"; - c2.Send( ev ); // 'register' c2 client on 'echo' server - - pcnd.set( true ); - - c2.wait(); - // cerr << "Fine!" << endl; - scnd.set( true ); - - mgr.close(); - mgr.join(); - } - catch ( ... ) { - } - - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' - StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) - - fcnd.set( true, true ); - - int stat; - waitpid( child.pid(), &stat, 0 ); - waitpid( fpid, &stat, 0 ); - - srv.close(); - srv.wait(); - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - (&pcnd)->~__condition<true>(); - shm_cnd.deallocate( &pcnd, 1 ); - (&scnd)->~__condition<true>(); - shm_cnd.deallocate( &scnd, 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::boring_manager) -{ - xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - fcnd.set( false ); - - try { - // Client - xmt::fork(); - try { - fcnd.try_wait(); - - for ( int i = 0; i < 10; ++i ) { - const int n = 10; - stem::NetTransportMgr *mgr[n]; - mgr[0] = new stem::NetTransportMgr; - mgr[0]->open( "localhost", 6995 ); - - for ( int j = 1; j < n; ++j ) { - mgr[j] = new stem::NetTransportMgr; - stem::addr_type a = mgr[j]->open( "localhost", 6995 ); - mgr[j]->close(); - mgr[j]->join(); - delete mgr[j]; - } - mgr[0]->close(); - mgr[0]->join(); - delete mgr[0]; - } - } - catch ( ... ) { - } - exit( 0 ); - } - catch ( xmt::fork_in_parent& child ) { - sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); // server, it serve 'echo' - StEMecho echo( 0, "echo service"); // <= zero! 'echo' server, default ('zero' address) - - fcnd.set( true, true ); - - int stat; - waitpid( child.pid(), &stat, 0 ); - - srv.close(); - srv.wait(); - } - - (&fcnd)->~__condition<true>(); - shm_cnd.deallocate( &fcnd, 1 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(stem_test::convert) -{ - Convert conv; - mess m; - - m.super_id = 2; - m.message = "hello"; - - stem::Event_base<mess> ev( CONV_EV0 ); - - ev.dest( conv.self_id() ); - ev.value() = m; - - conv.Send( ev ); - - conv.wait(); - - EXAM_CHECK( conv.v == -1 ); - - stem::Event_base<mess> ev1( CONV_EV1 ); - - ev1.dest( conv.self_id() ); - ev1.value() = m; - - conv.Send( ev1 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 1 ); - - stem::Event_base<mess> ev2( CONV_EV2 ); - - ev2.dest( conv.self_id() ); - ev2.value() = m; - - conv.Send( ev2 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 2 ); - EXAM_CHECK( conv.m2 == "hello" ); - - stem::Event_base<mess> ev3( CONV_EV3 ); - - ev3.dest( conv.self_id() ); - ev3.value().super_id = 3; - ev3.value().message = ", wold!"; - - conv.Send( ev3 ); - - conv.wait(); - - EXAM_CHECK( conv.v == 3 ); - EXAM_CHECK( conv.m3 == ", wold!" ); - - return EXAM_RESULT; -} - -// ----------------- - -// ----------------- - -int EXAM_DECL(stem_test_suite); - -int EXAM_IMPL(stem_test_suite) -{ - exam::test_suite::test_case_type tc[4]; - - exam::test_suite t( "libstem test suite" ); - stem_test test; - - tc[1] = t.add( &stem_test::basic2, test, "basic2", - tc[0] = t.add( &stem_test::basic1, test, "basic1" ) ); - - tc[2] = t.add( &stem_test::basic1new, test, "basic1new", tc[0] ); - - t.add( &stem_test::dl, test, "dl", - t.add( &stem_test::basic2new, test, "basic2new", tc + 1, tc + 3 ) ); - t.add( &stem_test::ns, test, "ns", tc[0] ); - - t.add( &stem_test::net_echo, test, "net echo", - t.add( &stem_test::echo_net, test, "echo_net", - tc[3] = t.add( &stem_test::echo, test, "echo", tc[1] ) ) ); - - t.add( &stem_test::boring_manager, test, "boring_manager", - t.add( &stem_test::peer, test, "peer", tc[3] ) ); - - t.add( &stem_test::convert, test, "convert", tc[0] ); - - return t.girdle(); -} - -int main( int, char ** ) -{ - return stem_test_suite(0); -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-06 07:01:17
|
Revision: 1675 http://complement.svn.sourceforge.net/complement/?rev=1675&view=rev Author: complement Date: 2007-08-06 00:01:16 -0700 (Mon, 06 Aug 2007) Log Message: ----------- more traits; established unit tests for type_traits workaround Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Added Paths: ----------- trunk/complement/explore/lib/misc/ut/ trunk/complement/explore/lib/misc/ut/Makefile trunk/complement/explore/lib/misc/ut/Makefile.inc trunk/complement/explore/lib/misc/ut/misc_test.cc trunk/complement/explore/lib/misc/ut/misc_test.h trunk/complement/explore/lib/misc/ut/misc_test_suite.cc trunk/complement/explore/lib/misc/ut/misc_test_suite.h trunk/complement/explore/lib/misc/ut/unit_test.cc Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-06 06:57:59 UTC (rev 1674) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 08:59:36 ptr> +// -*- C++ -*- Time-stamp: <07/08/06 10:30:28 ptr> /* * Copyright (c) 2007 @@ -15,22 +15,69 @@ #include <config/feature.h> #endif -#if !defined(STLPORT) /* || (_STLPORT_VERSION < 50200) */ +#if 1 /* !defined(STLPORT) */ /* || (_STLPORT_VERSION < 50200) */ // libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, // libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, // while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead -# if !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) +# if 1 /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ namespace std { namespace tr1 { +namespace detail { + +struct __select_types +{ + typedef char __t1; + struct __t2 + { + char __two[2]; + }; +}; + +template <class _Tp> +struct __instance : + public __select_types +{ + private: + template <class _Up> + static __t1 __test(_Up(*)[1]); + + template <class> + static __t2 __test(...); + + public: + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +}; + +template <class T> +struct __uoc_aux : // union or class + public __select_types +{ + private: + template <class _Up> + static __t1 __test( int _Up::* ); + + template <class> + static __t2 __test(...); + + public: + static const bool __value = sizeof(__test<T>(0)) == 1; +}; + +template <class T> +class __empty +{ }; + +} // namespace detail + template <class _Tp, _Tp __v> struct integral_constant { static const _Tp value = __v; - // enum { value = __v }; + // enum { value = __v }; ? typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; @@ -39,6 +86,15 @@ typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; +namespace detail { + +template<typename _Tp> +struct __is_union_or_class : + public integral_constant<bool, __uoc_aux<_Tp>::__value> +{ }; + +} // namespace detail + #define __SPEC_(C,T,B) \ template <> \ struct C<T> : \ @@ -75,6 +131,8 @@ __SPEC_2(C,T volatile,B); \ __SPEC_2(C,T const volatile,B) +// [4.5.1] primary type categories: + template <class _Tp> struct is_void : public false_type @@ -111,21 +169,6 @@ __SPEC_FULL(is_floating_point,long double,true); template <class _Tp> -struct is_arithmetic : - public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> -{ }; - -template <class _Tp> -struct is_fundamental : - public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> -{ }; - -template <class _Tp> -struct is_compound : - public integral_constant<bool, !is_fundamental<_Tp>::value> -{ }; - -template <class _Tp> struct is_array : public false_type { }; @@ -159,9 +202,9 @@ template <class _Tp> struct is_function : - public integral_constant<bool, !(/* __in_array<_Tp>::__value - || __is_union_or_class<_Tp>::value - || */ is_reference<_Tp>::value + public integral_constant<bool, !(detail::__instance<_Tp>::__value + || detail::__is_union_or_class<_Tp>::value + || is_reference<_Tp>::value || is_void<_Tp>::value)> { }; @@ -224,7 +267,21 @@ public integral_constant<bool, (is_member_object_pointer<_Tp>::value || is_member_function_pointer<_Tp>::value)> { }; +// 4.5.2 composite type categories + template <class _Tp> +struct is_arithmetic : + public integral_constant<bool, (is_integral<_Tp>::value || is_floating_point<_Tp>::value)> +{ }; + +template <class _Tp> +struct is_fundamental : + public integral_constant<bool, (is_arithmetic<_Tp>::value || is_void<_Tp>::value)> +{ }; + +// [4.5.1] primary type categories (continued): + +template <class _Tp> struct is_enum : public integral_constant<bool, !(is_fundamental<_Tp>::value || is_array<_Tp>::value @@ -232,13 +289,28 @@ || is_reference<_Tp>::value || is_member_pointer<_Tp>::value || is_function<_Tp>::value - /* || __is_union_or_class<_Tp>::value */) > + || detail::__is_union_or_class<_Tp>::value) > { }; +template <class T> +struct is_union +{ }; + +template <class T> +struct is_class +{ }; + +// is_function (above) + +// 4.5.2 composite type categories (continued) + +// is_arithmetic (above) +// is_fundamental (above) + template <class _Tp> struct is_object : - public integral_constant<bool, !(is_function<_Tp>::value /* || is_reference<_Tp>::value - || is_void<_Tp>::value */ )> + public integral_constant<bool, !(is_function<_Tp>::value || is_reference<_Tp>::value + || is_void<_Tp>::value)> { }; template <class _Tp> @@ -250,22 +322,13 @@ { }; template <class _Tp> -struct remove_all_extents -{ - typedef _Tp type; -}; +struct is_compound : + public integral_constant<bool, !is_fundamental<_Tp>::value> +{ }; -template <class _Tp, std::size_t _Size> -struct remove_all_extents<_Tp[_Size]> -{ - typedef typename remove_all_extents<_Tp>::type type; -}; +// is_member_pointer -template<typename _Tp> -struct remove_all_extents<_Tp[]> -{ - typedef typename remove_all_extents<_Tp>::type type; -}; +// 4.5.3 type properties: template <class _Tp> struct is_const : @@ -287,12 +350,62 @@ public true_type { }; + +// 4.7.3 array modifications: + template <class _Tp> +struct remove_extent +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Sz> +struct remove_extent<_Tp[_Sz]> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_extent<_Tp[]> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_all_extents +{ + typedef _Tp type; +}; + +template <class _Tp, std::size_t _Size> +struct remove_all_extents<_Tp[_Size]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +template<typename _Tp> +struct remove_all_extents<_Tp[]> +{ + typedef typename remove_all_extents<_Tp>::type type; +}; + +// 4.5.3 type properties (continued): + +template <class _Tp> struct is_pod : public integral_constant<bool, (is_void<_Tp>::value || is_scalar<typename remove_all_extents<_Tp>::type>::value)> { }; +template<typename _Tp> +struct is_empty + : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::__value + && (sizeof(detail::__empty<_Tp>) == sizeof(_Tp)))> +{ }; + +// is_polimorphic +// is_abstract + template <class _Tp> struct has_trivial_constructor : public integral_constant<bool, is_pod<_Tp>::value> @@ -355,6 +468,145 @@ __SPEC_FULL(is_unsigned,unsigned long,true); __SPEC_FULL(is_unsigned,unsigned long long,true); +// alignment_of +// rank +// extent + +// 4.6 type relations: + +template <class _Tp1, class _Tp2> +struct is_same : + public false_type +{ }; + +template <class _Tp> +struct is_same<_Tp, _Tp> : + public true_type +{ }; + +// is_base_of +// is_convertible + +// 4.7.1 const-volatile modifications + +template <class _Tp> +struct remove_const +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_const<_Tp const> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_volatile +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_volatile<_Tp volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_cv +{ + typedef typename remove_const<typename remove_volatile<_Tp>::type>::type type; +}; + +template <class _Tp> +struct add_const +{ + typedef _Tp const type; +}; + +template <class _Tp> +struct add_volatile +{ + typedef _Tp volatile type; +}; + +template <class _Tp> +struct add_cv +{ + typedef typename add_const<typename add_volatile<_Tp>::type>::type type; +}; + +// 4.7.2 reference modifications: + +template <class _Tp> +struct remove_reference +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_reference<_Tp&> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct add_reference +{ + typedef _Tp& type; +}; + +template <class _Tp> +struct add_reference<_Tp&> +{ + typedef _Tp& type; +}; + +// 4.7.3 array modifications (see above) + +// 4.7.4 pointer modifications: + +template <class _Tp> +struct remove_pointer +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp *> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * const> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct remove_pointer<_Tp * const volatile> +{ + typedef _Tp type; +}; + +template <class _Tp> +struct add_pointer +{ + typedef typename remove_reference<_Tp>::type * type; +}; + +// 4.8 other transformations: + +// aligned_storage + #undef __SPEC_FULL #undef __SPEC_ #undef __SPEC_FULL1 Property changes on: trunk/complement/explore/lib/misc/ut ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/misc/ut/Makefile =================================================================== --- trunk/complement/explore/lib/misc/ut/Makefile (rev 0) +++ trunk/complement/explore/lib/misc/ut/Makefile 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,60 @@ +# -*- Makefile -*- Time-stamp: <07/08/06 10:19:59 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + + +INCLUDES += -I$(SRCROOT)/include +DEFS += -D__FIT_EXAM + +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam + +ifeq ($(OSNAME),linux) + +release-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +endif + +endif + +ifeq ($(OSNAME),openbsd) + +release-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT +stldbg-shared: LDSEARCH += -Wl,-R:${STLPORT_LIB_DIR} +endif + +endif + +release-shared : LDLIBS = -lexam +dbg-shared : LDLIBS = -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lexamstlg +endif + +ifeq ($(OSNAME),freebsd) +release-shared : LDLIBS += -lthr +dbg-shared : LDLIBS += -lthr +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS += -lthr +endif +endif + +ifeq ($(OSNAME),sunos) +release-shared : LDLIBS += -lrt +dbg-shared : LDLIBS += -lrt +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS += -lrt +endif +endif + + Added: trunk/complement/explore/lib/misc/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/misc/ut/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/misc/ut/Makefile.inc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,5 @@ +# -*- makefile -*- Time-stamp: <07/07/16 22:12:31 ptr> + +PRGNAME = misc_ut +SRC_CC = unit_test.cc \ + misc_test.cc misc_test_suite.cc Added: trunk/complement/explore/lib/misc/ut/misc_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,62 @@ +// -*- C++ -*- Time-stamp: <07/08/06 10:26:25 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include "misc_test.h" + +#include <misc/type_traits.h> +#include <iostream> + +using namespace std; + +class MyType +{ + public: + + virtual int abstract() = 0; + + private: + int a; + int n; +}; + +class MyTypeOther +{ + public: + + private: + int a; + int n; +}; + +int f() +{ + return 0; +} + +template <class T> +static bool q( T v ) +{ + return std::tr1::detail::__instance<T>::__value; +} + +int EXAM_IMPL(misc_test::type_traits) +{ + EXAM_CHECK( std::tr1::detail::__instance<int []>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int *>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int&>::__value == false ); + EXAM_CHECK( std::tr1::detail::__instance<MyTypeOther>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<MyType>::__value == false ); + EXAM_CHECK( std::tr1::detail::__instance<int (*)()>::__value == true ); + EXAM_CHECK( std::tr1::detail::__instance<int (&)()>::__value == false ); + EXAM_CHECK( q(f) == true ); + + return EXAM_RESULT; +} Added: trunk/complement/explore/lib/misc/ut/misc_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.h (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,24 @@ +// -*- C++ -*- Time-stamp: <07/07/16 21:01:43 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#ifndef __MISC_TEST_H +#define __MISC_TEST_H + +#define FIT_EXAM + +#include <exam/suite.h> + +class misc_test +{ + public: + int EXAM_DECL(type_traits); +}; + +#endif // __MISC_TEST_H Added: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,26 @@ +// -*- C++ -*- Time-stamp: <07/07/17 10:20:08 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include "misc_test_suite.h" +#include "misc_test.h" + +#include <config/feature.h> + +int EXAM_IMPL(misc_test_suite) +{ + exam::test_suite t( "libmisc? test" ); + misc_test test; + + exam::test_suite::test_case_type tc[3]; + + tc[0] = t.add( &misc_test::type_traits, test, "misc_test::type_traits" ); + + return t.girdle(); +}; Added: trunk/complement/explore/lib/misc/ut/misc_test_suite.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.h (rev 0) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.h 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,18 @@ +// -*- C++ -*- Time-stamp: <07/07/16 22:08:39 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#ifndef __MISC_TEST_SUITE_H +#define __MISC_TEST_SUITE_H + +#include <exam/suite.h> + +int EXAM_DECL(misc_test_suite); + +#endif // __MISC_TEST_SUITE_H Added: trunk/complement/explore/lib/misc/ut/unit_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/misc/ut/unit_test.cc 2007-08-06 07:01:16 UTC (rev 1675) @@ -0,0 +1,19 @@ +// -*- C++ -*- Time-stamp: <07/07/16 22:12:10 ptr> + +/* + * Copyright (c) 2007 + * Petr Ovtchenkov + * + * Licensed under the Academic Free License Version 3.0 + * + */ + +#include <exam/suite.h> +#include <config/feature.h> + +#include "misc_test_suite.h" + +int main( int, char ** ) +{ + return misc_test_suite(0); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-06 11:18:15
|
Revision: 1676 http://complement.svn.sourceforge.net/complement/?rev=1676&view=rev Author: complement Date: 2007-08-06 04:18:14 -0700 (Mon, 06 Aug 2007) Log Message: ----------- working fixes; add test for is_empty Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h trunk/complement/explore/lib/misc/ut/misc_test.cc trunk/complement/explore/lib/misc/ut/misc_test.h trunk/complement/explore/lib/misc/ut/misc_test_suite.cc Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-06 11:18:14 UTC (rev 1676) @@ -399,7 +399,7 @@ template<typename _Tp> struct is_empty - : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::__value + : public integral_constant<bool, (detail::__is_union_or_class<_Tp>::value && (sizeof(detail::__empty<_Tp>) == sizeof(_Tp)))> { }; Modified: trunk/complement/explore/lib/misc/ut/misc_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test.cc 2007-08-06 11:18:14 UTC (rev 1676) @@ -11,7 +11,6 @@ #include "misc_test.h" #include <misc/type_traits.h> -#include <iostream> using namespace std; @@ -41,12 +40,12 @@ } template <class T> -static bool q( T v ) +bool q( T v ) { return std::tr1::detail::__instance<T>::__value; } -int EXAM_IMPL(misc_test::type_traits) +int EXAM_IMPL(misc_test::type_traits_internals) { EXAM_CHECK( std::tr1::detail::__instance<int []>::__value == true ); EXAM_CHECK( std::tr1::detail::__instance<int *>::__value == true ); @@ -60,3 +59,52 @@ return EXAM_RESULT; } + +class empty +{ +}; + +class not_empty1 +{ + private: + int k; +}; + +class not_empty2 +{ + private: + int f() const + { return 0; } +}; + +class not_empty3 +{ + private: + virtual int f() const + { return 0; } +}; + +class not_empty4 : + public not_empty2 +{ +}; + +class not_empty5 : + public not_empty3 +{ +}; + +int EXAM_IMPL(misc_test::type_traits_is_empty) +{ + EXAM_CHECK( std::tr1::is_empty<empty>::value == true ); + EXAM_CHECK( std::tr1::is_empty<not_empty1>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<not_empty2>::value == false ); + EXAM_CHECK( std::tr1::is_empty<not_empty3>::value == false ); + EXAM_CHECK( std::tr1::is_empty<int>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<int (&)()>::value == false ); + // EXAM_CHECK( std::tr1::is_empty<not_empty4>::value == false ); + EXAM_CHECK( std::tr1::is_empty<not_empty5>::value == false ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/lib/misc/ut/misc_test.h =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test.h 2007-08-06 11:18:14 UTC (rev 1676) @@ -18,7 +18,8 @@ class misc_test { public: - int EXAM_DECL(type_traits); + int EXAM_DECL(type_traits_internals); + int EXAM_DECL(type_traits_is_empty); }; #endif // __MISC_TEST_H Modified: trunk/complement/explore/lib/misc/ut/misc_test_suite.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 07:01:16 UTC (rev 1675) +++ trunk/complement/explore/lib/misc/ut/misc_test_suite.cc 2007-08-06 11:18:14 UTC (rev 1676) @@ -20,7 +20,8 @@ exam::test_suite::test_case_type tc[3]; - tc[0] = t.add( &misc_test::type_traits, test, "misc_test::type_traits" ); + t.add( &misc_test::type_traits_is_empty, test, "misc_test::type_traits_is_empty", + t.add( &misc_test::type_traits_internals, test, "misc_test::type_traits_internals" ) ); return t.girdle(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-16 19:18:54
|
Revision: 1682 http://complement.svn.sourceforge.net/complement/?rev=1682&view=rev Author: complement Date: 2007-08-16 12:18:49 -0700 (Thu, 16 Aug 2007) Log Message: ----------- experiments with virtual synchrony ready for library (janus subproject) Modified Paths: -------------- trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_object.cc Added Paths: ----------- trunk/complement/explore/include/janus/ trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ trunk/complement/explore/lib/janus/Makefile trunk/complement/explore/lib/janus/Makefile.inc trunk/complement/explore/lib/janus/ut/ trunk/complement/explore/lib/janus/ut/Makefile trunk/complement/explore/lib/janus/ut/Makefile.inc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_operations.h trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vtime.cc Removed Paths: ------------- trunk/complement/explore/lib/janus/ut/Makefile trunk/complement/explore/lib/janus/ut/Makefile.inc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_operations.h trunk/complement/explore/test/virtual_time/Makefile trunk/complement/explore/test/virtual_time/Makefile.inc trunk/complement/explore/test/virtual_time/test/Makefile trunk/complement/explore/test/virtual_time/test/Makefile.inc trunk/complement/explore/test/virtual_time/test/VTmess_core.cc trunk/complement/explore/test/virtual_time/test/unit_test.cc trunk/complement/explore/test/virtual_time/test/vt_dispatch.cc trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/test/vt_object.cc trunk/complement/explore/test/virtual_time/test/vt_operations.cc trunk/complement/explore/test/virtual_time/test/vt_operations.h trunk/complement/explore/test/virtual_time/test/vt_remote.cc trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Copied: trunk/complement/explore/include/janus/vtime.h (from rev 1680, trunk/complement/explore/test/virtual_time/vtime.h) =================================================================== --- trunk/complement/explore/include/janus/vtime.h (rev 0) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,413 @@ +// -*- C++ -*- Time-stamp: <07/08/11 01:05:47 ptr> + +#ifndef __vtime_h +#define __vtime_h + +#include <algorithm> +#include <list> +#include <vector> +#include <hash_map> +#include <hash_set> +#include <iterator> + +#include <istream> +#include <ostream> +#include <stdexcept> + +#include <stem/Event.h> +#include <stem/EventHandler.h> + +#include <mt/time.h> + +namespace vt { + +// typedef stem::addr_type oid_type; +typedef stem::gaddr_type oid_type; + +} // namespace vt + +namespace std { + +template <> +struct hash<vt::oid_type> +{ + size_t operator()(const vt::oid_type& __x) const + { return __x.addr; } +}; + +} // namespace std + +namespace vt { + +typedef uint32_t vtime_unit_type; +typedef stem::addr_type group_type; // required, used in VTSend +typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; + +bool operator <=( const vtime_type& l, const vtime_type& r ); +inline bool operator >=( const vtime_type& l, const vtime_type& r ) + { return r <= l; } +vtime_type operator -( const vtime_type& l, const vtime_type& r ); +vtime_type operator +( const vtime_type& l, const vtime_type& r ); +vtime_type& operator +=( vtime_type& l, const vtime_type& r ); + +// vt::vtime_type max( const vt::vtime_type& l, const vt::vtime_type& r ); +vtime_type& sup( vtime_type& l, const vtime_type& r ); + +struct vtime : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + vtime() + { } + vtime( const vtime& _vt ) : + vt( _vt.vt.begin(), _vt.vt.end() ) + { } + vtime( const vtime_type& _vt ) : + vt( _vt.begin(), _vt.end() ) + { } + + vtime& operator =( const vtime& _vt ) + { vt = _vt.vt; } + + // bool operator ==( const vtime& r ) const + // { return vt == r.vt; } + + bool operator <=( const vtime& r ) const + { return vt <= r.vt; } + bool operator >=( const vtime& r ) const + { return vt >= r.vt; } + + vtime operator -( const vtime& r ) const + { return vtime( vt - r.vt ); } + + vtime operator +( const vtime& r ) const + { return vtime( vt + r.vt ); } + + vtime& operator +=( const vtime_type& t ) + { + vt += t; + return *this; + } + vtime& operator +=( const vtime& t ) + { + vt += t.vt; + return *this; + } + + vtime& operator +=( const vtime_type::value_type& ); + + vtime_type::data_type& operator[]( const vtime_type::key_type& k ) + { return vt[k]; } + const vtime_type::data_type& operator[]( const vtime_type::key_type& k ) const + { return vt[k]; } + + + mutable vtime_type vt; +}; + + +// vtime max( const vtime& l, const vtime& r ); +vtime& sup( vtime& l, const vtime& r ); + +// typedef std::pair<group_type, vtime> vtime_group_type; +// typedef std::list<vtime_group_type> gvtime_type; +typedef std::hash_map<group_type, vtime> gvtime_type; + +gvtime_type& operator +=( gvtime_type&, const gvtime_type::value_type& ); +gvtime_type& operator +=( gvtime_type&, const gvtime_type& ); +gvtime_type operator -( const gvtime_type& l, const gvtime_type& r ); + +struct gvtime : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + gvtime() + { } + gvtime( const gvtime& _gvt ) : + gvt( _gvt.gvt.begin(), _gvt.gvt.end() ) + { } + + gvtime& operator =( const gvtime& _gvt ) + { gvt = _gvt.gvt; } + + gvtime& operator +=( const gvtime_type::value_type& ); + gvtime& operator +=( const gvtime& ); + + gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) + { return gvt[k]; } + const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const + { return gvt[k]; } + + mutable gvtime_type gvt; +}; + +struct VSsync_rq : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VSsync_rq() : + grp(0), + mess() + { } + VSsync_rq( const VSsync_rq& _gvt ) : + grp( _gvt.grp ), + mess( _gvt.mess ) + { } + + group_type grp; + std::string mess; +}; + +struct VSsync : + public VSsync_rq +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VSsync() + { } + VSsync( const VSsync& _gvt ) : + VSsync_rq( _gvt ), + gvt( _gvt.gvt ) + { } + + gvtime gvt; +}; + +struct VTmess : + public VSsync +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VTmess() : + code(0), + src() + { } + VTmess( const VTmess& _gvt ) : + VSsync( _gvt ), + code( _gvt.code ), + src( _gvt.src ) + { } + + stem::code_type code; + oid_type src; +}; + +namespace detail { + +class vtime_obj_rec +{ + public: + void add_group( group_type g ) + { groups.insert(g); } + void add( stem::addr_type a, group_type g ) + { addr = a; groups.insert(g); } + bool rm_group( group_type ); + void rm_member( const oid_type& ); + + template <typename BackInsertIterator> + void groups_list( BackInsertIterator bi ) const + { std::copy( groups.begin(), groups.end(), bi ); } + + stem::addr_type stem_addr() const + { return addr; } + + bool deliver( const VTmess& ev ); + bool deliver_delayed( const VTmess& ev ); + std::ostream& trace_deliver( const VTmess& m, std::ostream& o ); + void next( const oid_type& from, group_type grp ) + { ++vt.gvt[grp][from]; /* increment my VT counter */ } + void delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ); + void base_advance( const oid_type& to ) + { svt[to] = vt.gvt; /* store last sent VT to obj */ } + void get_gvt( gvtime_type& gvt ) const + { gvt = vt.gvt; } + void sync( group_type, const oid_type&, const gvtime_type& ); + +#ifdef __FIT_EXAM + const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const + { return vt[k]; } +#endif + + private: + typedef std::hash_set<group_type> groups_container_type; + typedef std::hash_map<oid_type, gvtime_type> delta_vtime_type; + typedef std::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; + + stem::addr_type addr; // stem address of object + delta_vtime_type lvt; // last recieve VT from neighbours + snd_delta_vtime_t svt; // last send VT to neighbours + gvtime vt; // VT of object + + groups_container_type groups; // member of groups + + public: + // delay pool should be here + typedef std::pair<xmt::timespec,stem::Event_base<VTmess>*> delay_item_t; + typedef std::list<delay_item_t> dpool_t; + + dpool_t dpool; + + private: + bool order_correct( const VTmess& ); + bool order_correct_delayed( const VTmess& ); +}; + +} // namespace detail + +class VTDispatcher : + public stem::EventHandler +{ + public: + enum traceflags { + notrace = 0, + tracenet = 1, + tracedispatch = 2, + tracefault = 4, + tracedelayed = 8, + tracegroup = 0x10 + }; + + VTDispatcher() : + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( const char *info ) : + stem::EventHandler( info ), + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( stem::addr_type id ) : + stem::EventHandler( id ), + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( stem::addr_type id, const char *info ) : + stem::EventHandler( id, info ), + _trflags( notrace ), + _trs( 0 ) + { } + + void VTDispatch( const stem::Event_base<VTmess>& ); + + void VTSend( const stem::Event& e, group_type ); + void Subscribe( stem::addr_type, oid_type, group_type ); + void Unsubscribe( oid_type, group_type ); + void Unsubscribe( oid_type ); + void get_gvtime( group_type, stem::addr_type, gvtime_type& ); + void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); + + void settrf( unsigned f ); + void unsettrf( unsigned f ); + void resettrf( unsigned f ); + void cleantrf(); + unsigned trflags() const; + void settrs( std::ostream * ); + + private: + typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef std::hash_multimap<group_type, oid_type> gid_map_type; + + void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); + void check_and_send_delayed( detail::vtime_obj_rec& ); + + vt_map_type vtmap; + gid_map_type grmap; + + xmt::mutex _lock_tr; + unsigned _trflags; + std::ostream *_trs; + + DECLARE_RESPONSE_TABLE( VTDispatcher, stem::EventHandler ); +}; + +class VTHandler : + public stem::EventHandler +{ + private: + class Init + { + public: + Init(); + ~Init(); + private: + static void _guard( int ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); + }; + + public: + VTHandler(); + explicit VTHandler( const char *info ); + explicit VTHandler( stem::addr_type id, const char *info = 0 ); + virtual ~VTHandler(); + + void VTSend( const stem::Event& e ); + void JoinGroup( group_type grp ) + { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } + virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSsync_time( const stem::Event_base<VSsync>& ); + + + template <class D> + void VTSend( const stem::Event_base<D>& e ) + { VTHandler::VTSend( stem::Event_convert<D>()( e ) ); } + + static VTDispatcher *vtdispatcher() + { return _vtdsp; } + + protected: + void VSNewMember_data( const stem::Event_base<VSsync_rq>&, const std::string& data ); + + void get_gvtime( group_type g, gvtime_type& gvt ) + { _vtdsp->get_gvtime( g, self_id(), gvt ); } + + private: + static class VTDispatcher *_vtdsp; + + DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); +}; + +#define VS_MESS 0x300 +#define VS_NEW_MEMBER 0x301 +#define VS_OUT_MEMBER 0x302 +#define VS_SYNC_TIME 0x303 + +} // namespace vt + +namespace std { + +ostream& operator <<( ostream&, const vt::vtime_type::value_type& ); +ostream& operator <<( ostream&, const vt::vtime_type& ); +ostream& operator <<( ostream&, const vt::vtime& ); +ostream& operator <<( ostream&, const vt::gvtime_type::value_type& ); +ostream& operator <<( ostream&, const vt::gvtime_type& ); +ostream& operator <<( ostream&, const vt::gvtime& ); +ostream& operator <<( ostream& o, const vt::VSsync& ); +ostream& operator <<( ostream& o, const vt::VTmess& ); + +} // namespace std + +#endif // __vtime_h Property changes on: trunk/complement/explore/lib/janus ___________________________________________________________________ Name: svn:ignore + obj Copied: trunk/complement/explore/lib/janus/Makefile (from rev 1672, trunk/complement/explore/test/virtual_time/Makefile) =================================================================== --- trunk/complement/explore/lib/janus/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,49 @@ +# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> + +SRCROOT := ../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +INCLUDES += -I$(SRCROOT)/include + +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios +LIBSTEM_DIR = ${CoMT_DIR}/lib/stem + +LDSEARCH += -L${CoMT_LIB_DIR} -Wl,--rpath=${CoMT_LIB_DIR} + +release-shared : LDLIBS = -lxmt -lsockios -lstem +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg +endif +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg + +check: all-shared + $(MAKE) -C test + (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 + (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 +ifndef WITHOUT_STLPORT + (cd test; ${OUTPUT_DIR_STLDBG}/ut_vt) || exit 1 +endif + +check-release-shared: release-shared + $(MAKE) -C test release-shared + (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 + +check-dbg-shared: dbg-shared + $(MAKE) -C test dbg-shared + (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg-shared: stldbg-shared + $(MAKE) -C test stldbg-shared + (cd test; ${OUTPUT_DIR_STLDBG}/ut_vtime) || exit 1 +endif + +depend:: + $(MAKE) -C test depend + +# dbg-shared: DEFS += -DDEBUG + Copied: trunk/complement/explore/lib/janus/Makefile.inc (from rev 1672, trunk/complement/explore/test/virtual_time/Makefile.inc) =================================================================== --- trunk/complement/explore/lib/janus/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,7 @@ +# -*- makefile -*- Time-stamp: <06/10/10 15:22:33 ptr> + +LIBNAME = janus +MAJOR = 0 +MINOR = 2 +PATCH = 0 +SRC_CC = vtime.cc Copied: trunk/complement/explore/lib/janus/ut (from rev 1672, trunk/complement/explore/test/virtual_time/test) Deleted: trunk/complement/explore/lib/janus/ut/Makefile =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,39 +0,0 @@ -# -*- Makefile -*- Time-stamp: <07/02/21 15:30:59 ptr> - -SRCROOT := ../../.. -COMPILER_NAME := gcc -# ALL_TAGS := install-release-shared install-dbg-shared -# CoMT_DIR := ../../external/complement/explore - -include Makefile.inc -include ${SRCROOT}/Makefiles/gmake/top.mak - -# DEFS += -DUNIT_TEST -INCLUDES += -I${CoMT_INCLUDE_DIR} -I${BOOST_INCLUDE_DIR} -I.. -DEFS += -D__FIT_EXAM - -LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} - -release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam -dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg -stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg - -LDLIBS = ${PROJECT_LIBS} - -check: all-shared - ${OUTPUT_DIR}/${PRGNAME} || exit 1 - ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 -ifndef WITHOUT_STLPORT - ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1; -endif - -check-release-shared: release-shared - ${OUTPUT_DIR}/${PRGNAME} || exit 1 - -check-dbg-shared: dbg-shared - ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 - -ifndef WITHOUT_STLPORT -check-stldbg-shared: stldbg-shared - ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1 -endif Copied: trunk/complement/explore/lib/janus/ut/Makefile (from rev 1678, trunk/complement/explore/test/virtual_time/test/Makefile) =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,46 @@ +# -*- Makefile -*- Time-stamp: <07/08/08 22:18:48 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc +# ALL_TAGS := install-release-shared install-dbg-shared +# CoMT_DIR := ../../external/complement/explore + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +# DEFS += -DUNIT_TEST +INCLUDES += -I${CoMT_INCLUDE_DIR} -I${BOOST_INCLUDE_DIR} -I.. +DEFS += -D__FIT_EXAM + +LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} + +release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam +dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg +endif + +dbg-shared: DEFS += -D__FIT_VS_TRACE +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + +LDLIBS = ${PROJECT_LIBS} + +check: all-shared + ${OUTPUT_DIR}/${PRGNAME} || exit 1 + ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 +ifndef WITHOUT_STLPORT + ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1; +endif + +check-release-shared: release-shared + ${OUTPUT_DIR}/${PRGNAME} || exit 1 + +check-dbg-shared: dbg-shared + ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg-shared: stldbg-shared + ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1 +endif Deleted: trunk/complement/explore/lib/janus/ut/Makefile.inc =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,11 +0,0 @@ -# -*- Makefile -*- - -PRGNAME = ut_vtime - -SRC_CC = ../vtime.cc \ - unit_test.cc \ - vt_operations.cc \ - VTmess_core.cc \ - vt_object.cc \ - vt_dispatch.cc \ - vt_handler.cc Copied: trunk/complement/explore/lib/janus/ut/Makefile.inc (from rev 1680, trunk/complement/explore/test/virtual_time/test/Makefile.inc) =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,12 @@ +# -*- Makefile -*- + +PRGNAME = ut_vtime + +SRC_CC = ../vtime.cc \ + unit_test.cc \ + vt_operations.cc \ + VTmess_core.cc \ + vt_object.cc \ + vt_dispatch.cc \ + vt_handler.cc \ + vt_remote Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/VTmess_core.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -3,7 +3,7 @@ #include "vt_operations.h" #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/unit_test.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,37 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:41:24 ptr> - -#include "vt_operations.h" - -int EXAM_DECL(vtime_test_suite); - -int EXAM_IMPL(vtime_test_suite) -{ - exam::test_suite::test_case_type tc[3]; - - exam::test_suite t( "virtual time operations" ); - - vtime_operations vt_oper; - - t.add( &vtime_operations::vt_max, vt_oper, "Max", - tc[1] = t.add( &vtime_operations::vt_add, vt_oper, "Additions", - tc[0] = t.add( &vtime_operations::vt_compare, vt_oper, "Compare" ) ) ); - t.add( &vtime_operations::vt_diff, vt_oper, "Differences", tc[0] ); - - t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", - tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - - t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ); - - return t.girdle(); -} - -int main( int, char ** ) -{ - - return vtime_test_suite(0); -} Copied: trunk/complement/explore/lib/janus/ut/unit_test.cc (from rev 1680, trunk/complement/explore/test/virtual_time/test/unit_test.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,41 @@ +// -*- C++ -*- Time-stamp: <07/08/16 09:04:40 ptr> + +#include "vt_operations.h" + +int EXAM_DECL(vtime_test_suite); + +int EXAM_IMPL(vtime_test_suite) +{ + exam::test_suite::test_case_type tc[3]; + + exam::test_suite t( "virtual time operations" ); + + vtime_operations vt_oper; + + t.add( &vtime_operations::vt_max, vt_oper, "Max", + tc[1] = t.add( &vtime_operations::vt_add, vt_oper, "Additions", + tc[0] = t.add( &vtime_operations::vt_compare, vt_oper, "Compare" ) ) ); + t.add( &vtime_operations::vt_diff, vt_oper, "Differences", tc[0] ); + + t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", + tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); + + t.add( &vtime_operations::remote, vt_oper, "remote", + t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", + t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", + t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))); + + return t.girdle(); +} + +int main( int, char ** ) +{ + + return vtime_test_suite(0); +} Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_dispatch.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -5,7 +5,7 @@ // #include <boost/lexical_cast.hpp> #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,191 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> - -#include "vt_operations.h" - -// #include <boost/lexical_cast.hpp> - -#include <iostream> -#include <vtime.h> - -using namespace vt; -using namespace std; - -class VTDummy : - public vt::VTHandler -{ - public: - VTDummy(); - VTDummy( stem::addr_type id ); - VTDummy( stem::addr_type id, const char *info ); - ~VTDummy(); - - void handler( const stem::Event& ); - void VTNewMember( const stem::Event& ); - void VTOutMember( const stem::Event& ); - - void wait(); - std::string msg; - int count; - int ocount; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); -}; - -#define VT_MESS3 0x1203 - -VTDummy::VTDummy() : - VTHandler(), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::VTDummy( stem::addr_type id ) : - VTHandler( id ), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::VTDummy( stem::addr_type id, const char *info ) : - VTHandler( id, info ), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::~VTDummy() -{ - // cnd.wait(); -} - -void VTDummy::handler( const stem::Event& ev ) -{ - msg = ev.value(); - - cnd.set( true ); -} - -void VTDummy::VTNewMember( const stem::Event& ev ) -{ - // cerr << "Hello" << endl; - ++count; -} - -void VTDummy::VTOutMember( const stem::Event& ev ) -{ - // cerr << "Hello" << endl; - ++ocount; -} - -void VTDummy::wait() -{ - cnd.try_wait(); - - cnd.set( false ); -} - -DEFINE_RESPONSE_TABLE( VTDummy ) - EV_EDS( ST_NULL, VT_MESS3, handler ) -END_RESPONSE_TABLE - -int EXAM_IMPL(vtime_operations::VTHandler1) -{ - VTDummy dummy1; - VTDummy dummy2; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - - EXAM_CHECK( dummy2.msg == "hello" ); - EXAM_CHECK( dummy1.msg == "" ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::VTHandler2) -{ - VTDummy dummy1; - VTDummy dummy2; - VTDummy dummy3; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - dummy3.wait(); - - EXAM_CHECK( dummy3.count == 0 ); - EXAM_CHECK( dummy3.msg == "hello" ); - EXAM_CHECK( dummy2.count == 1 ); - EXAM_CHECK( dummy2.msg == "hello" ); - EXAM_CHECK( dummy1.count == 2 ); - EXAM_CHECK( dummy1.msg == "" ); - - ev.dest( 100 ); // not this group member - try { - dummy1.VTSend( ev ); - EXAM_ERROR( "exception expected" ); - } - catch ( std::domain_error& ) { - } - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::VTSubscription) -{ - VTDummy dummy1; - VTDummy dummy2; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - EXAM_CHECK( dummy2.msg == "hello" ); - - { - VTDummy dummy3; - - ev.value() = "hi"; - dummy1.VTSend( ev ); - - dummy2.wait(); - // dummy3.wait(); - - // EXAM_CHECK( dummy3.msg == "hi" ); - EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS - EXAM_CHECK( dummy2.msg == "hi" ); - EXAM_CHECK( dummy1.msg == "" ); - } - - ev.value() = "yet more"; - dummy1.VTSend( ev ); - - dummy2.wait(); - EXAM_CHECK( dummy2.msg == "yet more" ); - EXAM_CHECK( dummy1.msg == "" ); - - EXAM_CHECK( dummy1.ocount == 1 ); - EXAM_CHECK( dummy2.ocount == 1 ); - - return EXAM_RESULT; -} - Copied: trunk/complement/explore/lib/janus/ut/vt_handler.cc (from rev 1679, trunk/complement/explore/test/virtual_time/test/vt_handler.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,357 @@ +// -*- C++ -*- Time-stamp: <07/08/11 23:21:59 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +#include <stem/EvManager.h> + +using namespace vt; +using namespace std; + +class VTDummy : + public vt::VTHandler +{ + public: + VTDummy(); + VTDummy( stem::addr_type id ); + VTDummy( stem::addr_type id, const char *info ); + ~VTDummy(); + + void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + void greeting(); + + void wait(); + std::string msg; + int count; + int ocount; + + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + + private: + xmt::condition cnd; + xmt::condition gr; + + DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); +}; + +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + +VTDummy::VTDummy() : + VTHandler(), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::VTDummy( stem::addr_type id ) : + VTHandler( id ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::VTDummy( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::~VTDummy() +{ + // cnd.wait(); +} + +void VTDummy::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void VTDummy::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello " << ev.src() << endl; + ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); +} + +void VTDummy::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + +void VTDummy::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +void VTDummy::greeting() +{ + gr.set( true ); +} + +DEFINE_RESPONSE_TABLE( VTDummy ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::VTHandler1) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTHandler2) +{ + VTDummy dummy1; + VTDummy dummy2; + VTDummy dummy3; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy3.count == 0 ); + EXAM_CHECK( dummy3.msg == "hello" ); + EXAM_CHECK( dummy2.count == 1 ); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.count == 2 ); + EXAM_CHECK( dummy1.msg == "" ); + + ev.dest( 100 ); // not this group member + try { + dummy1.VTSend( ev ); + EXAM_ERROR( "exception expected" ); + } + catch ( std::domain_error& ) { + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTSubscription) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + VTDummy dummy3; + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy2.wait(); + // dummy3.wait(); + + // EXAM_CHECK( dummy3.msg == "hi" ); + // EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + ev.value() = "yet more"; + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "yet more" ); + EXAM_CHECK( dummy1.msg == "" ); + + EXAM_CHECK( dummy1.ocount == 1 ); + EXAM_CHECK( dummy2.ocount == 1 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + { + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch ); + // dummy1.manager()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup2) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + // cerr << (void *)&dummy1 << " dummy1\n" + // << (void *)&dummy2 << " dummy2\n"; + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + // dummy1.manager()->settrs( &std::cerr ); + + // dummy1.vtdispatcher()->settrf( VTDispatcher::tracedispatch | VTDispatcher::tracefault | VTDispatcher::tracedelayed | VTDispatcher::tracegroup ); + // dummy1.vtdispatcher()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup3) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + + { + VTDummy dummy2; + + dummy2.wait_greeting(); + + ev.value() = "hello"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy2; + VTDummy dummy3; + + dummy2.wait_greeting(); + dummy3.wait_greeting(); + + ev.value() = "more"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "more" ); + EXAM_CHECK( dummy3.msg == "more" ); + EXAM_CHECK( dummy1.msg == "" ); + + dummy2.VTSend( ev ); + + dummy1.wait(); + } + + EXAM_CHECK( dummy1.msg == "more" ); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_object.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -5,7 +5,7 @@ // #include <boost/lexical_cast.hpp> #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/vt_operations.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,321 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> - -#include "vt_operations.h" - -// #include <boost/lexical_cast.hpp> - -#include <iostream> -#include <vtime.h> - -using namespace vt; -using namespace std; - -int EXAM_IMPL(vtime_operations::vt_compare) -{ - const oid_type t0(0); - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( vt2 <= vt1 ); - EXAM_CHECK( vt1 >= vt2 ); - EXAM_CHECK( vt2 >= vt1 ); - - vt2[t3] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( !(vt2 <= vt1) ); - EXAM_CHECK( vt2 >= vt1 ); - - vt1.clear(); - vt2.clear(); - - vt1[t1] = 1; - - vt2[t1] = 1; - vt2[t3] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( !(vt2 <= vt1) ); - - vt1[t2] = 1; - - EXAM_CHECK( !(vt1 <= vt2) ); - EXAM_CHECK( !(vt2 <= vt1) ); -} - -int EXAM_IMPL(vtime_operations::vt_add) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1 + vt2; - - EXAM_CHECK( vt1 <= vt3 ); - EXAM_CHECK( vt3 <= vt1 ); - - vt2[t2] = 1; - - vt3 = vt1 + vt2; - - vt4[t1] = 1; - vt4[t2] = 2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt4.clear(); - - vt2[t3] = 1; - - vt3 = vt1 + vt2; - - vt4[t1] = 1; - vt4[t2] = 2; - vt4[t3] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::vt_diff) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1 - vt2; - - EXAM_CHECK( vt1 <= vt3 ); - EXAM_CHECK( vt3 <= vt1 ); - - vt2[t1] = 1; - - vt3 = vt1 - vt2; - - vt4[t2] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2[t2] = 1; - - vt4.clear(); - - vt3 = vt1 - vt2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2.clear(); - - vt2[t3] = 1; - - try { - vt3 = vt1 - vt2; - EXAM_ERROR( "Virtual Times are incomparable" ); - } - catch ( const std::range_error& err ) { - EXAM_CHECK( true ); - } - - vt2.clear(); - - vt2[t2] = 2; - - try { - vt3 = vt1 - vt2; - EXAM_ERROR( "Virtual Times are incomparable" ); - } - catch ( const std::range_error& err ) { - EXAM_CHECK( true ); - } - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::vt_max) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t1] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t2] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t3] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t1] = 1; - vt4[t2] = 1; - vt4[t3] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2.clear(); - - vt2[t1] = 1; - vt2[t2] = 2; - - vt4.clear(); - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t1] = 1; - vt4[t2] = 2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2[t3] = 4; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t3] = 4; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::gvt_add) -{ - const oid_type t0(0); - const oid_type t1(1); - const oid_type t2(2); - - { - gvtime_type gvt1; - gvtime_type gvt2; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - gvt2[0] = vt2; - - gvt1 += gvt2; - - EXAM_CHECK( gvt1[0][t1] == 2 ); - EXAM_CHECK( gvt1[0][t2] == 2 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 0 ); - EXAM_CHECK( gvt1[1][t2] == 0 ); - } - { - gvtime_type gvt1; - gvtime_type gvt2; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - gvt2[1] = vt2; - - gvt1 += gvt2; - - EXAM_CHECK( gvt1[0][t1] == 1 ); - EXAM_CHECK( gvt1[0][t2] == 1 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 1 ); - EXAM_CHECK( gvt1[1][t2] == 1 ); - } - { - gvtime_type gvt1; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - - gvt1 += make_pair( 1, vt2 ); - - EXAM_CHECK( gvt1[0][t1] == 1 ); - EXAM_CHECK( gvt1[0][t2] == 1 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 1 ); - EXAM_CHECK( gvt1[1][t2] == 1 ); - } - - return EXAM_RESULT; -} Copied: trunk/complement/explore/lib/janus/ut/vt_operations.cc (from rev 1678, trunk/complement/explore/test/virtual_time/test/vt_operations.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,323 @@ +// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +using namespace vt; +using namespace std; + +int EXAM_IMPL(vtime_operations::vt_compare) +{ + const oid_type t0(0); + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( vt2 <= vt1 ); + EXAM_CHECK( vt1 >= vt2 ); + EXAM_CHECK( vt2 >= vt1 ); + + vt2[t3] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( !(vt2 <= vt1) ); + EXAM_CHECK( vt2 >= vt1 ); + + vt1.clear(); + vt2.clear(); + + vt1[t1] = 1; + + vt2[t1] = 1; + vt2[t3] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( !(vt2 <= vt1) ); + + vt1[t2] = 1; + + EXAM_CHECK( !(vt1 <= vt2) ); + EXAM_CHECK( !(vt2 <= vt1) ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_add) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1 + vt2; + + EXAM_CHECK( vt1 <= vt3 ); + EXAM_CHECK( vt3 <= vt1 ); + + vt2[t2] = 1; + + vt3 = vt1 + vt2; + + vt4[t1] = 1; + vt4[t2] = 2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt4.clear(); + + vt2[t3] = 1; + + vt3 = vt1 + vt2; + + vt4[t1] = 1; + vt4[t2] = 2; + vt4[t3] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_diff) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1 - vt2; + + EXAM_CHECK( vt1 <= vt3 ); + EXAM_CHECK( vt3 <= vt1 ); + + vt2[t1] = 1; + + vt3 = vt1 - vt2; + + vt4[t2] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2[t2] = 1; + + vt4.clear(); + + vt3 = vt1 - vt2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2.clear(); + + vt2[t3] = 1; + + try { + vt3 = vt1 - vt2; + EXAM_ERROR( "Virtual Times are incomparable" ); + } + catch ( const std::range_error& err ) { + EXAM_CHECK( true ); + } + + vt2.clear(); + + vt2[t2] = 2; + + try { + vt3 = vt1 - vt2; + EXAM_ERROR( "Virtual Times are incomparable" ); + } + catch ( const std::range_error& err ) { + EXAM_CHECK( true ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_max) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t1] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t2] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t3] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t1] = 1; + vt4[t2] = 1; + vt4[t3] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2.clear(); + + vt2[t1] = 1; + vt2[t2] = 2; + + vt4.clear(); + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t1] = 1; + vt4[t2] = 2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2[t3] = 4; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t3] = 4; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::gvt_add) +{ + const oid_type t0(0); + const oid_type t1(1); + const oid_type t2(2); + + { + gvtime_type gvt1; + gvtime_type gvt2; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + gvt2[0] = vt2; + + gvt1 += gvt2; + + EXAM_CHECK( gvt1[0][t1] == 2 ); + EXAM_CHECK( gvt1[0][t2] == 2 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 0 ); + EXAM_CHECK( gvt1[1][t2] == 0 ); + } + { + gvtime_type gvt1; + gvtime_type gvt2; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + gvt2[1] = vt2; + + gvt1 += gvt2; + + EXAM_CHECK( gvt1[0][t1] == 1 ); + EXAM_CHECK( gvt1[0][t2] == 1 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 1 ); + EXAM_CHECK( gvt1[1][t2] == 1 ); + } + { + gvtime_type gvt1; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + + gvt1 += make_pair( 1, vt2 ); + + EXAM_CHECK( gvt1[0][t1] == 1 ); + EXAM_CHECK( gvt1[0][t2] == 1 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 1 ); + EXAM_CHECK( gvt1[1][t2] == 1 ); + } + + return EXAM_RESULT; +} Deleted: trunk/complement/explore/lib/janus/ut/vt_operations.h =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,30 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:40:39 ptr> - -#ifndef __vt_operations_h -#define __vt_operations_h - -#include <exam/suite.h> - -struct vtime_operations -{ - int EXAM_DECL(vt_compare); - int EXAM_DECL(vt_add); - int EXAM_DECL(vt_diff); - int EXAM_DECL(vt_max); - - int EXAM_DECL(gvt_add); - - int EXAM_DECL(VTMess_core); - - int EXAM_DECL(vt_object); - - int EXAM_DECL(VTDispatch1); - int EXAM_DECL(VTDispatch2); - - int EXAM_DECL(VTHandler1); - int EXAM_DECL(VTHandler2); - - int EXAM_DECL(VTSubscription); -}; - -#endif // __vt_operations_h Copied: trunk/complement/explore/lib/janus/ut/vt_operations.h (from rev 1680, trunk/complement/explore/test/virtual_time/test/vt_operations.h) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.h (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,35 @@ +// -*- C++ -*- Time-stamp: <07/08/16 09:02:08 ptr> + +#ifndef __vt_operations_h +#define __vt_operations_h + +#include <exam/suite.h> + +struct vtime_operations +{ + int EXAM_DECL(vt_compare); + int EXAM_DECL(vt_add); + int EXAM_DECL(vt_diff); + int EXAM_DECL(vt_max); + + int EXAM_DECL(gvt_add); + + int EXAM_DECL(VTMess_core); + + int EXAM_DECL(vt_object); + + int EXAM_DECL(VTDispatch1); + int EXAM_DECL(VTDispatch2); + + int EXAM_DECL(VTHandler1); + int EXAM_DECL(VTHandler2); + + int EXAM_DECL(VTSubscription); + int EXAM_DECL(VTEntryIntoGroup); + int EXAM_DECL(VTEntryIntoGroup2); + int EXAM_DECL(VTEntryIntoGroup3); + + int EXAM_DECL(remote); +}; + +#endif // __vt_operations_h Copied: trunk/complement/explore/lib/janus/ut/vt_remote.cc (from rev 1680, trunk/complement/explore/test/virtual_time/test/vt_remote.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,194 @@ +// -*- C++ -*- Time-stamp: <07/08/16 10:45:48 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +#include <stem/EvManager.h> +#include <stem/NetTransport.h> +#include <sockios/sockmgr.h> +#include <sys/wait.h> + +#include <mt/xmt.h> +#include <mt/shm.h> + +using namespace std; +using namespace stem; +using namespace xmt; +using namespace vt; + +class YaRemote : + public vt::VTHandler +{ + public: + YaRemote(); + YaRemote( stem::addr_type id ); + YaRemote( stem::addr_type id, const char *info ); + ~YaRemote(); + + void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + void greeting(); + + void wait(); + std::string msg; + int count; + int ocount; + + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + + private: + xmt::condition cnd; + xmt::condition gr; + + DECLARE_RESPONSE_TABLE( YaRemote, vt::VTHandler ); +}; + +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + +YaRemote::YaRemote() : + VTHandler(), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id ) : + VTHandler( id ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::~YaRemote() +{ + // cnd.wait(); +} + +void YaRemote::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello " << ev.src() << endl; + ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); +} + +void YaRemote::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + +void YaRemote::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +void YaRemote::greeting() +{ + gr.set( true ); +} + +DEFINE_RESPONSE_TABLE( YaRemote ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::remote) +{ + const char fname[] = "/tmp/yanus_test.shm"; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; + + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); + + try { + xmt::fork(); + + b.wait(); + + NetTransportMgr mgr; + + addr_type zero = mgr.open( "localhost", 6980 ); + + EXAM_CHECK_ASYNC( mgr.good() ); + + YaRemote obj2; + + exit(0); + } + catch ( xmt::fork_in_parent& child ) { + sockmgr_stream_MP<NetTransport> srv( 6980 ); + + EXAM_REQUIRE( srv.good() ); + + b.wait(); + + YaRemote obj1; + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + srv.close(); + srv.wait(); + } + + (&b)->~__barrier<true>(); + shm_b.deallocate( &b, 1 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + EXAM_ERROR( err.what() ); + } + + seg.deallocate(); + unlink( fname ); + + return EXAM_RESULT; +} + Copied: trunk/complement/explore/lib/janus/vtime.cc (from rev 1680, trunk/complement/explore/test/virtual_time/vtime.cc) =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc (rev 0) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,1170 @@ +// -*- C++ -*- Time-stamp: <07/08/11 01:10:59 ptr> + +#include <janus/vtime.h> + +#include <iostream> +#include <stdint.h> +#include <stem/EvManager.h> + +namespace vt { + +using namespace std; +using namespace xmt; +using namespace stem; + +void vtime::pack( std::ostream& s ) const +{ + __pack( s, static_cast<uint8_t>(vt.size()) ); + for ( vtime_type::const_iterator i = vt.begin(); i != vt.end(); ++i ) { + i->first.pack( s ); // __pack( s, i->first ); + __pack( s, i->second ); + } +} + +void vtime::net_pack( std::ostream& s ) const +{ + __net_pack( s, static_cast<uint8_t>(vt.size()) ); + for ( vtime_type::const_iterator i = vt.begin(); i != vt.end(); ++i ) { + i->first.net_pack( s ); // __net_pack( s, i->first ); + __net_pack( s, i->second ); + } +} + +void vtime::unpack( std::istream& s ) +{ + vt.clear(); + uint8_t n; + __unpack( s, n ); + while ( n-- > 0 ) { + oid_type oid; + vtime_unit_type v; + + oid.unpack( s ); // __unpack( s, oid ); + __unpack( s, v ); + + vt[oid] = v; + } +} + +void vtime::net_unpack( std::istream& s ) +{ + vt.clear(); + uint8_t n; + __net_unpack( s, n ); + while ( n-- > 0 ) { + oid_type oid; + vtime_unit_type v; + + oid.net_unpack( s ); // __net_unpack( s, oid ); + __net_unpack( s, v ); + + vt[oid] = v; + } +} + +void gvtime::pack( std::ostream& s ) const +{ + __pack( s, static_cast<uint8_t>(gvt.size()) ); + for ( gvtime_type::const_iterator i = gvt.begin(); i != gvt.end(); ++i ) { + __pack( s, i->first ); + i->second.pack( s ); + } +} + +void gvtime::net_pack( std::ostream& s ) const +{ + __net_pack( s, static_cast<uint8_t>(gvt.size()) ); + for ( gvtime_type::const_iterator i = gvt.begin(); i != gvt.end(); ++i ) { + __net_pack( s, i->first ); + i->second.net_pack( s ); + } +} + +void gvtime::unpack( std::istream& s ) +{ + gvt.clear(); + uint8_t n; + __unpack( s, n ); + while ( n-- > 0 ) { + group_type gid; + __unpack( s, gid ); + gvt[gid].unpack( s ); + } +} + +void gvtime::net_unpack( std::istream& s ) +{ + gvt.clear(); + uint8_t n; + __net_unpack( s, n ); + while ( n-- > 0 ) { + group_type gid; + __net_unpack( s, gid ); + gvt[gid].net_unpack( s ); + } +} + +void VSsync_rq::pack( std::ostream& s ) const +{ + __pack( s, grp ); + __pack( s, mess ); +} + +void VSsync_rq::net_pack( std::ostream& s ) const +{ + __net_pack( s, grp ); + __net_pack( s, mess ); +} + +void VSsync_rq::unpack( std::istream& s ) +{ + __unpack( s, grp ); + __unpack( s, mess ); +} + +void VSsync_rq::net_unpack( std::istream& s ) +{ + __net_unpack( s, grp ); + __net_unpack( s, mess ); +} + +void VSsync::pack( std::ostream& s ) const +{ + gvt.pack( s ); + VSsync_rq::pack( s ); +} + +void VSsync::net_pack( std::ostream& s ) const +{ + gvt.net_pack( s ); + VSsync_rq::net_pack( s ); +} + +void VSsync::unpack( std::istream& s ) +{ + gvt.unpack( s ); + VSsync_rq::unpack( s ); +} + +void VSsync::net_unpack( std::istream& s ) +{ + gvt.net_unpack( s ); + VSsync_rq::net_unpack( s ); +} + +void VTmess::pack( std::ostream& s ) const +{ + __pack( s, code ); + src.pack( s ); // __pack( s, src ); + VSsync::pack( s ); +} + +void VTmess::net_pack( std::ostream& s ) const +{ + __net_pack( s, code ); + src.net_pack( s ); // __net_pack( s, src ); + VSsync::net_pack( s ); +} + +void VTmess::unpack( std::istream& s ) +{ + __unpack( s, code ); + src.unpack( s ); // __unpack( s, src ); + VSsync::unpack( s ); +} + +void VTmess::net_unpack( std::istream& s ) +{ + __net_unpack( s, code ); + src.net_unpack( s ); // __net_unpack( s, src ); + VSsync::net_unpack( s ); +} + +bool operator <=( const vtime_type& l, const vtime_type& r ) +{ + if ( l.empty() ) { + return true; + } + + for ( vtime_type::const_iterator i = l.begin(); i != l.end(); ++i ) { + if ( i->second > 0 ) { + vtime_type::const_iterator j = r.find( i->first ); + if ( j == r.end() || i->second > j->second ) { + return false; + } + } + } + + return true; +} + +vtime_type operator -( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( r.begin(), r.end() ); + + for ( vtime_type::iterator i = tmp.begin(); i != tmp.end(); ++i ) { + if ( i->second > 0 ) { + vtime_type::const_iterator p = l.find(i->first); + if ( p == l.end() || p->second < i->second ) { + throw range_error( "vtime different: right value grater then left" ); + } + i->second = p->second - i->second; + } + } + + for ( vtime_type::const_iterator i = l.begin(); i != l.end(); ++i ) { + vtime_type::iterator p = tmp.find(i->first); + if ( p == tmp.end() ) { + tmp[i->first] = i->second; + } + } + + return tmp; +} + +vtime_type operator +( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( l.begin(), l.end() ); + + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + tmp[i->first] += i->second; + } + + return tmp; +} + +vtime_type& operator +=( vtime_type& l, const vtime_type& r ) +{ + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + l[i->first] += i->second; + } + + return l; +} + +#if 0 +// template <> +vtime_type max( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( l.begin(), l.end() ); + + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + tmp[i->first] = std::max( tmp[i->first], i->second ); + } + return tmp; +} +#endif + +vtime_type& sup( vtime_type& l, const vtime_type& r ) +{ + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + l[i->first] = std::max( l[i->first], i->second ); + } + return l; +} + + +#if 0 +// template <> +vtime max( const vtime& l, const vtime& r ) +{ + vtime tmp( l ); + + for ( vtime_type::const_iterator i = r.vt.begin(); i != r.vt.end(); ++i ) { + tmp[i->first] = std::max( tmp[i->first], i->second ); + } + return tmp; +} +#endif + +vtime& sup( vtime& l, const vtime& r ) +{ + for ( vtime_type::const_iterator i = r.vt.begin(); i != r.vt.end(); ++i ) { + l[i->first] = std::max( l[i->first], i->second ); + } + return l; +} + +vtime& vtime::operator +=( const vtime_type::value_type& t ) +{ + vt[t.first] += t.second; + + return *this; +} + +gvtime_type& operator +=( gvtime_type& gvt, const gvtime_type::value_type& t ) +{ + gvt[t.first] += t.seco... [truncated message content] |
From: <com...@us...> - 2007-08-17 06:47:46
|
Revision: 1684 http://complement.svn.sourceforge.net/complement/?rev=1684&view=rev Author: complement Date: 2007-08-16 23:47:44 -0700 (Thu, 16 Aug 2007) Log Message: ----------- namespace vt -> janus; VTDispatcher -> Janus; VTmess -> VSmess Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_object.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vtime.cc Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:05:47 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:38:35 ptr> #ifndef __vtime_h #define __vtime_h @@ -19,25 +19,25 @@ #include <mt/time.h> -namespace vt { +namespace janus { // typedef stem::addr_type oid_type; typedef stem::gaddr_type oid_type; -} // namespace vt +} // namespace janus namespace std { template <> -struct hash<vt::oid_type> +struct hash<janus::oid_type> { - size_t operator()(const vt::oid_type& __x) const + size_t operator()(const janus::oid_type& __x) const { return __x.addr; } }; } // namespace std -namespace vt { +namespace janus { typedef uint32_t vtime_unit_type; typedef stem::addr_type group_type; // required, used in VTSend @@ -188,7 +188,7 @@ gvtime gvt; }; -struct VTmess : +struct VSmess : public VSsync { void pack( std::ostream& s ) const; @@ -196,11 +196,11 @@ void unpack( std::istream& s ); void net_unpack( std::istream& s ); - VTmess() : + VSmess() : code(0), src() { } - VTmess( const VTmess& _gvt ) : + VSmess( const VSmess& _gvt ) : VSsync( _gvt ), code( _gvt.code ), src( _gvt.src ) @@ -229,9 +229,9 @@ stem::addr_type stem_addr() const { return addr; } - bool deliver( const VTmess& ev ); - bool deliver_delayed( const VTmess& ev ); - std::ostream& trace_deliver( const VTmess& m, std::ostream& o ); + bool deliver( const VSmess& ev ); + bool deliver_delayed( const VSmess& ev ); + std::ostream& trace_deliver( const VSmess& m, std::ostream& o ); void next( const oid_type& from, group_type grp ) { ++vt.gvt[grp][from]; /* increment my VT counter */ } void delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ); @@ -260,19 +260,19 @@ public: // delay pool should be here - typedef std::pair<xmt::timespec,stem::Event_base<VTmess>*> delay_item_t; + typedef std::pair<xmt::timespec,stem::Event_base<VSmess>*> delay_item_t; typedef std::list<delay_item_t> dpool_t; dpool_t dpool; private: - bool order_correct( const VTmess& ); - bool order_correct_delayed( const VTmess& ); + bool order_correct( const VSmess& ); + bool order_correct_delayed( const VSmess& ); }; } // namespace detail -class VTDispatcher : +class Janus : public stem::EventHandler { public: @@ -285,32 +285,32 @@ tracegroup = 0x10 }; - VTDispatcher() : + Janus() : _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( const char *info ) : + Janus( const char *info ) : stem::EventHandler( info ), _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( stem::addr_type id ) : + Janus( stem::addr_type id ) : stem::EventHandler( id ), _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( stem::addr_type id, const char *info ) : + Janus( stem::addr_type id, const char *info ) : stem::EventHandler( id, info ), _trflags( notrace ), _trs( 0 ) { } - void VTDispatch( const stem::Event_base<VTmess>& ); + void JaDispatch( const stem::Event_base<VSmess>& ); - void VTSend( const stem::Event& e, group_type ); + void JaSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); void Unsubscribe( oid_type, group_type ); void Unsubscribe( oid_type ); @@ -328,7 +328,7 @@ typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; - void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); + void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); void check_and_send_delayed( detail::vtime_obj_rec& ); vt_map_type vtmap; @@ -338,7 +338,7 @@ unsigned _trflags; std::ostream *_trs; - DECLARE_RESPONSE_TABLE( VTDispatcher, stem::EventHandler ); + DECLARE_RESPONSE_TABLE( Janus, stem::EventHandler ); }; class VTHandler : @@ -363,7 +363,7 @@ explicit VTHandler( stem::addr_type id, const char *info = 0 ); virtual ~VTHandler(); - void VTSend( const stem::Event& e ); + void JaSend( const stem::Event& e ); void JoinGroup( group_type grp ) { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); @@ -371,11 +371,11 @@ virtual void VSsync_time( const stem::Event_base<VSsync>& ); - template <class D> - void VTSend( const stem::Event_base<D>& e ) - { VTHandler::VTSend( stem::Event_convert<D>()( e ) ); } + // template <class D> + // void JaSend( const stem::Event_base<D>& e ) + // { VTHandler::JaSend( stem::Event_convert<D>()( e ) ); } - static VTDispatcher *vtdispatcher() + static Janus *vtdispatcher() { return _vtdsp; } protected: @@ -385,7 +385,7 @@ { _vtdsp->get_gvtime( g, self_id(), gvt ); } private: - static class VTDispatcher *_vtdsp; + static class Janus *_vtdsp; DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); }; @@ -395,18 +395,18 @@ #define VS_OUT_MEMBER 0x302 #define VS_SYNC_TIME 0x303 -} // namespace vt +} // namespace janus namespace std { -ostream& operator <<( ostream&, const vt::vtime_type::value_type& ); -ostream& operator <<( ostream&, const vt::vtime_type& ); -ostream& operator <<( ostream&, const vt::vtime& ); -ostream& operator <<( ostream&, const vt::gvtime_type::value_type& ); -ostream& operator <<( ostream&, const vt::gvtime_type& ); -ostream& operator <<( ostream&, const vt::gvtime& ); -ostream& operator <<( ostream& o, const vt::VSsync& ); -ostream& operator <<( ostream& o, const vt::VTmess& ); +ostream& operator <<( ostream&, const janus::vtime_type::value_type& ); +ostream& operator <<( ostream&, const janus::vtime_type& ); +ostream& operator <<( ostream&, const janus::vtime& ); +ostream& operator <<( ostream&, const janus::gvtime_type::value_type& ); +ostream& operator <<( ostream&, const janus::gvtime_type& ); +ostream& operator <<( ostream&, const janus::gvtime& ); +ostream& operator <<( ostream& o, const janus::VSsync& ); +ostream& operator <<( ostream& o, const janus::VSmess& ); } // namespace std Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,11 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/25 22:06:40 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:20:54 ptr> #include "vt_operations.h" #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; class VTM_handler : @@ -17,8 +17,8 @@ VTM_handler( stem::addr_type id, const char *info ); ~VTM_handler(); - void handlerE( const stem::Event_base<VTmess>& ); - void handlerV( const VTmess& ); + void handlerE( const stem::Event_base<VSmess>& ); + void handlerV( const VSmess& ); void wait(); @@ -59,7 +59,7 @@ // cnd.wait(); } -void VTM_handler::handlerE( const stem::Event_base<VTmess>& ev ) +void VTM_handler::handlerE( const stem::Event_base<VSmess>& ev ) { code = ev.value().code; src = ev.value().src; @@ -71,7 +71,7 @@ cnd.set( true ); } -void VTM_handler::handlerV( const VTmess& m ) +void VTM_handler::handlerV( const VSmess& m ) { code = m.code; src = m.src; @@ -91,8 +91,8 @@ } DEFINE_RESPONSE_TABLE( VTM_handler ) - EV_Event_base_T_( ST_NULL, VT_MESS, handlerE, VTmess ) - EV_T_( 1, VT_MESS, handlerV, VTmess ) + EV_Event_base_T_( ST_NULL, VT_MESS, handlerE, VSmess ) + EV_T_( 1, VT_MESS, handlerV, VSmess ) END_RESPONSE_TABLE int EXAM_IMPL(vtime_operations::VTMess_core) @@ -103,7 +103,7 @@ VTM_handler h; - stem::Event_base<VTmess> ev( VT_MESS ); + stem::Event_base<VSmess> ev( VT_MESS ); ev.dest( h.self_id() ); ev.value().code = 2; Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:39:45 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; class Dummy : @@ -75,7 +73,7 @@ int EXAM_IMPL(vtime_operations::VTDispatch1) { - vt::VTDispatcher dsp; + janus::Janus dsp; Dummy dummy1; Dummy dummy2; const oid_type t1(1); @@ -89,7 +87,7 @@ ev.value() = "hello"; - dsp.VTSend( ev, 0 ); + dsp.JaSend( ev, 0 ); dummy2.wait(); @@ -101,7 +99,7 @@ int EXAM_IMPL(vtime_operations::VTDispatch2) { - vt::VTDispatcher dsp; + janus::Janus dsp; Dummy dummy1; Dummy dummy2; Dummy dummy3; @@ -118,7 +116,7 @@ ev.value() = "hello"; - dsp.VTSend( ev, 0 ); + dsp.JaSend( ev, 0 ); dummy2.wait(); dummy3.wait(); Modified: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,19 +1,17 @@ -// -*- C++ -*- Time-stamp: <07/08/11 23:21:59 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:41:22 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> #include <stem/EvManager.h> -using namespace vt; +using namespace janus; using namespace std; class VTDummy : - public vt::VTHandler + public janus::VTHandler { public: VTDummy(); @@ -42,7 +40,7 @@ xmt::condition cnd; xmt::condition gr; - DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); + DECLARE_RESPONSE_TABLE( VTDummy, janus::VTHandler ); }; #define VS_DUMMY_MESS 0x1203 @@ -138,7 +136,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); @@ -158,7 +156,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -172,7 +170,7 @@ ev.dest( 100 ); // not this group member try { - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); EXAM_ERROR( "exception expected" ); } catch ( std::domain_error& ) { @@ -190,7 +188,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -199,7 +197,7 @@ VTDummy dummy3; ev.value() = "hi"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); // dummy3.wait(); @@ -211,7 +209,7 @@ } ev.value() = "yet more"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "yet more" ); @@ -240,7 +238,7 @@ dummy3.wait_greeting(); ev.value() = "hi"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy3.wait(); @@ -260,7 +258,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -280,7 +278,7 @@ ev.value() = "hi"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -306,7 +304,7 @@ ev.value() = "hello"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -320,7 +318,7 @@ ev.value() = "hi"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy3.wait(); @@ -337,7 +335,7 @@ ev.value() = "more"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -346,7 +344,7 @@ EXAM_CHECK( dummy3.msg == "more" ); EXAM_CHECK( dummy1.msg == "" ); - dummy2.VTSend( ev ); + dummy2.JaSend( ev ); dummy1.wait(); } Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/25 22:09:32 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:21:34 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; int EXAM_IMPL(vtime_operations::vt_object) @@ -29,8 +27,8 @@ // gvtime gvt; // gvt[gr0][obj1] = 1; - VTmess mess; - VTmess mess_bad; + VSmess mess; + VSmess mess_bad; mess_bad.code = mess.code = 1; mess_bad.src = mess.src = obj1; @@ -90,7 +88,7 @@ // ---- - VTmess mess2; + VSmess mess2; mess2.code = 1; mess2.src = obj2; @@ -158,7 +156,7 @@ // cerr << ob.vt[gr0] << endl; // cerr << "===========\n"; - VTmess mess3; + VSmess mess3; mess3.code = 1; mess3.src = obj2; Modified: trunk/complement/explore/lib/janus/ut/vt_operations.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:06:23 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; int EXAM_IMPL(vtime_operations::vt_compare) @@ -180,7 +178,7 @@ vt1[t2] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -188,7 +186,7 @@ vt2[t1] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -196,7 +194,7 @@ vt2[t2] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -204,7 +202,7 @@ vt2[t3] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t1] = 1; vt4[t2] = 1; @@ -221,7 +219,7 @@ vt4.clear(); vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t1] = 1; vt4[t2] = 2; @@ -232,7 +230,7 @@ vt2[t3] = 4; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t3] = 4; Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,9 +1,7 @@ -// -*- C++ -*- Time-stamp: <07/08/16 10:45:48 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:07:52 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> @@ -18,10 +16,10 @@ using namespace std; using namespace stem; using namespace xmt; -using namespace vt; +using namespace janus; class YaRemote : - public vt::VTHandler + public janus::VTHandler { public: YaRemote(); @@ -50,7 +48,7 @@ xmt::condition cnd; xmt::condition gr; - DECLARE_RESPONSE_TABLE( YaRemote, vt::VTHandler ); + DECLARE_RESPONSE_TABLE( YaRemote, janus::VTHandler ); }; #define VS_DUMMY_MESS 0x1203 Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:10:59 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:39:02 ptr> #include <janus/vtime.h> @@ -6,7 +6,7 @@ #include <stdint.h> #include <stem/EvManager.h> -namespace vt { +namespace janus { using namespace std; using namespace xmt; @@ -152,28 +152,28 @@ VSsync_rq::net_unpack( s ); } -void VTmess::pack( std::ostream& s ) const +void VSmess::pack( std::ostream& s ) const { __pack( s, code ); src.pack( s ); // __pack( s, src ); VSsync::pack( s ); } -void VTmess::net_pack( std::ostream& s ) const +void VSmess::net_pack( std::ostream& s ) const { __net_pack( s, code ); src.net_pack( s ); // __net_pack( s, src ); VSsync::net_pack( s ); } -void VTmess::unpack( std::istream& s ) +void VSmess::unpack( std::istream& s ) { __unpack( s, code ); src.unpack( s ); // __unpack( s, src ); VSsync::unpack( s ); } -void VTmess::net_unpack( std::istream& s ) +void VSmess::net_unpack( std::istream& s ) { __net_unpack( s, code ); src.net_unpack( s ); // __net_unpack( s, src ); @@ -349,7 +349,7 @@ namespace detail { -bool vtime_obj_rec::deliver( const VTmess& m ) +bool vtime_obj_rec::deliver( const VSmess& m ) { if ( order_correct( m ) ) { lvt[m.src] += m.gvt.gvt; @@ -361,7 +361,7 @@ return false; } -bool vtime_obj_rec::deliver_delayed( const VTmess& m ) +bool vtime_obj_rec::deliver_delayed( const VSmess& m ) { if ( order_correct_delayed( m ) ) { lvt[m.src] += m.gvt.gvt; @@ -373,17 +373,17 @@ return false; } -bool vtime_obj_rec::order_correct( const VTmess& m ) +bool vtime_obj_rec::order_correct( const VSmess& m ) { if ( groups.find( m.grp ) == groups.end() ) { - throw domain_error( "VT object not member of group" ); + throw domain_error( "virtual synchrony object not member of group" ); } gvtime gvt( m.gvt ); if ( (vt.gvt[m.grp][m.src] + 1) != gvt[m.grp][m.src] ) { if ( (vt.gvt[m.grp][m.src] + 1) > gvt[m.grp][m.src] ) { - throw out_of_range( "duplicate or wrong VT message" ); + throw out_of_range( "duplicate or wrong virtual synchrony message" ); } return false; } @@ -405,10 +405,10 @@ return true; } -ostream& vtime_obj_rec::trace_deliver( const VTmess& m, ostream& o ) +ostream& vtime_obj_rec::trace_deliver( const VSmess& m, ostream& o ) { if ( groups.find( m.grp ) == groups.end() ) { - return o << "VT object not member of group"; + return o << "virtual synchrony object not member of group"; } gvtime gvt( m.gvt ); @@ -437,7 +437,7 @@ return o << "should be delivered"; } -bool vtime_obj_rec::order_correct_delayed( const VTmess& m ) +bool vtime_obj_rec::order_correct_delayed( const VSmess& m ) { gvtime gvt( m.gvt ); @@ -473,7 +473,7 @@ // strike out group g from my groups list groups_container_type::iterator i = groups.find( g ); if ( i == groups.end() ) { - throw domain_error( "VT object not member of group" ); + throw domain_error( "virtual synchrony object not member of group" ); } groups.erase( i ); @@ -543,44 +543,44 @@ } // namespace detail -void VTDispatcher::settrf( unsigned f ) +void Janus::settrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags |= f; } -void VTDispatcher::unsettrf( unsigned f ) +void Janus::unsettrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags &= (0xffffffff & ~f); } -void VTDispatcher::resettrf( unsigned f ) +void Janus::resettrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags = f; } -void VTDispatcher::cleantrf() +void Janus::cleantrf() { scoped_lock _x1( _lock_tr ); _trflags = 0; } -unsigned VTDispatcher::trflags() const +unsigned Janus::trflags() const { scoped_lock _x1( _lock_tr ); return _trflags; } -void VTDispatcher::settrs( std::ostream *s ) +void Janus::settrs( std::ostream *s ) { scoped_lock _x1( _lock_tr ); _trs = s; } -void VTDispatcher::VTDispatch( const stem::Event_base<VTmess>& m ) +void Janus::JaDispatch( const stem::Event_base<VSmess>& m ) { pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( m.value().grp ); @@ -621,7 +621,7 @@ } } -void VTDispatcher::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VTmess>& m ) +void Janus::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VSmess>& m ) { if ( vt.deliver( m.value() ) ) { stem::Event ev( m.value().code ); @@ -651,11 +651,11 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VTmess>(m) ) ); // 0 should be timestamp + vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VSmess>(m) ) ); // 0 should be timestamp } } -void VTDispatcher::check_and_send_delayed( detail::vtime_obj_rec& vt ) +void Janus::check_and_send_delayed( detail::vtime_obj_rec& vt ) { typedef detail::vtime_obj_rec::dpool_t dpool_t; bool more; @@ -700,7 +700,7 @@ } while ( more ); } -void VTDispatcher::VTSend( const stem::Event& e, group_type grp ) +void Janus::JaSend( const stem::Event& e, group_type grp ) { // This method not called from Dispatch, but work on the same level and in the same // scope, so this lock (from stem::EventHandler) required here: @@ -714,7 +714,7 @@ if ( i != vtmap.end() && i->second.stem_addr() == e.src() ) { // for self detail::vtime_obj_rec& vt = i->second; const oid_type& from = o->second; - stem::Event_base<VTmess> m( VS_MESS ); + stem::Event_base<VSmess> m( VS_MESS ); m.value().src = from; // oid m.value().code = e.code(); m.value().mess = e.value(); @@ -787,7 +787,7 @@ throw domain_error( "VT object not member of group" ); // Error: not group member } -void VTDispatcher::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +void Janus::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -820,7 +820,7 @@ grmap.insert( make_pair(grp,oid) ); } -void VTDispatcher::Unsubscribe( oid_type oid, group_type grp ) +void Janus::Unsubscribe( oid_type oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -863,9 +863,9 @@ } } -void VTDispatcher::Unsubscribe( oid_type oid ) +void Janus::Unsubscribe( oid_type oid ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); vt_map_type::iterator i = vtmap.find( oid ); @@ -909,9 +909,9 @@ } } -void VTDispatcher::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) +void Janus::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); pair<gid_map_type::iterator,gid_map_type::iterator> range = @@ -927,18 +927,18 @@ try { scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; } } catch ( ... ) { } - throw domain_error( "VT object not member of group" ); // Error: not group member + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member } -void VTDispatcher::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) +void Janus::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); pair<gid_map_type::iterator,gid_map_type::iterator> range = @@ -966,21 +966,21 @@ try { scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; } } catch ( ... ) { } - throw domain_error( "VT object not member of group" ); // Error: not group member + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member } -DEFINE_RESPONSE_TABLE( VTDispatcher ) - EV_Event_base_T_( ST_NULL, VS_MESS, VTDispatch, VTmess ) +DEFINE_RESPONSE_TABLE( Janus ) + EV_Event_base_T_( ST_NULL, VS_MESS, JaDispatch, VSmess ) END_RESPONSE_TABLE char *Init_buf[128]; -VTDispatcher *VTHandler::_vtdsp = 0; +Janus *VTHandler::_vtdsp = 0; static int *_rcount = 0; void VTHandler::Init::__at_fork_prepare() @@ -1013,7 +1013,7 @@ _rcount = &_count; pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); #endif - VTHandler::_vtdsp = new VTDispatcher( 2, "vtd" ); + VTHandler::_vtdsp = new Janus( 2, "vtd" ); } } else { --_count; @@ -1030,10 +1030,10 @@ VTHandler::Init::~Init() { _guard( 0 ); } -void VTHandler::VTSend( const stem::Event& ev ) +void VTHandler::JaSend( const stem::Event& ev ) { ev.src( self_id() ); - _vtdsp->VTSend( ev, ev.dest() ); // throw domain_error, if not group member + _vtdsp->JaSend( ev, ev.dest() ); // throw domain_error, if not group member } VTHandler::VTHandler() : @@ -1112,14 +1112,14 @@ namespace std { -ostream& operator <<( ostream& o, const vt::vtime_type::value_type& v ) +ostream& operator <<( ostream& o, const janus::vtime_type::value_type& v ) { return o << "(" << v.first << "," << v.second << ")"; } -ostream& operator <<( ostream& o, const vt::vtime_type& v ) +ostream& operator <<( ostream& o, const janus::vtime_type& v ) { - for ( vt::vtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { + for ( janus::vtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { if ( i != v.begin() ) { o << ", "; } @@ -1128,29 +1128,29 @@ return o; } -ostream& operator <<( ostream& o, const vt::vtime& v ) +ostream& operator <<( ostream& o, const janus::vtime& v ) { return o << v.vt; } -ostream& operator <<( ostream& o, const vt::gvtime_type::value_type& v ) +ostream& operator <<( ostream& o, const janus::gvtime_type::value_type& v ) { o << v.first << ": " << v.second.vt; } -ostream& operator <<( ostream& o, const vt::gvtime_type& v ) +ostream& operator <<( ostream& o, const janus::gvtime_type& v ) { o << "{\n"; - for ( vt::gvtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { + for ( janus::gvtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { o << "\t" << *i << "\n"; } return o << "}\n"; } -ostream& operator <<( ostream& o, const vt::gvtime& v ) +ostream& operator <<( ostream& o, const janus::gvtime& v ) { return o << v.gvt; } -ostream& operator <<( ostream& o, const vt::VSsync& m ) +ostream& operator <<( ostream& o, const janus::VSsync& m ) { // ios_base::fmtflags f = o.flags( ios_base::hex ); o << "G" << m.grp << " " << m.gvt; @@ -1158,13 +1158,13 @@ return o; } -ostream& operator <<( ostream& o, const vt::VTmess& m ) +ostream& operator <<( ostream& o, const janus::VSmess& m ) { ios_base::fmtflags f = o.flags( ios_base::hex | ios_base::showbase ); - o << "C" << m.code << dec << " " << m.src << " " << static_cast<const vt::VSsync&>(m); + o << "C" << m.code << dec << " " << m.src << " " << static_cast<const janus::VSsync&>(m); o.flags( f ); return o; } -} // namespace std +} // namespace janus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:26:24
|
Revision: 1688 http://complement.svn.sourceforge.net/complement/?rev=1688&view=rev Author: complement Date: 2007-08-17 05:26:22 -0700 (Fri, 17 Aug 2007) Log Message: ----------- use available variant of hash_map/hash_set or unordered_map/unordered_set Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ChangeLog Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 11:16:43 UTC (rev 1687) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:26:22 UTC (rev 1688) @@ -6,8 +6,28 @@ #include <algorithm> #include <list> #include <vector> -#include <hash_map> -#include <hash_set> +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + +#include <unordered_map> +#include <unordered_set> + #include <iterator> #include <istream> @@ -41,7 +61,15 @@ typedef uint32_t vtime_unit_type; typedef stem::addr_type group_type; // required, used in VTSend +#ifdef __USE_STLPORT_HASH typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; +#endif +#ifdef __USE_STD_HASH +typedef __gnu_cxx::hash_map<oid_type, vtime_unit_type> vtime_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +typedef std::tr1::unordered_map<oid_type, vtime_unit_type> vtime_type; +#endif bool operator <=( const vtime_type& l, const vtime_type& r ); inline bool operator >=( const vtime_type& l, const vtime_type& r ) @@ -115,7 +143,15 @@ // typedef std::pair<group_type, vtime> vtime_group_type; // typedef std::list<vtime_group_type> gvtime_type; +#ifdef __USE_STLPORT_HASH typedef std::hash_map<group_type, vtime> gvtime_type; +#endif +#ifdef __USE_STD_HASH +typedef __gnu_cxx::hash_map<group_type, vtime> gvtime_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +typedef std::tr1::unordered_map<group_type, vtime> gvtime_type; +#endif gvtime_type& operator +=( gvtime_type&, const gvtime_type::value_type& ); gvtime_type& operator +=( gvtime_type&, const gvtime_type& ); @@ -247,9 +283,21 @@ #endif private: +#ifdef __USE_STLPORT_HASH typedef std::hash_set<group_type> groups_container_type; typedef std::hash_map<oid_type, gvtime_type> delta_vtime_type; typedef std::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_set<group_type> groups_container_type; + typedef __gnu_cxx::hash_map<oid_type, gvtime_type> delta_vtime_type; + typedef __gnu_cxx::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_set<group_type> groups_container_type; + typedef std::tr1::unordered_map<oid_type, gvtime_type> delta_vtime_type; + typedef std::tr1::unordered_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif stem::addr_type addr; // stem address of object delta_vtime_type lvt; // last recieve VT from neighbours @@ -324,9 +372,19 @@ unsigned trflags() const; void settrs( std::ostream * ); - private: + private: +#ifdef __USE_STLPORT_HASH typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef __gnu_cxx::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef std::tr1::unordered_multimap<group_type, oid_type> gid_map_type; +#endif void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); void check_and_send_delayed( detail::vtime_obj_rec& ); Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-08-17 11:16:43 UTC (rev 1687) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-08-17 12:26:22 UTC (rev 1688) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <ye...@ya...> + + * vtime.h: use available variant of hash_map/hash_set or + unordered_map/unordered_set. + 2007-08-17 Petr Ovtchenkov <pt...@is...> * vtime.cc, vtime.h: namespace vt moved to janus; VTDispatcher This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:42:09
|
Revision: 1689 http://complement.svn.sourceforge.net/complement/?rev=1689&view=rev Author: complement Date: 2007-08-17 05:42:07 -0700 (Fri, 17 Aug 2007) Log Message: ----------- made code acceptable for gcc 3.3 [remove inline initialization of statics in template] Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h trunk/complement/explore/lib/misc/ChangeLog Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:26:22 UTC (rev 1688) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:42:07 UTC (rev 1689) @@ -49,9 +49,12 @@ static __t2 __test(...); public: - static const bool __value = sizeof(__test<_Tp>(0)) == 1; + static const bool __value; // = sizeof(__test<_Tp>(0)) == 1; }; +template <class _Tp> +const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == 1; + template <class T> struct __uoc_aux : // union or class public __select_types @@ -64,10 +67,13 @@ static __t2 __test(...); public: - static const bool __value = sizeof(__test<T>(0)) == 1; + static const bool __value; // = sizeof(__test<T>(0)) == 1; }; template <class T> +const bool __uoc_aux<T>::__value = sizeof(__uoc_aux<T>::__test<T>(0)) == 1; + +template <class T> class __empty { }; Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2007-08-17 12:26:22 UTC (rev 1688) +++ trunk/complement/explore/lib/misc/ChangeLog 2007-08-17 12:42:07 UTC (rev 1689) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * type_traits.h: made code acceptable for gcc 3.3 [remove + inline initialization of statics in template]. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * type_traits.h: select appropriate TR1 type_traits implementation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-18 05:13:11
|
Revision: 1698 http://complement.svn.sourceforge.net/complement/?rev=1698&view=rev Author: complement Date: 2007-08-17 22:13:06 -0700 (Fri, 17 Aug 2007) Log Message: ----------- add fixed address for janus [virtual synchrony dispatcher, janus subproject] Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/lib/janus/vtime.cc trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/include/stem/Event.h 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 08:19:34 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:15:41 ptr> /* * @@ -40,6 +40,7 @@ extern const addr_type extbit; extern const addr_type default_addr; extern const addr_type ns_addr; +extern const addr_type janus_addr; extern const code_type badcode; struct gaddr_type : Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 10:39:02 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:28:55 ptr> #include <janus/vtime.h> @@ -1013,7 +1013,7 @@ _rcount = &_count; pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); #endif - VTHandler::_vtdsp = new Janus( 2, "vtd" ); + VTHandler::_vtdsp = new Janus( janus_addr, "janus" ); } } else { --_count; @@ -1040,24 +1040,18 @@ EventHandler() { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( const char *info ) : EventHandler( info ) { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( stem::addr_type id, const char *info ) : EventHandler( id, info ) { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( id, oid_type( id ), /* grp */ 0 ); } VTHandler::~VTHandler() Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * Event.h, EvManager.cc: add fixed address for janus + [virtual synchrony dispatcher, janus subproject]. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * Makefile: let's try don't include boost's -I if macro Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/08/03 09:20:31 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:22:13 ptr> /* * - * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1995-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -29,11 +29,12 @@ using namespace std; using namespace xmt; -const addr_type badaddr = 0xffffffff; -const code_type badcode = static_cast<code_type>(-1); -const addr_type extbit = 0x80000000; +const addr_type badaddr = 0xffffffff; +const code_type badcode = 0xffffffff; +const addr_type extbit = 0x80000000; const addr_type default_addr = 0x00000000; -const addr_type ns_addr = 0x00000001; +const addr_type ns_addr = 0x00000001; +const addr_type janus_addr = 0x00000002; const addr_type beglocaddr = 0x00000100; const addr_type endlocaddr = 0x3fffffff; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 08:46:48
|
Revision: 1699 http://complement.svn.sourceforge.net/complement/?rev=1699&view=rev Author: complement Date: 2007-08-23 01:46:41 -0700 (Thu, 23 Aug 2007) Log Message: ----------- explicitly inhibit copy of basic_sockmgr and sockmgr_stream_MP. libsockios: Version 1.12.1 Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile.inc Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-08-23 08:46:41 UTC (rev 1699) @@ -102,6 +102,10 @@ } private: + basic_sockmgr( const basic_sockmgr& ); + basic_sockmgr& operator =( const basic_sockmgr& ); + + private: sock_base::socket_type _fd; // master socket unsigned long _mode; // open mode unsigned long _state; // state flags @@ -190,6 +194,11 @@ ~sockmgr_stream_MP() { loop_id.join(); } + private: + sockmgr_stream_MP( const sockmgr_stream_MP<Connect>& ); + sockmgr_stream_MP<Connect>& operator =( const sockmgr_stream_MP<Connect>& ); + + public: void open( const in_addr& addr, int port, sock_base::stype t = sock_base::sock_stream ); void open( unsigned long addr, int port, sock_base::stype t = sock_base::sock_stream ); void open( int port, sock_base::stype t = sock_base::sock_stream ); @@ -315,7 +324,7 @@ bool _shift_fd(); static void _close_by_signal( int ); bool _is_follow() const - { MT_REENTRANT( _flock, _1 ); return _follow; } + { xmt::scoped_lock lk( _flock ); bool tmp = _follow; return tmp; } }; #endif // !__FIT_NO_POLL Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-23 08:46:41 UTC (rev 1699) @@ -1,3 +1,10 @@ +2007-08-23 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h: explicitly inhibit copy of basic_sockmgr and + sockmgr_stream_MP. + + * libsockios: Version 1.12.1. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * include/sockios/sockstream: workaround for file openmode Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-08-23 08:46:41 UTC (rev 1699) @@ -3,7 +3,7 @@ LIBNAME = sockios MAJOR = 1 MINOR = 12 -PATCH = 0 +PATCH = 1 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ freebsd/ns_parse.c \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 08:48:00
|
Revision: 1700 http://complement.svn.sourceforge.net/complement/?rev=1700&view=rev Author: complement Date: 2007-08-23 01:47:58 -0700 (Thu, 23 Aug 2007) Log Message: ----------- inhibit copy of NetTransportMgr explicitly; libstem: library version 4.6.2 (due to address for janus). Modified Paths: -------------- trunk/complement/explore/include/stem/NetTransport.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Makefile.inc Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/include/stem/NetTransport.h 2007-08-23 08:47:58 UTC (rev 1700) @@ -99,6 +99,10 @@ int join() { return _thr.join().iword; } + private: + NetTransportMgr( const NetTransportMgr& ); + NetTransportMgr& operator =( const NetTransportMgr& ); + protected: static xmt::Thread::ret_code _loop( void * ); xmt::Thread _thr; Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-23 08:47:58 UTC (rev 1700) @@ -1,3 +1,9 @@ +2007-08-23 Petr Ovtchenkov <pt...@is...> + + * NetTransport.h: inhibit copy of NetTransportMgr explicitly; + + * libstem: library version 4.6.2 (due to address for janus). + 2007-08-17 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc: add fixed address for janus Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-08-23 08:47:58 UTC (rev 1700) @@ -3,7 +3,7 @@ LIBNAME = stem MAJOR = 4 MINOR = 6 -PATCH = 1 +PATCH = 2 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |