[complement-svn] SF.net SVN: complement: [1670] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
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. |