Thread: [complement-svn] SF.net SVN: complement: [1469] trunk/complement/explore/lib
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-01-23 12:28:24
|
Revision: 1469 http://svn.sourceforge.net/complement/?rev=1469&view=rev Author: complement Date: 2007-01-23 04:28:23 -0800 (Tue, 23 Jan 2007) Log Message: ----------- build unit tests and run it (check target) Modified Paths: -------------- trunk/complement/explore/lib/Makefile trunk/complement/explore/lib/mt/Makefile trunk/complement/explore/lib/sockios/Makefile trunk/complement/explore/lib/stem/Makefile Modified: trunk/complement/explore/lib/Makefile =================================================================== --- trunk/complement/explore/lib/Makefile 2007-01-23 12:27:17 UTC (rev 1468) +++ trunk/complement/explore/lib/Makefile 2007-01-23 12:28:23 UTC (rev 1469) @@ -1,4 +1,4 @@ -# Time-stamp: <06/11/01 22:59:18 ptr> +# Time-stamp: <07/01/23 14:12:04 ptr> # # Copyright (c) 2006 # Petr Ovtchenkov @@ -11,7 +11,7 @@ include ${SRCROOT}/Makefiles/gmake/subdirs.mak -all install depend clean clobber distclean: +all install depend clean clobber distclean check: $(doinsubdirs) -.PHONY: all install depend clean clobber distclean +.PHONY: all install depend clean clobber distclean check Modified: trunk/complement/explore/lib/mt/Makefile =================================================================== --- trunk/complement/explore/lib/mt/Makefile 2007-01-23 12:27:17 UTC (rev 1468) +++ trunk/complement/explore/lib/mt/Makefile 2007-01-23 12:28:23 UTC (rev 1469) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <06/11/10 16:23:01 ptr> +# -*- Makefile -*- Time-stamp: <07/01/23 15:00:11 ptr> SRCROOT := ../.. @@ -6,3 +6,26 @@ include ${SRCROOT}/Makefiles/top.mak INCLUDES += -I$(SRCROOT)/include + +check: install + $(MAKE) -C ../../test/mt + (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 + (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 + (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 + +check-release: install-release-shared + $(MAKE) -C ../../test/mt release-shared + (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 + +check-dbg: install-dbg-shared + $(MAKE) -C ../../test/mt dbg-shared + (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg: install-stldbg-shared + $(MAKE) -C ../../test/mt stldbg-shared + (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 +endif + +depend:: + $(MAKE) -C ../../test/mt depend Modified: trunk/complement/explore/lib/sockios/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/Makefile 2007-01-23 12:27:17 UTC (rev 1468) +++ trunk/complement/explore/lib/sockios/Makefile 2007-01-23 12:28:23 UTC (rev 1469) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <03/07/09 18:08:47 ptr> +# -*- Makefile -*- Time-stamp: <07/01/23 14:59:53 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -8,3 +8,25 @@ INCLUDES += -I$(SRCROOT)/include +check: install + $(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 + +check-release: install-release-shared + $(MAKE) -C ../../test/sockios release-shared + (cd ../../test/sockios; ${OUTPUT_DIR}/sockios_ut) || exit 1 + +check-dbg: install-dbg-shared + $(MAKE) -C ../../test/sockios dbg-shared + (cd ../../test/sockios; ${OUTPUT_DIR_DBG}/sockios_ut) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg: install-stldbg-shared + $(MAKE) -C ../../test/sockios stldbg-shared + (cd ../../test/sockios; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 +endif + +depend:: + $(MAKE) -C ../../test/sockios depend Modified: trunk/complement/explore/lib/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/Makefile 2007-01-23 12:27:17 UTC (rev 1468) +++ trunk/complement/explore/lib/stem/Makefile 2007-01-23 12:28:23 UTC (rev 1469) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <06/11/30 22:27:35 ptr> +# -*- Makefile -*- Time-stamp: <07/01/23 14:58:35 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -15,3 +15,26 @@ else stldbg-shared: DEFS += -D__FIT_STEM_TRACE=1 endif + +check: install + $(MAKE) -C ../../test/stem + (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 + (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 + +check-release: install-release-shared + $(MAKE) -C ../../test/stem release-shared + (cd ../../test/stem; ${OUTPUT_DIR}/stem_ut) || exit 1 + +check-dbg: install-dbg-shared + $(MAKE) -C ../../test/stem dbg-shared + (cd ../../test/stem; ${OUTPUT_DIR_DBG}/stem_ut) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg: install-stldbg-shared + $(MAKE) -C ../../test/stem stldbg-shared + (cd ../../test/stem; ${OUTPUT_DIR_STLDBG}/stem_ut) || exit 1 +endif + +depend:: + $(MAKE) -C ../../test/stem depend 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:10:51
|
Revision: 1671 http://complement.svn.sourceforge.net/complement/?rev=1671&view=rev Author: complement Date: 2007-08-03 13:10:49 -0700 (Fri, 03 Aug 2007) Log Message: ----------- lost stem unit test? more tags for unit tests Modified Paths: -------------- trunk/complement/explore/lib/exam/Makefile trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/Makefile.inc trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile trunk/complement/explore/lib/mt/ut/Makefile trunk/complement/explore/lib/sockios/Makefile Added 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 Modified: trunk/complement/explore/lib/exam/Makefile =================================================================== --- trunk/complement/explore/lib/exam/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/07/16 15:00:11 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:56:16 ptr> SRCROOT := ../.. @@ -29,8 +29,5 @@ (cd ./ut; ${OUTPUT_DIR_STLDBG}/exam_self_test) || exit 1 endif -depend:: - $(MAKE) -C ./ut depend - -clean:: - $(MAKE) -C ./ut clean +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Modified: trunk/complement/explore/lib/exam/ut/Makefile =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/07/21 09:01:38 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 22:53:39 ptr> SRCROOT := ../../.. @@ -8,4 +8,24 @@ INCLUDES += -I${CoMT_INCLUDE_DIR} DEFS += -D__FIT_EXAM +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam + LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} + +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 + +release-shared : LDLIBS = -lexam +dbg-shared : LDLIBS = -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lexamstlg +endif Modified: trunk/complement/explore/lib/exam/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile.inc 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/exam/ut/Makefile.inc 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,7 +1,5 @@ -# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> +# -*- makefile -*- Time-stamp: <07/08/03 22:54:01 ptr> PRGNAME = exam_self_test SRC_CC = exam_self_test.cc \ - exam_test_suite.cc \ - ../suite.cc \ - ../logger.cc + exam_test_suite.cc Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-03 20:10:49 UTC (rev 1671) @@ -6,8 +6,10 @@ * 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. + technique; add tricks to compile without STLport; + * ut: moved from ../../test/mt to ut. + 2007-07-17 Petr Ovtchenkov <pt...@is...> * test/mt: boost unit test framework was replaced by exam. Modified: trunk/complement/explore/lib/mt/Makefile =================================================================== --- trunk/complement/explore/lib/mt/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/01/23 15:00:11 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:56:04 ptr> SRCROOT := ../.. @@ -8,24 +8,26 @@ INCLUDES += -I$(SRCROOT)/include check: all-shared - $(MAKE) -C ../../test/mt - (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 - (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 - (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 + $(MAKE) -C ut all-shared + (cd ut; ${OUTPUT_DIR}/mt_ut) || exit 1 + (cd ut; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 +ifndef WITHOUT_STLPORT + (cd ut; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 +endif check-release-shared: release-shared - $(MAKE) -C ../../test/mt release-shared - (cd ../../test/mt; ${OUTPUT_DIR}/mt_ut) || exit 1 + $(MAKE) -C ut release-shared + (cd ut; ${OUTPUT_DIR}/mt_ut) || exit 1 check-dbg-shared: dbg-shared - $(MAKE) -C ../../test/mt dbg-shared - (cd ../../test/mt; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 + $(MAKE) -C ut dbg-shared + (cd ut; ${OUTPUT_DIR_DBG}/mt_ut) || exit 1 ifndef WITHOUT_STLPORT check-stldbg-shared: stldbg-shared - $(MAKE) -C ../../test/mt stldbg-shared - (cd ../../test/mt; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 + $(MAKE) -C ut stldbg-shared + (cd ut; ${OUTPUT_DIR_STLDBG}/mt_ut) || exit 1 endif -depend:: - $(MAKE) -C ../../test/mt depend +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/mt/ut/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,7 +1,6 @@ -# -*- Makefile -*- Time-stamp: <07/07/17 10:01:41 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 22:38:12 ptr> -SRCROOT := ../.. -COMPILER_NAME := gcc +SRCROOT := ../../.. include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak @@ -27,31 +26,49 @@ LIBFS_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/filesystem ifeq ($(OSNAME),linux) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif +endif + ifeq ($(OSNAME),openbsd) + release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} + +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} + +ifndef WITHOUT_STLPORT stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif +endif + release-shared : LDLIBS = -lxmt -lexam -lboost_fs +dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg -dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg +endif ifeq ($(OSNAME),freebsd) release-shared : LDLIBS += -lthr +dbg-shared : LDLIBS += -lthr +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS += -lthr -dbg-shared : LDLIBS += -lthr endif +endif ifeq ($(OSNAME),sunos) release-shared : LDLIBS += -lrt +dbg-shared : LDLIBS += -lrt +ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS += -lrt -dbg-shared : LDLIBS += -lrt endif +endif Modified: trunk/complement/explore/lib/sockios/Makefile =================================================================== --- trunk/complement/explore/lib/sockios/Makefile 2007-08-03 20:05:01 UTC (rev 1670) +++ trunk/complement/explore/lib/sockios/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <07/08/03 23:06:18 ptr> +# -*- Makefile -*- Time-stamp: <07/08/03 23:55:50 ptr> SRCROOT := ../.. @@ -29,8 +29,5 @@ (cd ut; ${OUTPUT_DIR_STLDBG}/sockios_ut) || exit 1 endif -depend:: - $(MAKE) -C ut depend - -clean:: - $(MAKE) -C ut clean +depend clean distclean mostlyclean maintainer-clean:: + ${MAKE} -C ut $@ Added: trunk/complement/explore/lib/stem/ut/stem/Convert.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Convert.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,104 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Convert.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Convert.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Convert.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,74 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Echo.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Echo.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,144 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Echo.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Echo.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Echo.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,83 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Makefile =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Makefile (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,48 @@ +# -*- 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 $@ Added: trunk/complement/explore/lib/stem/ut/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Makefile.inc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,8 @@ +# -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/NameService.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NameService.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,61 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/NameService.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NameService.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NameService.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,44 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Node.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Node.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Node.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,97 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/Node.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/Node.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/Node.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,62 @@ +// -*- 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 Added: trunk/complement/explore/lib/stem/ut/stem/NodeDL.h =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/NodeDL.h (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/NodeDL.h 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,66 @@ +// -*- 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 Property changes on: trunk/complement/explore/lib/stem/ut/stem/dl ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/stem/ut/stem/unit_test.cc =================================================================== --- trunk/complement/explore/lib/stem/ut/stem/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/stem/ut/stem/unit_test.cc 2007-08-03 20:10:49 UTC (rev 1671) @@ -0,0 +1,835 @@ +// -*- 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: <Dmi...@us...> - 2008-06-30 12:31:57
|
Revision: 1931 http://complement.svn.sourceforge.net/complement/?rev=1931&view=rev Author: DmitryOsmakov Date: 2008-06-30 05:31:55 -0700 (Mon, 30 Jun 2008) Log Message: ----------- fix opts/ut Modified Paths: -------------- trunk/complement/explore/lib/misc/ut/opts_test.cc trunk/complement/explore/lib/mt/ut/Makefile Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-30 06:40:02 UTC (rev 1930) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-30 12:31:55 UTC (rev 1931) @@ -292,6 +292,7 @@ return EXAM_RESULT; } + int EXAM_IMPL(opts_test::defaults) { { @@ -324,8 +325,18 @@ opts << option<string>( "run tests by number", 'r', "run" )["0"]; - EXAM_CHECK( opts.is_set( 'r' ) ); - EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); + try { + opts.parse( argc , argv ); + + EXAM_CHECK( opts.is_set( 'r' ) ); + EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); + } + catch( const Opts::unknown_option& e) { + } + catch( const Opts::arg_typemismatch&e ) { + } + catch( ... ) { + } } { @@ -340,18 +351,6 @@ EXAM_CHECK( opts.get<string>( 'r' ) == "20" ); // but has default value } - { - const char* argv[] = { "name", "-r", "10" }; - int argc = sizeof( argv ) / sizeof(argv[0]); - - Opts opts; - - opts << option<string>( "run tests by number", 'r', "run" ); - - EXAM_CHECK( opts.is_set( 'r' ) ); - EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); - } - return EXAM_RESULT; } Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2008-06-30 06:40:02 UTC (rev 1930) +++ trunk/complement/explore/lib/mt/ut/Makefile 2008-06-30 12:31:55 UTC (rev 1931) @@ -49,7 +49,7 @@ endif -release-shared : LDLIBS = -lxmt -lexam -lboost_fs +release-shared : LDLIBS = -lxmt -lexam -lboost_filesystem dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2008-06-30 12:50:46
|
Revision: 1932 http://complement.svn.sourceforge.net/complement/?rev=1932&view=rev Author: complement Date: 2008-06-30 05:50:41 -0700 (Mon, 30 Jun 2008) Log Message: ----------- Revert "fix opts/ut" This reverts commit bd109078f223aecfa6cf41029a50ed33f8e3c2eb. Modified Paths: -------------- trunk/complement/explore/lib/misc/ut/opts_test.cc trunk/complement/explore/lib/mt/ut/Makefile Modified: trunk/complement/explore/lib/misc/ut/opts_test.cc =================================================================== --- trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-30 12:31:55 UTC (rev 1931) +++ trunk/complement/explore/lib/misc/ut/opts_test.cc 2008-06-30 12:50:41 UTC (rev 1932) @@ -292,7 +292,6 @@ return EXAM_RESULT; } - int EXAM_IMPL(opts_test::defaults) { { @@ -325,18 +324,8 @@ opts << option<string>( "run tests by number", 'r', "run" )["0"]; - try { - opts.parse( argc , argv ); - - EXAM_CHECK( opts.is_set( 'r' ) ); - EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); - } - catch( const Opts::unknown_option& e) { - } - catch( const Opts::arg_typemismatch&e ) { - } - catch( ... ) { - } + EXAM_CHECK( opts.is_set( 'r' ) ); + EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); } { @@ -351,6 +340,18 @@ EXAM_CHECK( opts.get<string>( 'r' ) == "20" ); // but has default value } + { + const char* argv[] = { "name", "-r", "10" }; + int argc = sizeof( argv ) / sizeof(argv[0]); + + Opts opts; + + opts << option<string>( "run tests by number", 'r', "run" ); + + EXAM_CHECK( opts.is_set( 'r' ) ); + EXAM_CHECK( opts.get<string>( 'r' ) == "10" ); + } + return EXAM_RESULT; } Modified: trunk/complement/explore/lib/mt/ut/Makefile =================================================================== --- trunk/complement/explore/lib/mt/ut/Makefile 2008-06-30 12:31:55 UTC (rev 1931) +++ trunk/complement/explore/lib/mt/ut/Makefile 2008-06-30 12:50:41 UTC (rev 1932) @@ -49,7 +49,7 @@ endif -release-shared : LDLIBS = -lxmt -lexam -lboost_filesystem +release-shared : LDLIBS = -lxmt -lexam -lboost_fs dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg ifndef WITHOUT_STLPORT stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |