complement-svn Mailing List for Complement (Page 15)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2007-07-18 12:17:24
|
Revision: 1628 http://svn.sourceforge.net/complement/?rev=1628&view=rev Author: complement Date: 2007-07-18 05:17:22 -0700 (Wed, 18 Jul 2007) Log Message: ----------- ref to GNU Standard Tags Modified Paths: -------------- trunk/WWW/explore/Complement/MakeTags.shtml Modified: trunk/WWW/explore/Complement/MakeTags.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeTags.shtml 2007-07-18 12:01:38 UTC (rev 1627) +++ trunk/WWW/explore/Complement/MakeTags.shtml 2007-07-18 12:17:22 UTC (rev 1628) @@ -19,6 +19,8 @@ </div> <div class="main"> <h2 class="lheader">Build tags</h2> + <p>This make tags inspired by <a href="http://www.gnu.org/software/make/manual/html_node/Standard-Targets.html#Standard-Targets">GNU make Standard Targets document</a>. + </p> <dl> <dt>all</dt> <dd>Deafult tag; build release-shared, dbg-shared, stlport-debug (if applicable) tags</dd> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 12:01:46
|
Revision: 1627 http://svn.sourceforge.net/complement/?rev=1627&view=rev Author: complement Date: 2007-07-18 05:01:38 -0700 (Wed, 18 Jul 2007) Log Message: ----------- boost unit test framework replaced by exam Modified Paths: -------------- trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/test/stem/Echo.cc trunk/complement/explore/test/stem/Echo.h trunk/complement/explore/test/stem/Makefile trunk/complement/explore/test/stem/NameService.cc trunk/complement/explore/test/stem/NameService.h trunk/complement/explore/test/stem/Node.cc trunk/complement/explore/test/stem/Node.h trunk/complement/explore/test/stem/NodeDL.h trunk/complement/explore/test/stem/dl/Makefile trunk/complement/explore/test/stem/dl/loadable_stem.cc trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,3 +1,7 @@ +2007-07-18 Petr Ovtchenkov <pt...@is...> + + * test/stem: boost unit test framework replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libstem: library version 4.6.0 Modified: trunk/complement/explore/test/stem/Echo.cc =================================================================== --- trunk/complement/explore/test/stem/Echo.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Echo.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <06/11/29 13:02:34 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -13,10 +13,8 @@ #include <stem/NetTransport.h> #include <stem/EvManager.h> -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - using namespace stem; StEMecho::StEMecho() @@ -83,7 +81,7 @@ void EchoClient::handler1( const stem::Event& ev ) { - BOOST_CHECK( ev.value() == mess ); + EXAM_CHECK_ASYNC( ev.value() == mess ); cnd.set(true); } @@ -131,7 +129,7 @@ void PeerClient::handler1( const stem::Event& ev ) { - BOOST_CHECK( ev.value() == mess ); + EXAM_CHECK( ev.value() == mess ); cnd.set(true); } Modified: trunk/complement/explore/test/stem/Echo.h =================================================================== --- trunk/complement/explore/test/stem/Echo.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Echo.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <07/07/11 21:45:09 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/Makefile =================================================================== --- trunk/complement/explore/test/stem/Makefile 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Makefile 2007-07-18 12:01:38 UTC (rev 1627) @@ -10,22 +10,22 @@ include Makefile.inc include ${SRCROOT}/Makefiles/gmake/top.mak -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include LIBMT_DIR = ${CoMT_DIR}/lib/mt LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -L${LIBSTEM_DIR}/${OUTPUT_DIR} -Wl,--rpath=./dl/${OUTPUT_DIR}:${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${LIBSTEM_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=./dl/${OUTPUT_DIR_STLDBG}:${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -L${LIBSTEM_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=./dl/${OUTPUT_DIR_DBG}:${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${LIBSTEM_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif -release-shared : LDLIBS = -lxmt -lsockios -lstem -lboost_test_utf -ldl -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lboost_test_utfstlg -ldl -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lboost_test_utfg -ldl +release-shared : LDLIBS = -lxmt -lsockios -lstem -lexam -ldl +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg -ldl +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg -lexamg -ldl # dbg-shared: DEFS += -DDEBUG Modified: trunk/complement/explore/test/stem/NameService.cc =================================================================== --- trunk/complement/explore/test/stem/NameService.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NameService.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,17 +1,13 @@ // -*- C++ -*- Time-stamp: <06/11/29 10:50:21 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - #include <iostream> #include <functional> #include <iterator> Modified: trunk/complement/explore/test/stem/NameService.h =================================================================== --- trunk/complement/explore/test/stem/NameService.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NameService.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <07/07/11 21:47:37 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/Node.cc =================================================================== --- trunk/complement/explore/test/stem/Node.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Node.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,19 +2,13 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> - -using namespace boost::unit_test_framework; - -#include <iostream> - #include "Node.h" using namespace std; Modified: trunk/complement/explore/test/stem/Node.h =================================================================== --- trunk/complement/explore/test/stem/Node.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/Node.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,7 +2,7 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/NodeDL.h =================================================================== --- trunk/complement/explore/test/stem/NodeDL.h 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/NodeDL.h 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,7 +2,7 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 Modified: trunk/complement/explore/test/stem/dl/Makefile =================================================================== --- trunk/complement/explore/test/stem/dl/Makefile 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/dl/Makefile 2007-07-18 12:01:38 UTC (rev 1627) @@ -11,7 +11,7 @@ include ${SRCROOT}/Makefiles/gmake/top.mak LIBSTEM_DIR = ${CoMT_DIR}/lib/stem -INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +INCLUDES += -I$(SRCROOT)/include #LDSEARCH = -L${STLPORT_LIB_DIR} -L${CoMT_LIB_DIR} release-shared: LDSEARCH += -L${LIBSTEM_DIR}/${OUTPUT_DIR} Modified: trunk/complement/explore/test/stem/dl/loadable_stem.cc =================================================================== --- trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/dl/loadable_stem.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -2,17 +2,13 @@ /* * - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -// #include <boost/test/unit_test.hpp> - -// using namespace boost::unit_test_framework; - #include "../NodeDL.h" using namespace stem; @@ -33,15 +29,12 @@ NodeDL::~NodeDL() { - // cnd.wait(); } void NodeDL::handler1( const stem::Event& ) { - // std::cerr << "I am here 1\n"; v = 1; cnd.set(true); - // std::cerr << "I am here 2\n"; } void NodeDL::wait() @@ -71,15 +64,12 @@ NewNodeDL::~NewNodeDL() { - // cnd.wait(); } void NewNodeDL::handler1( const stem::Event& ) { - // std::cerr << "I am here 1\n"; v = 1; cnd.set(true); - // std::cerr << "I am here 2\n"; } void NewNodeDL::wait() Modified: trunk/complement/explore/test/stem/unit_test.cc =================================================================== --- trunk/complement/explore/test/stem/unit_test.cc 2007-07-18 10:24:21 UTC (rev 1626) +++ trunk/complement/explore/test/stem/unit_test.cc 2007-07-18 12:01:38 UTC (rev 1627) @@ -1,17 +1,15 @@ // -*- C++ -*- Time-stamp: <07/07/12 00:48:50 ptr> /* - * Copyright (c) 2002, 2003, 2006 + * Copyright (c) 2002, 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <mt/xmt.h> #include <mt/shm.h> @@ -42,29 +40,35 @@ using namespace std; -struct stem_test +class stem_test { + public: + stem_test(); + ~stem_test(); + void shm_init(); void shm_finit(); - void basic1(); - void basic2(); - void basic1new(); - void basic2new(); - void dl(); - void ns(); + int EXAM_DECL(basic1); + int EXAM_DECL(basic2); + int EXAM_DECL(basic1new); + int EXAM_DECL(basic2new); + int EXAM_DECL(dl); + int EXAM_DECL(ns); - void echo(); - void echo_net(); - void net_echo(); - void peer(); - void boring_manager(); + int EXAM_DECL(echo); + int EXAM_DECL(echo_net); + int EXAM_DECL(net_echo); + int EXAM_DECL(peer); + int EXAM_DECL(boring_manager); static xmt::Thread::ret_code thr1( void * ); static xmt::Thread::ret_code thr1new( void * ); + + private: }; -void stem_test::basic1() +int EXAM_IMPL(stem_test::basic1) { Node node( 2000 ); @@ -74,20 +78,24 @@ node.Send( ev ); node.wait(); - BOOST_CHECK_EQUAL( node.v, 1 ); + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; } -void stem_test::basic2() +int EXAM_IMPL(stem_test::basic2) { Node node( 2000 ); xmt::Thread t1( thr1 ); - t1.join(); + EXAM_CHECK( t1.join().iword == 0 ); node.wait(); - BOOST_CHECK_EQUAL( node.v, 1 ); + EXAM_CHECK( node.v == 1 ); + + return EXAM_RESULT; } xmt::Thread::ret_code stem_test::thr1( void * ) @@ -105,7 +113,7 @@ return rt; } -void stem_test::basic1new() +int EXAM_IMPL(stem_test::basic1new) { NewNode *node = new NewNode( 2000 ); @@ -116,11 +124,13 @@ node->wait(); - BOOST_CHECK_EQUAL( node->v, 1 ); + EXAM_CHECK( node->v == 1 ); delete node; + + return EXAM_RESULT; } -void stem_test::basic2new() +int EXAM_IMPL(stem_test::basic2new) { NewNode *node = new NewNode( 2000 ); @@ -129,8 +139,10 @@ t1.join(); node->wait(); - BOOST_CHECK_EQUAL( node->v, 1 ); + EXAM_CHECK( node->v == 1 ); delete node; + + return EXAM_RESULT; } xmt::Thread::ret_code stem_test::thr1new( void * ) @@ -150,24 +162,24 @@ return rt; } -void stem_test::dl() +int EXAM_IMPL(stem_test::dl) { void *lh = dlopen( "libloadable_stem.so", RTLD_LAZY ); // Path was passed via -Wl,--rpath= - BOOST_REQUIRE( lh != NULL ); + EXAM_REQUIRE( lh != NULL ); void *(*f)(unsigned); void (*g)(void *); void (*w)(void *); int (*v)(void *); *(void **)(&f) = dlsym( lh, "create_NewNodeDL" ); - BOOST_REQUIRE( f != NULL ); + EXAM_REQUIRE( f != NULL ); *(void **)(&g) = dlsym( lh, "destroy_NewNodeDL" ); - BOOST_REQUIRE( g != NULL ); + EXAM_REQUIRE( g != NULL ); *(void **)(&w) = dlsym( lh, "wait_NewNodeDL" ); - BOOST_REQUIRE( w != NULL ); + EXAM_REQUIRE( w != NULL ); *(void **)(&v) = dlsym( lh, "v_NewNodeDL" ); - BOOST_REQUIRE( v != NULL ); + EXAM_REQUIRE( v != NULL ); NewNodeDL *node = reinterpret_cast<NewNodeDL *>( f( 2002 ) ); stem::Event ev( NODE_EV2 ); @@ -175,13 +187,15 @@ node->Send( ev ); w( reinterpret_cast<void *>(node) ); - BOOST_CHECK_EQUAL( v(reinterpret_cast<void *>(node)), 1 ); + EXAM_CHECK( v(reinterpret_cast<void *>(node)) == 1 ); g( reinterpret_cast<void *>(node) ); dlclose( lh ); + + return EXAM_RESULT; } -void stem_test::ns() +int EXAM_IMPL(stem_test::ns) { Node node( 2003, "Node" ); Naming nm; @@ -195,11 +209,11 @@ // this is sample of all inline find: Naming::nsrecords_type::const_iterator i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "ns" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "ns" ); - BOOST_CHECK( i->first.hid == xmt::hostid() ); - BOOST_CHECK( i->first.pid == getpid() ); - BOOST_CHECK( i->first.addr == stem::ns_addr ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "ns" ); + EXAM_CHECK( i->first.hid == xmt::hostid() ); + EXAM_CHECK( i->first.pid == getpid() ); + EXAM_CHECK( i->first.addr == stem::ns_addr ); // well, but for few seaches declare and reuse functors: equal_to<string> eq; @@ -210,20 +224,20 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first.addr == 2003 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->first == nm.self_glid() ); - BOOST_CHECK( i->second.length() == 0 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->first == nm.self_glid() ); + EXAM_CHECK( i->second.length() == 0 ); nm.lst.clear(); nm.reset(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( stem::ns_addr ); @@ -234,32 +248,34 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "ns" ) ), second ) ); - BOOST_CHECK( i == nm.lst.end() ); + EXAM_CHECK( i == nm.lst.end() ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eq, string( "Node" ) ), second ) ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "Node" ); - BOOST_CHECK( i->first.addr == 2003 ); + EXAM_CHECK( i != nm.lst.end() ); + EXAM_CHECK( i->second == "Node" ); + EXAM_CHECK( i->first.addr == 2003 ); i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( eqa, nm.self_glid() ), first ) ); - BOOST_CHECK( i == nm.lst.end() ); + EXAM_CHECK( i == nm.lst.end() ); nm.lst.clear(); nm.reset(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); evname.value() = "No-such-name"; nm.Send( evname ); nm.wait(); - BOOST_CHECK( nm.lst.empty() ); + EXAM_CHECK( nm.lst.empty() ); + + return EXAM_RESULT; } -void stem_test::echo() +int EXAM_IMPL(stem_test::echo) { try { sockmgr_stream_MP<stem::NetTransport> srv( 6995 ); @@ -269,8 +285,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery + EXAM_CHECK( zero != stem::badaddr ); + EXAM_CHECK( zero == 0 ); // NetTransportMgr should detect local delivery EchoClient node; @@ -291,6 +307,8 @@ } catch ( ... ) { } + + return EXAM_RESULT; } const char fname[] = "/tmp/stem_test.shm"; @@ -298,23 +316,23 @@ xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; -void stem_test::shm_init() +stem_test::stem_test() { try { seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); } catch ( const xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } } -void stem_test::shm_finit() +stem_test::~stem_test() { seg.deallocate(); unlink( fname ); } -void stem_test::echo_net() +int EXAM_IMPL(stem_test::echo_net) { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); fcnd.set( false ); @@ -329,8 +347,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); // NetTransportMgr should detect external delivery + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); // NetTransportMgr should detect external delivery EchoClient node; @@ -360,7 +378,7 @@ fcnd.set( true ); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); srv.close(); srv.wait(); @@ -373,11 +391,13 @@ shm_cnd.deallocate( &fcnd, 1 ); // cerr << "Fine\n"; + + return EXAM_RESULT; } // same as echo_net(), but server in child process -void stem_test::net_echo() +int EXAM_IMPL(stem_test::net_echo) { try { xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); @@ -396,7 +416,7 @@ // echo.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); // echo.manager()->settrs( &std::cerr ); - BOOST_REQUIRE( srv.good() ); + EXAM_CHECK_ASYNC( srv.good() ); c.set( true ); // ok, server listen b.wait(); // server may go away @@ -418,8 +438,8 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); - BOOST_REQUIRE( mgr.good() ); - BOOST_REQUIRE( zero != stem::badaddr ); + EXAM_REQUIRE( mgr.good() ); + EXAM_REQUIRE( zero != stem::badaddr ); EchoClient node; stem::Event ev( NODE_EV_ECHO ); @@ -436,7 +456,7 @@ b.wait(); // server may go away int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } (&c)->~__condition<true>(); @@ -445,8 +465,10 @@ shm_b.deallocate( &b, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } extern "C" { @@ -456,7 +478,7 @@ } -void stem_test::peer() +int EXAM_IMPL(stem_test::peer) { /* * Scheme: @@ -515,9 +537,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); - BOOST_CHECK( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -527,13 +549,13 @@ stem::gaddr_type ga( c1.manager()->reflect( zero ) ); - BOOST_CHECK( ga.addr == 0 ); - BOOST_CHECK( ga.pid != -1 ); + EXAM_CHECK_ASYNC( ga.addr == 0 ); + EXAM_CHECK_ASYNC( ga.pid != -1 ); ga.addr = stem::ns_addr; // this will be global address of ns of the same process // as zero - BOOST_CHECK( c1.manager()->reflect( ga ) != stem::badaddr ); + EXAM_CHECK_ASYNC( c1.manager()->reflect( ga ) != stem::badaddr ); stem::Event evname( EV_STEM_GET_NS_NAME ); evname.dest( c1.manager()->reflect( ga ) ); @@ -551,8 +573,8 @@ i = find_if( nm.lst.begin(), nm.lst.end(), compose1( bind2nd( equal_to<string>(), string( "c2@here" ) ), select2nd<pair<stem::gaddr_type,string> >() ) ); } while ( i == nm.lst.end() ); - BOOST_CHECK( i != nm.lst.end() ); - BOOST_CHECK( i->second == "c2@here" ); + EXAM_CHECK_ASYNC( i != nm.lst.end() ); + EXAM_CHECK_ASYNC( i->second == "c2@here" ); stem::addr_type pa = c1.manager()->reflect( i->first ); if ( pa == stem::badaddr ) { // unknown yet @@ -563,7 +585,7 @@ } } - BOOST_CHECK( pa != stem::badaddr ); + EXAM_CHECK_ASYNC( pa != stem::badaddr ); if ( pa != stem::badaddr ) { stem::Event pe( NODE_EV_ECHO ); @@ -615,9 +637,9 @@ stem::addr_type zero = mgr.open( "localhost", 6995 ); // take address of 'zero' (aka default) object via net transport from server // It done like it should on client side - BOOST_CHECK( zero != stem::badaddr ); - BOOST_CHECK( zero != 0 ); - BOOST_CHECK( zero & stem::extbit ); // "external" address + EXAM_CHECK_ASYNC( zero != stem::badaddr ); + EXAM_CHECK_ASYNC( zero != 0 ); + EXAM_CHECK_ASYNC( zero & stem::extbit ); // "external" address stem::Event ev( NODE_EV_REGME ); ev.dest( zero ); @@ -659,9 +681,11 @@ shm_cnd.deallocate( &pcnd, 1 ); (&scnd)->~__condition<true>(); shm_cnd.deallocate( &scnd, 1 ); + + return EXAM_RESULT; } -void stem_test::boring_manager() +int EXAM_IMPL(stem_test::boring_manager) { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); fcnd.set( false ); @@ -709,81 +733,43 @@ (&fcnd)->~__condition<true>(); shm_cnd.deallocate( &fcnd, 1 ); + + return EXAM_RESULT; } // ----------------- // ----------------- -struct stem_test_suite : - public test_suite +int EXAM_DECL(stem_test_suite); + +int EXAM_IMPL(stem_test_suite) { - stem_test_suite(); -}; + exam::test_suite::test_case_type tc[4]; + exam::test_suite t( "libsteam test suite" ); + stem_test test; -stem_test_suite::stem_test_suite() : - test_suite( "StEM test suite" ) -{ - boost::shared_ptr<stem_test> instance( new stem_test() ); + tc[1] = t.add( &stem_test::basic2, test, "basic2", + tc[0] = t.add( &stem_test::basic1, test, "basic1" ) ); - test_case *basic1_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic1, instance ); - test_case *basic2_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic2, instance ); - test_case *basic1n_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic1new, instance ); - test_case *basic2n_tc = BOOST_CLASS_TEST_CASE( &stem_test::basic2new, instance ); - test_case *dl_tc = BOOST_CLASS_TEST_CASE( &stem_test::dl, instance ); - test_case *ns_tc = BOOST_CLASS_TEST_CASE( &stem_test::ns, instance ); - test_case *echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo, instance ); - test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_init, instance ); - test_case *echo_net_tc = BOOST_CLASS_TEST_CASE( &stem_test::echo_net, instance ); - test_case *net_echo_tc = BOOST_CLASS_TEST_CASE( &stem_test::net_echo, instance ); - test_case *peer_tc = BOOST_CLASS_TEST_CASE( &stem_test::peer, instance ); - test_case *boring_manager_tc = BOOST_CLASS_TEST_CASE( &stem_test::boring_manager, instance ); - test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &stem_test::shm_finit, instance ); + tc[2] = t.add( &stem_test::basic1new, test, "basic1new", tc[0] ); - basic2_tc->depends_on( basic1_tc ); - basic1n_tc->depends_on( basic1_tc ); - basic2n_tc->depends_on( basic2_tc ); - basic2n_tc->depends_on( basic1n_tc ); - dl_tc->depends_on( basic2n_tc ); - ns_tc->depends_on( basic1_tc ); + t.add( &stem_test::dl, test, "dl", + t.add( &stem_test::basic2new, test, "basic2new", tc + 1, tc + 3 ) ); + t.add( &stem_test::ns, test, "ns", tc[0] ); - echo_tc->depends_on( basic2_tc ); - echo_net_tc->depends_on( shm_init_tc ); - echo_net_tc->depends_on( echo_tc ); - net_echo_tc->depends_on( shm_init_tc ); - net_echo_tc->depends_on( echo_net_tc ); - peer_tc->depends_on( echo_tc ); - peer_tc->depends_on( shm_init_tc ); - boring_manager_tc->depends_on( peer_tc ); - boring_manager_tc->depends_on( shm_init_tc ); - shm_finit_tc->depends_on( shm_init_tc ); + t.add( &stem_test::net_echo, test, "net echo", + t.add( &stem_test::echo_net, test, "echo_net", + tc[3] = t.add( &stem_test::echo, test, "echo", tc[1] ) ) ); - add( basic1_tc ); - add( basic2_tc ); - add( basic1n_tc ); - add( basic2n_tc ); - add( dl_tc ); - add( ns_tc ); + t.add( &stem_test::boring_manager, test, "boring_manager", + t.add( &stem_test::peer, test, "peer", tc[3] ) ); - add( echo_tc ); - add( shm_init_tc ); - add( echo_net_tc ); - add( net_echo_tc ); - add( peer_tc ); - add( boring_manager_tc ); - add( shm_finit_tc ); + return t.girdle(); } -test_suite *init_unit_test_suite( int argc, char **argv ) +int main( int, char ** ) { - // test_suite *ts = BOOST_TEST_SUITE( "libstem test" ); - - // ts->add( new stem_test_suite() ); - - // ts->add( BOOST_TEST_CASE( &send_test ) ); - // ts->add( BOOST_TEST_CASE( &send2_test ) ); - - // return ts; - return new stem_test_suite(); + return stem_test_suite(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 10:32:52
|
Revision: 1626 http://svn.sourceforge.net/complement/?rev=1626&view=rev Author: complement Date: 2007-07-18 03:24:21 -0700 (Wed, 18 Jul 2007) Log Message: ----------- refine test Modified Paths: -------------- trunk/complement/explore/test/sockios/client-wc.cc Modified: trunk/complement/explore/test/sockios/client-wc.cc =================================================================== --- trunk/complement/explore/test/sockios/client-wc.cc 2007-07-18 10:23:42 UTC (rev 1625) +++ trunk/complement/explore/test/sockios/client-wc.cc 2007-07-18 10:24:21 UTC (rev 1626) @@ -71,18 +71,22 @@ Thread::ret_code server_proc( void * ) { + Thread::ret_code rt; + rt.iword = 0; + cnd.set( false ); srv_type srv( port ); // start server ::srv_p = &srv; + if ( !srv.is_open() || !srv.good() ) { + ++rt.iword; + } + cnd.set( true ); srv.wait(); - Thread::ret_code rt; - rt.iword = 0; - return rt; } @@ -100,6 +104,10 @@ getline( sock, buf ); + if ( !sock.is_open() || !sock.good() ) { + ++rt.iword; + } + EXAM_CHECK_ASYNC( buf == "hello" ); // xmt::delay( xmt::timespec( 5, 0 ) ); @@ -131,8 +139,8 @@ cnd_close.set( false ); Thread client( client_proc ); - client.join(); - srv.join(); + EXAM_CHECK( client.join().iword == 0 ); + EXAM_CHECK( srv.join().iword == 0 ); return EXAM_RESULT; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 10:23:43
|
Revision: 1625 http://svn.sourceforge.net/complement/?rev=1625&view=rev Author: complement Date: 2007-07-18 03:23:42 -0700 (Wed, 18 Jul 2007) Log Message: ----------- describe TAGS Modified Paths: -------------- trunk/WWW/explore/Complement/MakeTags.shtml Modified: trunk/WWW/explore/Complement/MakeTags.shtml =================================================================== --- trunk/WWW/explore/Complement/MakeTags.shtml 2007-07-18 10:02:02 UTC (rev 1624) +++ trunk/WWW/explore/Complement/MakeTags.shtml 2007-07-18 10:23:42 UTC (rev 1625) @@ -63,9 +63,9 @@ <dt>install-strip</dt> <dd></dd> <dt>TAGS</dt> - <dd></dd> + <dd>generate TAGS index file (useful for emacses)</dd> <dt>tags</dt> - <dd></dd> + <dd>generate tags index file (useful for vi and his friends)</dd> <dt>dist</dt> <dd></dd> <dt>check</dt> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 10:02:05
|
Revision: 1624 http://svn.sourceforge.net/complement/?rev=1624&view=rev Author: complement Date: 2007-07-18 03:02:02 -0700 (Wed, 18 Jul 2007) Log Message: ----------- refine test Modified Paths: -------------- trunk/complement/explore/test/sockios/ConnectionProcessor.cc trunk/complement/explore/test/sockios/ConnectionProcessor.h trunk/complement/explore/test/sockios/sockios_test_suite.cc Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 09:49:45 UTC (rev 1623) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 10:02:02 UTC (rev 1624) @@ -261,3 +261,76 @@ { EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } + +int EXAM_IMPL(trivial_sockios_test::shared_socket) +{ +#ifndef __FIT_NO_POLL + sockmgr_stream_MP<ConnectionProcessor2> srv( port ); // start server + + EXAM_CHECK( srv.is_open() ); + EXAM_CHECK( srv.good() ); + + { + EXAM_MESSAGE( "Client start" ); + std::sockstream sock( "localhost", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + + { + std::sockstream sock2; + sock2.attach( sock.rdbuf()->fd() ); + + sock2 << ::message1 << endl; + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + srv_line.clear(); + getline( sock2, srv_line ); + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + EXAM_CHECK( srv_line == ::message_rsp1 ); + + EXAM_MESSAGE( "Subclient close connection (subclient's end of life)" ); + } + + sock << ::message2 << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + srv_line.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp2 ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections +#else + EXAM_ERROR( "select-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.h =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 09:49:45 UTC (rev 1623) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 10:02:02 UTC (rev 1624) @@ -40,6 +40,7 @@ int EXAM_DECL(simple); int EXAM_DECL(listen_iface); + int EXAM_DECL(shared_socket); private: in_addr hostaddr; Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:49:45 UTC (rev 1623) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 10:02:02 UTC (rev 1624) @@ -29,82 +29,6 @@ using namespace std; -int generator_1() -{ - static int i = 0; - - return i++; -} - -int EXAM_IMPL(test_shared_socket) -{ -#ifndef __FIT_NO_POLL - sockmgr_stream_MP<ConnectionProcessor2> srv( port ); // start server - - { - EXAM_MESSAGE( "Client start" ); - std::sockstream sock( "localhost", ::port ); - string srv_line; - - sock << ::message << endl; - - EXAM_CHECK( sock.good() ); - - // sock.clear(); - getline( sock, srv_line ); - - EXAM_CHECK( sock.good() ); - - EXAM_CHECK( srv_line == ::message_rsp ); - - EXAM_MESSAGE( "Client close connection (client's end of life)" ); - - { - std::sockstream sock2; - sock2.attach( sock.rdbuf()->fd() ); - - sock2 << ::message1 << endl; - - EXAM_CHECK( sock.good() ); - EXAM_CHECK( sock2.good() ); - - srv_line.clear(); - getline( sock2, srv_line ); - - EXAM_CHECK( sock.good() ); - EXAM_CHECK( sock2.good() ); - - EXAM_CHECK( srv_line == ::message_rsp1 ); - - EXAM_MESSAGE( "Subclient close connection (subclient's end of life)" ); - } - - sock << ::message2 << endl; - - EXAM_CHECK( sock.good() ); - - // sock.clear(); - srv_line.clear(); - getline( sock, srv_line ); - - EXAM_CHECK( sock.good() ); - - EXAM_CHECK( srv_line == ::message_rsp2 ); - - EXAM_MESSAGE( "Client close connection (client's end of life)" ); - - // sock.close(); // no needs, that will done in sock destructor - } - - srv.close(); // close server, so we don't wait server termination on next line - srv.wait(); // Wait for server stop to serve clients connections -#else - EXAM_ERROR( "select-based sockmgr not implemented on this platform" ); -#endif - - return EXAM_RESULT; -} - int EXAM_DECL(test_client_close_socket); int EXAM_DECL(test_more_bytes_in_socket); int EXAM_DECL(test_more_bytes_in_socket2); @@ -139,10 +63,10 @@ // Old tests - t.add( &trivial_sockios_test::listen_iface, trivial_test, "listen_iface", tc[0] ); + t.add( &trivial_sockios_test::listen_iface, trivial_test, "trivial_sockios_test::listen_iface", tc[0] ); t.add( srv_close_connection_test, "srv_close_connection_test" ); - t.add( test_shared_socket, "test_shared_socket" ); + t.add( &trivial_sockios_test::shared_socket, trivial_test, "trivial_sockios_test::shared_socket", tc[0] ); t.add( test_client_close_socket, "test_client_close_socket" ); t.add( test_more_bytes_in_socket, "test_more_bytes_in_socket" ); // timeout 5 t.add( test_more_bytes_in_socket2, "test_more_bytes_in_socket2" ); // timeout 5 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 09:49:48
|
Revision: 1623 http://svn.sourceforge.net/complement/?rev=1623&view=rev Author: complement Date: 2007-07-18 02:49:45 -0700 (Wed, 18 Jul 2007) Log Message: ----------- 'mass write' test removed --- it really was not completed and do nothing Modified Paths: -------------- trunk/complement/explore/test/sockios/Makefile.inc trunk/complement/explore/test/sockios/sockios_test_suite.cc Removed Paths: ------------- trunk/complement/explore/test/sockios/client-mw.cc trunk/complement/explore/test/sockios/client-mw.h Modified: trunk/complement/explore/test/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/test/sockios/Makefile.inc 2007-07-18 09:42:23 UTC (rev 1622) +++ trunk/complement/explore/test/sockios/Makefile.inc 2007-07-18 09:49:45 UTC (rev 1623) @@ -1,6 +1,6 @@ # -*- makefile -*- Time-stamp: <07/07/18 08:37:31 ptr> PRGNAME = sockios_ut -SRC_CC = ConnectionProcessor.cc message.cc client-mw.cc \ +SRC_CC = ConnectionProcessor.cc message.cc \ client-wc.cc close_socket.cc bytes_in_socket.cc bytes_in_socket2.cc \ names.cc sockios_test.cc sockios_test_suite.cc unit_test.cc Deleted: trunk/complement/explore/test/sockios/client-mw.cc =================================================================== --- trunk/complement/explore/test/sockios/client-mw.cc 2007-07-18 09:42:23 UTC (rev 1622) +++ trunk/complement/explore/test/sockios/client-mw.cc 2007-07-18 09:49:45 UTC (rev 1623) @@ -1,51 +0,0 @@ -// -*- C++ -*- Time-stamp: <05/12/01 20:29:05 ptr> - -/* - * - * Copyright (c) 2002, 2003 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#include <exam/suite.h> - -#include <string> -#include <sockios/sockstream> -#include <iostream> -#include <iomanip> -#include <mt/xmt.h> - -#include "client-mw.h" -#include "message.h" - -using namespace std; -using namespace xmt; - -int EXAM_IMPL(ClientMassWrite::client_proc) -{ - using namespace test_area; - - EXAM_MESSAGE( "Client start" ); - for ( int i_close = 0; i_close < ni2; ++i_close ) { - std::sockstream sock( "localhost", ::port ); - - for ( int i_send = 0; i_send < ni1; ++i_send ) { - sock.write( bin_buff1, bin_buff1_size ); - } - - EXAM_CHECK( sock.good() ); - } - EXAM_MESSAGE( "Client end" ); - - return EXAM_RESULT; -} Deleted: trunk/complement/explore/test/sockios/client-mw.h =================================================================== --- trunk/complement/explore/test/sockios/client-mw.h 2007-07-18 09:42:23 UTC (rev 1622) +++ trunk/complement/explore/test/sockios/client-mw.h 2007-07-18 09:49:45 UTC (rev 1623) @@ -1,33 +0,0 @@ -// -*- C++ -*- Time-stamp: <05/12/01 20:29:26 ptr> - -/* - * - * Copyright (c) 2002, 2003 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#ifndef __ClientMassWrite_h -#define __ClientMassWrite_h - -#include <exam/suite.h> - -// Clients simulator - -class ClientMassWrite -{ - public: - static int EXAM_DECL(client_proc); -}; - -#endif // __ClientMassWrite_h Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:42:23 UTC (rev 1622) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:49:45 UTC (rev 1623) @@ -36,34 +36,6 @@ return i++; } -#include "client-mw.h" - -int EXAM_IMPL(test_mass_processing_poll) -{ -#ifndef __FIT_NO_POLL - using namespace test_area; - - EXAM_REQUIRE( bin_buff1_size == 0 ); // test integrity of test suite - EXAM_REQUIRE( bin_buff1 == 0 ); // test integrity of test suite - - bin_buff1_size = 48; - bin_buff1 = new char [bin_buff1_size]; - EXAM_REQUIRE( bin_buff1 != 0 ); - generate_n( bin_buff1, bin_buff1_size, generator_1 ); - - ni1 = 10; - ni2 = 5; - - delete bin_buff1; - bin_buff1 = 0; - bin_buff1_size = 0; -#else - EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); -#endif - - return EXAM_RESULT; -} - int EXAM_IMPL(test_shared_socket) { #ifndef __FIT_NO_POLL @@ -169,7 +141,6 @@ t.add( &trivial_sockios_test::listen_iface, trivial_test, "listen_iface", tc[0] ); - t.add( test_mass_processing_poll, "test_mass_processing_poll" ); t.add( srv_close_connection_test, "srv_close_connection_test" ); t.add( test_shared_socket, "test_shared_socket" ); t.add( test_client_close_socket, "test_client_close_socket" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 09:42:27
|
Revision: 1622 http://svn.sourceforge.net/complement/?rev=1622&view=rev Author: complement Date: 2007-07-18 02:42:23 -0700 (Wed, 18 Jul 2007) Log Message: ----------- check of correct understanding ip expressed as string added to existent test; separate test removed Modified Paths: -------------- trunk/complement/explore/test/sockios/ConnectionProcessor.cc trunk/complement/explore/test/sockios/sockios_test_suite.cc Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 09:27:10 UTC (rev 1621) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 09:42:23 UTC (rev 1622) @@ -116,6 +116,22 @@ // sock.close(); // no needs, that will done in sock destructor } + { + std::sockstream sock( "127.0.0.1", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + } + srv.close(); // close server, so we don't wait server termination on next line srv.wait(); // Wait for server stop to serve clients connections #else Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:27:10 UTC (rev 1621) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:42:23 UTC (rev 1622) @@ -29,47 +29,6 @@ using namespace std; -int EXAM_IMPL(test_client_server_poll_local_ack) -{ -#ifndef __FIT_NO_POLL - try { - // server listen localhost (127.0.0.1), but not listen ext interface: - sockmgr_stream_MP<ConnectionProcessor> srv( 0x7f000001, port ); // start server - - { - EXAM_MESSAGE( "Client start" ); - - std::sockstream sock( "127.0.0.1", ::port ); - string srv_line; - - sock << ::message << endl; - - EXAM_CHECK( sock.good() ); - - // sock.clear(); - getline( sock, srv_line ); - - EXAM_CHECK( sock.good() ); - - EXAM_CHECK( srv_line == ::message_rsp ); - - EXAM_MESSAGE( "Client close connection (client's end of life)" ); - // sock.close(); // no needs, that will done in sock destructor - } - - srv.close(); // close server, so we don't wait server termination on next line - srv.wait(); // Wait for server stop to serve clients connections - } - catch ( std::domain_error& err ) { - EXAM_ERROR( "host not found by name" ); - } -#else - EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); -#endif - - return EXAM_RESULT; -} - int generator_1() { static int i = 0; @@ -210,7 +169,6 @@ t.add( &trivial_sockios_test::listen_iface, trivial_test, "listen_iface", tc[0] ); - t.add( test_client_server_poll_local_ack, "test_client_server_poll_local_ack" ); t.add( test_mass_processing_poll, "test_mass_processing_poll" ); t.add( srv_close_connection_test, "srv_close_connection_test" ); t.add( test_shared_socket, "test_shared_socket" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 09:27:12
|
Revision: 1621 http://svn.sourceforge.net/complement/?rev=1621&view=rev Author: complement Date: 2007-07-18 02:27:10 -0700 (Wed, 18 Jul 2007) Log Message: ----------- fix listen interfaces tests Modified Paths: -------------- trunk/complement/explore/test/sockios/ConnectionProcessor.cc trunk/complement/explore/test/sockios/ConnectionProcessor.h trunk/complement/explore/test/sockios/sockios_test_suite.cc Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 06:29:40 UTC (rev 1620) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 09:27:10 UTC (rev 1621) @@ -56,6 +56,40 @@ // ****************** +trivial_sockios_test::trivial_sockios_test() : + hostaddr( findhost( hostname().c_str() ) ) // take primary host IP +{ + // Oh, this trick not work well: hostname may be assigned to 127.0.0.1 too... + // I need list of interfaces... + + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR_ASYNC( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.inet.sin_addr; + // hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK_ASYNC( i != ifaces.end() ); + + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "lo" ) { + localaddr = i->addr.inet.sin_addr; + // hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK_ASYNC( i != ifaces.end() ); +} + int EXAM_IMPL(trivial_sockios_test::simple) { #ifndef __FIT_NO_POLL @@ -93,6 +127,62 @@ // ****************** +int EXAM_IMPL(trivial_sockios_test::listen_iface) +{ +#ifndef __FIT_NO_POLL + try { + // server not listen localhost, but listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server + + EXAM_CHECK( srv.is_open() ); + EXAM_CHECK( srv.good() ); + + { + EXAM_MESSAGE( "Client start" ); + + // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); + // std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); + std::sockstream sock( hostaddr, ::port ); + string srv_line; + + EXAM_CHECK( sock.good() ); + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + { + std::sockstream sock( localaddr, ::port ); + + EXAM_CHECK( !sock.is_open() ); + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +// ****************** + ConnectionProcessor2::ConnectionProcessor2( std::sockstream& s ) : count( 0 ) { Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.h =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 06:29:40 UTC (rev 1620) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 09:27:10 UTC (rev 1621) @@ -36,7 +36,15 @@ class trivial_sockios_test { public: + trivial_sockios_test(); + int EXAM_DECL(simple); + int EXAM_DECL(listen_iface); + + private: + in_addr hostaddr; + // sockaddr hostaddr; + in_addr localaddr; }; class ConnectionProcessor2 // Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 06:29:40 UTC (rev 1620) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 09:27:10 UTC (rev 1621) @@ -29,179 +29,6 @@ using namespace std; -int EXAM_IMPL(test_client_server_poll_nonlocal_ack) -{ -#ifndef __FIT_NO_POLL - try { - - // Oh, this trick not work well: hostname may be assigned to 127.0.0.1 too... - // I need list of interfaces... - - // take primary host IP: - in_addr hostaddr( findhost( hostname().c_str() ) ); - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - EXAM_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.inet.sin_addr; - break; - } - } - EXAM_CHECK( i != ifaces.end() ); - - // server not listen localhost, but listen ext interface: - sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server - - EXAM_CHECK( srv.is_open() ); - EXAM_CHECK( srv.good() ); - - { - EXAM_MESSAGE( "Client start" ); - - // in_addr hostaddr( findhost( hostname().c_str() ) ); - sockaddr hostaddr; - - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - EXAM_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.any; // .inet.sin_addr; - break; - } - } - EXAM_CHECK( i != ifaces.end() ); - - // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); - std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); - string srv_line; - - EXAM_CHECK( sock.good() ); - - sock << ::message << endl; - - EXAM_CHECK( sock.good() ); - - // sock.clear(); - getline( sock, srv_line ); - - EXAM_CHECK( sock.good() ); - - EXAM_CHECK( srv_line == ::message_rsp ); - - EXAM_MESSAGE( "Client close connection (client's end of life)" ); - // sock.close(); // no needs, that will done in sock destructor - } - - srv.close(); // close server, so we don't wait server termination on next line - srv.wait(); // Wait for server stop to serve clients connections - } - catch ( std::domain_error& err ) { - EXAM_ERROR( "host not found by name" ); - } -#else - EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); -#endif - - return EXAM_RESULT; -} - -int EXAM_IMPL(test_client_server_poll_nonlocal_nac) -{ -#ifndef __FIT_NO_POLL - try { - // take primary host IP: - in_addr hostaddr( findhost( hostname().c_str() ) ); - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - EXAM_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.inet.sin_addr; - break; - } - } - EXAM_CHECK( i != ifaces.end() ); - - // server not listen localhost, but listen ext interface: - sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server - - { - EXAM_MESSAGE( "Client start" ); - - // in_addr hostaddr( findhost( hostname().c_str() ) ); - sockaddr hostaddr; - - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - EXAM_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.any; // .inet.sin_addr; - break; - } - } - EXAM_CHECK( i != ifaces.end() ); - - // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); - std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); - string srv_line; - - EXAM_CHECK( sock.good() ); - - sock << ::message << endl; - - EXAM_CHECK( sock.good() ); - - // sock.clear(); - getline( sock, srv_line ); - - EXAM_CHECK( sock.good() ); - - EXAM_CHECK( srv_line == ::message_rsp ); - - EXAM_MESSAGE( "Client close connection (client's end of life)" ); - // sock.close(); // no needs, that will done in sock destructor - } - - srv.close(); // close server, so we don't wait server termination on next line - srv.wait(); // Wait for server stop to serve clients connections - } - catch ( std::domain_error& err ) { - EXAM_ERROR( "host not found by name" ); - } -#else - EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); -#endif - - return EXAM_RESULT; -} - int EXAM_IMPL(test_client_server_poll_local_ack) { #ifndef __FIT_NO_POLL @@ -381,8 +208,7 @@ // Old tests - t.add( test_client_server_poll_nonlocal_ack, "test_client_server_poll_nonlocal_ack" ); - t.add( test_client_server_poll_nonlocal_nac, "test_client_server_poll_nonlocal_nac" ); + t.add( &trivial_sockios_test::listen_iface, trivial_test, "listen_iface", tc[0] ); t.add( test_client_server_poll_local_ack, "test_client_server_poll_local_ack" ); t.add( test_mass_processing_poll, "test_mass_processing_poll" ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-18 06:29:41
|
Revision: 1620 http://svn.sourceforge.net/complement/?rev=1620&view=rev Author: complement Date: 2007-07-17 23:29:40 -0700 (Tue, 17 Jul 2007) Log Message: ----------- boost unit test framework replaced by exam Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/test/sockios/ConnectionProcessor.cc trunk/complement/explore/test/sockios/ConnectionProcessor.h trunk/complement/explore/test/sockios/Makefile trunk/complement/explore/test/sockios/Makefile.inc trunk/complement/explore/test/sockios/bytes_in_socket.cc trunk/complement/explore/test/sockios/bytes_in_socket2.cc trunk/complement/explore/test/sockios/client-mw.cc trunk/complement/explore/test/sockios/client-mw.h trunk/complement/explore/test/sockios/client-wc.cc trunk/complement/explore/test/sockios/client-wc.h trunk/complement/explore/test/sockios/close_socket.cc trunk/complement/explore/test/sockios/message.cc trunk/complement/explore/test/sockios/message.h trunk/complement/explore/test/sockios/names.cc trunk/complement/explore/test/sockios/sockios_test.cc trunk/complement/explore/test/sockios/sockios_test.h trunk/complement/explore/test/sockios/sockios_test_suite.cc trunk/complement/explore/test/sockios/sockios_test_suite.h trunk/complement/explore/test/sockios/unit_test.cc Removed Paths: ------------- trunk/complement/explore/test/sockios/client.cc trunk/complement/explore/test/sockios/client.h Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,3 +1,7 @@ +2007-07-17 Petr Ovtchenkov <pt...@is...> + + * test/mt: boost unit test framework was replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libxmt: version 1.11.0 Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,3 +1,7 @@ +2007-07-18 Petr Ovtchenkov <pt...@is...> + + * test/sockios: boost unit test framework replaced by exam. + 2007-07-12 Petr Ovtchenkov <pt...@is...> * libsockios: Version 1.12.0 Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.cc =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,95 +1,113 @@ -// -*- C++ -*- Time-stamp: <06/07/08 00:13:31 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:17:29 ptr> /* * - * Copyright (c) 2002, 2003, 2005 + * Copyright (c) 2002, 2003, 2005, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include "ConnectionProcessor.h" #include <string> #include "message.h" +#include <sockios/sockmgr.h> + using namespace std; ConnectionProcessor::ConnectionProcessor( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt } void ConnectionProcessor::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); string msg; getline( s, msg ); - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } +// ****************** +int EXAM_IMPL(trivial_sockios_test::simple) +{ +#ifndef __FIT_NO_POLL + + std::sockmgr_stream_MP<ConnectionProcessor> srv( port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + std::sockstream sock( "localhost", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +// ****************** + ConnectionProcessor2::ConnectionProcessor2( std::sockstream& s ) : count( 0 ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt } void ConnectionProcessor2::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); string msg; @@ -97,46 +115,34 @@ switch ( count ) { case 0: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; case 1: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message1 ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message1 ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp1 << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; case 2: - pr_lock.lock(); - BOOST_CHECK_EQUAL( msg, ::message2 ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( msg == ::message2 ); + EXAM_CHECK_ASYNC( s.good() ); s << ::message_rsp2 << endl; // server's response - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); break; default: - BOOST_ERROR( "Unexpected connection! count not 0, 1, 2!" ); + EXAM_ERROR_ASYNC( "Unexpected connection! count not 0, 1, 2!" ); break; } @@ -147,7 +153,5 @@ void ConnectionProcessor2::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } Modified: trunk/complement/explore/test/sockios/ConnectionProcessor.h =================================================================== --- trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/ConnectionProcessor.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,20 +1,12 @@ -// -*- C++ -*- Time-stamp: <06/07/08 00:13:11 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:08:07 ptr> /* * - * Copyright (c) 2002, 2005 + * Copyright (c) 2002, 2005, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __ConnectionProcessor_h @@ -41,6 +33,12 @@ void close(); }; +class trivial_sockios_test +{ + public: + int EXAM_DECL(simple); +}; + class ConnectionProcessor2 // { public: Modified: trunk/complement/explore/test/sockios/Makefile =================================================================== --- trunk/complement/explore/test/sockios/Makefile 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/Makefile 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <03/08/15 12:46:45 ptr> +# -*- Makefile -*- Time-stamp: <07/07/18 08:44:04 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -8,17 +8,19 @@ INCLUDES += -I$(SRCROOT)/include -I$(BOOST_INCLUDE_DIR) +DEFS += -D__FIT_EXAM LIBMT_DIR = ${CoMT_DIR}/lib/mt LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios -LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam +# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBEXAM_DIR}/${OUTPUT_DIR} -L${LIBSOCK_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBEXAM_DIR}/${OUTPUT_DIR}:${LIBSOCK_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} +stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_STLDBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} +dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBEXAM_DIR}/${OUTPUT_DIR_DBG} -L${LIBSOCK_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBEXAM_DIR}/${OUTPUT_DIR_DBG}:${LIBSOCK_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif -release-shared : LDLIBS = -lxmt -lsockios -lboost_test_utf -stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lboost_test_utfstlg -dbg-shared : LDLIBS = -lxmtg -lsockiosg -lboost_test_utfg +release-shared : LDLIBS = -lxmt -lsockios -lexam +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lexamstlg +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lexamg Modified: trunk/complement/explore/test/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/test/sockios/Makefile.inc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/Makefile.inc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/02/07 10:26:26 ptr> +# -*- makefile -*- Time-stamp: <07/07/18 08:37:31 ptr> PRGNAME = sockios_ut -SRC_CC = unit_test.cc ConnectionProcessor.cc message.cc client.cc client-mw.cc \ +SRC_CC = ConnectionProcessor.cc message.cc client-mw.cc \ client-wc.cc close_socket.cc bytes_in_socket.cc bytes_in_socket2.cc \ - names.cc sockios_test.cc sockios_test_suite.cc + names.cc sockios_test.cc sockios_test_suite.cc unit_test.cc Modified: trunk/complement/explore/test/sockios/bytes_in_socket.cc =================================================================== --- trunk/complement/explore/test/sockios/bytes_in_socket.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/bytes_in_socket.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:35:39 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:32:22 ptr> /* * @@ -17,10 +17,8 @@ * in supporting documentation. */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -41,7 +39,6 @@ */ extern int port; -extern xmt::mutex pr_lock; static condition cnd; @@ -56,11 +53,9 @@ ConnectionProcessor4::ConnectionProcessor4( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); #if 0 /* @@ -74,11 +69,9 @@ char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); - BOOST_CHECK( c == '0' ); + EXAM_CHECK( c == '0' ); #endif } @@ -86,43 +79,35 @@ { static int count = 0; - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); if ( count++ == 0 ) { - BOOST_CHECK( c == '0' ); + EXAM_CHECK_ASYNC( c == '0' ); } else { cnd.set( true ); - BOOST_CHECK( c == '3' ); + EXAM_CHECK_ASYNC( c == '3' ); } - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor4::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } -void test_more_bytes_in_socket() +int EXAM_IMPL(test_more_bytes_in_socket) { // #ifndef __FIT_NO_POLL cnd.set( false ); @@ -140,4 +125,6 @@ // #else // BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); // #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/bytes_in_socket2.cc =================================================================== --- trunk/complement/explore/test/sockios/bytes_in_socket2.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/bytes_in_socket2.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -2,17 +2,15 @@ /* * - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -32,7 +30,6 @@ */ extern int port; -extern xmt::mutex pr_lock; static condition cnd; @@ -47,11 +44,9 @@ ConnectionProcessor7::ConnectionProcessor7( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // connect( s ); // cerr << "Server see connection\n"; // Be silent, avoid interference @@ -59,48 +54,38 @@ char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); - BOOST_CHECK( c == '0' ); + EXAM_CHECK_ASYNC( c == '0' ); } void ConnectionProcessor7::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); char c = '1'; s.read( &c, 1 ); - pr_lock.lock(); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); cnd.set( true ); - BOOST_CHECK( c == '3' ); + EXAM_CHECK_ASYNC( c == '3' ); - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor7::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } -void test_more_bytes_in_socket2() +int EXAM_IMPL(test_more_bytes_in_socket2) { // #ifndef __FIT_NO_POLL cnd.set( false ); @@ -118,4 +103,6 @@ // #else // BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); // #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-mw.cc =================================================================== --- trunk/complement/explore/test/sockios/client-mw.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-mw.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -17,7 +17,7 @@ * in supporting documentation. */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include <string> #include <sockios/sockstream> @@ -29,15 +29,13 @@ #include "message.h" using namespace std; -using namespace __impl; +using namespace xmt; -void ClientMassWrite::client_proc() +int EXAM_IMPL(ClientMassWrite::client_proc) { using namespace test_area; - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE( "Client start" ); for ( int i_close = 0; i_close < ni2; ++i_close ) { std::sockstream sock( "localhost", ::port ); @@ -45,11 +43,9 @@ sock.write( bin_buff1, bin_buff1_size ); } - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); + EXAM_CHECK( sock.good() ); } - pr_lock.lock(); - BOOST_MESSAGE( "Client end" ); - pr_lock.unlock(); + EXAM_MESSAGE( "Client end" ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-mw.h =================================================================== --- trunk/complement/explore/test/sockios/client-mw.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-mw.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -20,12 +20,14 @@ #ifndef __ClientMassWrite_h #define __ClientMassWrite_h +#include <exam/suite.h> + // Clients simulator class ClientMassWrite { public: - static void client_proc(); + static int EXAM_DECL(client_proc); }; #endif // __ClientMassWrite_h Modified: trunk/complement/explore/test/sockios/client-wc.cc =================================================================== --- trunk/complement/explore/test/sockios/client-wc.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-wc.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,14 +1,14 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:34:07 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:46:23 ptr> /* - * Copyright (c) 2004, 2006 + * Copyright (c) 2004, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/test_tools.hpp> +#include <exam/suite.h> #include <string> #include <sockios/sockstream> @@ -93,18 +93,14 @@ cnd.try_wait(); - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client start" ); std::sockstream sock( "localhost", ::port ); string buf; getline( sock, buf ); - pr_lock.lock(); - BOOST_CHECK( buf == "hello" ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( buf == "hello" ); // xmt::delay( xmt::timespec( 5, 0 ) ); @@ -120,20 +116,16 @@ char a; sock.read( &a, 1 ); - pr_lock.lock(); - BOOST_CHECK( !sock.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( !sock.good() ); srv_p->close(); - pr_lock.lock(); - BOOST_MESSAGE( "Client end" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client end" ); return rt; } -void srv_close_connection_test() +int EXAM_IMPL(srv_close_connection_test) { Thread srv( server_proc ); cnd_close.set( false ); @@ -141,4 +133,6 @@ client.join(); srv.join(); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/client-wc.h =================================================================== --- trunk/complement/explore/test/sockios/client-wc.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client-wc.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,25 +1,19 @@ -// -*- C++ -*- Time-stamp: <05/12/01 20:30:10 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 09:20:14 ptr> /* * - * Copyright (c) 2004 + * Copyright (c) 2004, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ #ifndef __client_wc_h #define __client_wc_h -void srv_close_connection_test(); +#include <exam/suite.h> +int EXAM_DECL(srv_close_connection_test); + #endif // __client_wc_h Deleted: trunk/complement/explore/test/sockios/client.cc =================================================================== --- trunk/complement/explore/test/sockios/client.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,251 +0,0 @@ -// -*- C++ -*- Time-stamp: <06/07/11 12:56:11 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2005, 2006 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#include <boost/test/test_tools.hpp> - -#include <string> -#include <sockios/sockstream> -#include <iostream> -#include <iomanip> -#include <list> -#include <mt/xmt.h> - -#include "client.h" -#include "message.h" - -using namespace std; -using namespace xmt; - -void Client::client1() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_nonlocal_ack() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - - // in_addr hostaddr( findhost( hostname().c_str() ) ); - sockaddr hostaddr; - - list<net_iface> ifaces; - try { - get_ifaces( ifaces ); - } - catch ( runtime_error& err ) { - BOOST_ERROR( err.what() ); - } - - list<net_iface>::const_iterator i; - for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { - if ( i->name == "eth0" ) { - hostaddr = i->addr.any; // .inet.sin_addr; - break; - } - } - BOOST_CHECK( i != ifaces.end() ); - - // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); - std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); - string srv_line; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_nonlocal_nac() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - // server listen only primary host's IP, not 127.0.0.1 - std::sockstream sock( /* "localhost" */ "127.0.0.1", ::port ); - - pr_lock.lock(); - BOOST_CHECK( !sock.is_open() ); - pr_lock.unlock(); -} - -void Client::client_local_ack() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - - std::sockstream sock( "127.0.0.1", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::udp_client1() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port, sock_base::sock_dgram ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - // sock.close(); // no needs, that will done in sock destructor -} - -void Client::client_dup() -{ - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); - std::sockstream sock( "localhost", ::port ); - string srv_line; - - sock << ::message << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - - { - std::sockstream sock2; - sock2.attach( sock.rdbuf()->fd() ); - - sock2 << ::message1 << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - BOOST_CHECK( sock2.good() ); - pr_lock.unlock(); - - srv_line.clear(); - getline( sock2, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - BOOST_CHECK( sock2.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp1 ); - - BOOST_MESSAGE( "Subclient close connection (subclient's end of life)" ); - pr_lock.unlock(); - } - - sock << ::message2 << endl; - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - pr_lock.unlock(); - - // sock.clear(); - srv_line.clear(); - getline( sock, srv_line ); - - pr_lock.lock(); - BOOST_CHECK( sock.good() ); - - BOOST_CHECK_EQUAL( srv_line, ::message_rsp2 ); - - BOOST_MESSAGE( "Client close connection (client's end of life)" ); - pr_lock.unlock(); - - // sock.close(); // no needs, that will done in sock destructor -} Deleted: trunk/complement/explore/test/sockios/client.h =================================================================== --- trunk/complement/explore/test/sockios/client.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/client.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,36 +0,0 @@ -// -*- C++ -*- Time-stamp: <05/12/20 09:52:15 ptr> - -/* - * - * Copyright (c) 2002, 2003, 2005 - * Petr Ovtchenkov - * - * Licensed under the Academic Free License Version 2.1 - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - */ - -#ifndef __Client_h -#define __Client_h - -// Clients simulator - -class Client -{ - public: - static void client1(); - static void client_nonlocal_ack(); - static void client_nonlocal_nac(); - static void client_local_ack(); - static void udp_client1(); - static void client_dup(); -}; - -#endif // __Client_h Modified: trunk/complement/explore/test/sockios/close_socket.cc =================================================================== --- trunk/complement/explore/test/sockios/close_socket.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/close_socket.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -17,10 +17,8 @@ * in supporting documentation. */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <iostream> #include <list> #include <mt/xmt.h> @@ -41,7 +39,6 @@ */ extern int port; -extern xmt::mutex pr_lock; class ConnectionProcessor3 // dummy variant { @@ -54,11 +51,9 @@ ConnectionProcessor3::ConnectionProcessor3( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server seen connection" ); + EXAM_MESSAGE_ASYNC( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); connect( s ); // cerr << "Server see connection\n"; // Be silent, avoid interference // with Input line prompt @@ -68,11 +63,9 @@ void ConnectionProcessor3::connect( std::sockstream& s ) { - pr_lock.lock(); - BOOST_MESSAGE( "Server start connection processing" ); + EXAM_MESSAGE_ASYNC( "Server start connection processing" ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + EXAM_CHECK_ASYNC( s.good() ); // string msg; @@ -81,26 +74,20 @@ s.write( &c, 1 ); s.flush(); // cnd2.set( true ); - pr_lock.lock(); - // BOOST_CHECK_EQUAL( msg, ::message ); - BOOST_REQUIRE( s.good() ); - pr_lock.unlock(); + // EXAM_CHECK_EQUAL( msg, ::message ); + EXAM_CHECK_ASYNC( s.good() ); // s << ::message_rsp << endl; // server's response - pr_lock.lock(); // BOOST_REQUIRE( s.good() ); - BOOST_MESSAGE( "Server stop connection processing" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server stop connection processing" ); return; } void ConnectionProcessor3::close() { - pr_lock.lock(); - BOOST_MESSAGE( "Server: client close connection" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Server: client close connection" ); } condition cnd1; @@ -114,22 +101,20 @@ cnd1.set( true ); - pr_lock.lock(); - BOOST_MESSAGE( "Client start" ); - pr_lock.unlock(); + EXAM_MESSAGE_ASYNC( "Client start" ); - BOOST_REQUIRE( psock->good() ); + EXAM_CHECK_ASYNC( psock->good() ); char c = '0'; psock->read( &c, 1 ); - BOOST_CHECK( c == '1' ); + EXAM_CHECK_ASYNC( c == '1' ); cnd2.set( true ); psock->read( &c, 1 ); return rt; } -void test_client_close_socket() +int EXAM_IMPL(test_client_close_socket) { #ifndef __FIT_NO_POLL sockmgr_stream_MP<ConnectionProcessor3> srv( port ); // start server @@ -156,6 +141,8 @@ srv.close(); // close server, so we don't wait server termination on next line srv.wait(); // Wait for server stop to serve clients connections #else - BOOST_ERROR( "select-based sockmgr not implemented on this platform" ); + EXAM_ERROR( "select-based sockmgr not implemented on this platform" ); #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/message.cc =================================================================== --- trunk/complement/explore/test/sockios/message.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/message.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -33,8 +33,6 @@ int port = 2048; -xmt::mutex pr_lock; - namespace test_area { int bin_buff1_size = 0; Modified: trunk/complement/explore/test/sockios/message.h =================================================================== --- trunk/complement/explore/test/sockios/message.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/message.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -37,10 +37,6 @@ extern int port; -extern xmt::mutex pr_lock; - -#define OUT_MSG(msg) pr_lock.lock(); cerr << msg << endl; pr_lock.unlock() - namespace test_area { extern int bin_buff1_size; Modified: trunk/complement/explore/test/sockios/names.cc =================================================================== --- trunk/complement/explore/test/sockios/names.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/names.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -11,7 +11,7 @@ #include "sockios_test.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> #include <sockios/sockstream> #include <sockios/sockmgr.h> @@ -20,69 +20,74 @@ #include <arpa/inet.h> -using namespace boost::unit_test_framework; using namespace std; /* ************************************************************ */ -void names_sockios_test::hostname_test() +int EXAM_IMPL(names_sockios_test::hostname_test) { unsigned long local = htonl( 0x7f000001 ); // 127.0.0.1 #ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( local, 0x0100007f ); + EXAM_CHECK( local == 0x0100007f ); #endif #ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( local, 0x7f000001 ); + EXAM_CHECK( local == 0x7f000001 ); #endif - BOOST_CHECK_EQUAL( std::hostname( local ), "localhost [127.0.0.1]" ); + EXAM_CHECK( std::hostname( local ) == "localhost [127.0.0.1]" ); #ifdef __unix char buff[1024]; gethostname( buff, 1024 ); - BOOST_CHECK_EQUAL( std::hostname(), buff ); + EXAM_CHECK( std::hostname() == buff ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::service_test() +int EXAM_IMPL(names_sockios_test::service_test) { #ifdef __unix - BOOST_CHECK( std::service( "ftp", "tcp" ) == 21 ); - BOOST_CHECK( std::service( 7, "udp" ) == "echo" ); + EXAM_CHECK( std::service( "ftp", "tcp" ) == 21 ); + EXAM_CHECK( std::service( 7, "udp" ) == "echo" ); #else BOOST_ERROR( "requests for service (/etc/services) not implemented on this platform" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test1() +int EXAM_IMPL(names_sockios_test::hostaddr_test1) { #ifdef __unix in_addr addr = std::findhost( "localhost" ); # ifdef _LITTLE_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x0100007f ); + EXAM_CHECK( addr.s_addr == 0x0100007f ); # endif # ifdef _BIG_ENDIAN - BOOST_CHECK_EQUAL( addr.s_addr, 0x7f000001 ); + EXAM_CHECK( addr.s_addr == 0x7f000001 ); # endif #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test2() +int EXAM_IMPL(names_sockios_test::hostaddr_test2) { #ifdef __unix list<in_addr> haddrs; @@ -97,16 +102,18 @@ } } - BOOST_CHECK( localhost_found == true ); + EXAM_CHECK( localhost_found == true ); #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } /* ************************************************************ */ -void names_sockios_test::hostaddr_test3() +int EXAM_IMPL(names_sockios_test::hostaddr_test3) { #ifdef __unix list<sockaddr> haddrs; @@ -132,9 +139,11 @@ } } - BOOST_CHECK( localhost_found == true ); + EXAM_CHECK( localhost_found == true ); #else - BOOST_ERROR( "Not implemented" ); + EXAM_ERROR( "Not implemented" ); #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/sockios/sockios_test.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:33:49 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 09:22:46 ptr> /* * @@ -12,7 +12,7 @@ #include "sockios_test.h" #include "message.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> #include <sockios/sockstream> #include <sockios/sockmgr.h> @@ -21,36 +21,23 @@ #include <sys/wait.h> #include <signal.h> -using namespace boost::unit_test_framework; using namespace std; -const char fname[] = "/tmp/sockios_test.shm"; -xmt::shm_alloc<0> seg; -xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; -xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; - -sockios_test::sockios_test() +sockios_test::sockios_test() : + fname( "/tmp/sockios_test.shm" ) { -} - -sockios_test::~sockios_test() -{ -} - -void sockios_test::init() -{ try { - seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + seg.allocate( fname.c_str(), 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); } catch ( const xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } } -void sockios_test::finit() +sockios_test::~sockios_test() { seg.deallocate(); - unlink( fname ); + unlink( fname.c_str() ); } /* ************************************************************ */ @@ -82,7 +69,7 @@ int Cnt::cnt = 0; int Cnt::visits = 0; -void sockios_test::ctor_dtor() +int EXAM_IMPL(sockios_test::ctor_dtor) { // Check, that number of ctors of Cnt is the same as number of called dtors // i.e. all created Cnt was released. @@ -92,18 +79,18 @@ { sockstream s1( "localhost", port ); - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); s1 << "1234" << endl; - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); while ( Cnt::get_visits() == 0 ) { xmt::Thread::yield(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 1 ); + EXAM_CHECK( Cnt::cnt == 1 ); Cnt::lock.unlock(); } @@ -111,13 +98,13 @@ srv.wait(); Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::visits = 0; Cnt::lock.unlock(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); { @@ -127,23 +114,23 @@ sockstream s1( "localhost", port ); sockstream s2( "localhost", port ); - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); - BOOST_CHECK( s2.good() ); - BOOST_CHECK( s2.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); + EXAM_CHECK( s2.good() ); + EXAM_CHECK( s2.is_open() ); s1 << "1234" << endl; s2 << "1234" << endl; - BOOST_CHECK( s1.good() ); - BOOST_CHECK( s1.is_open() ); - BOOST_CHECK( s2.good() ); - BOOST_CHECK( s2.is_open() ); + EXAM_CHECK( s1.good() ); + EXAM_CHECK( s1.is_open() ); + EXAM_CHECK( s2.good() ); + EXAM_CHECK( s2.is_open() ); while ( Cnt::get_visits() < 2 ) { xmt::Thread::yield(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 2 ); + EXAM_CHECK( Cnt::cnt == 2 ); Cnt::lock.unlock(); } @@ -151,13 +138,15 @@ srv.wait(); Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); } Cnt::lock.lock(); - BOOST_CHECK( Cnt::cnt == 0 ); + EXAM_CHECK( Cnt::cnt == 0 ); Cnt::lock.unlock(); + + return EXAM_RESULT; } /* ************************************************************ */ @@ -225,7 +214,7 @@ #endif } -void sockios_test::sigpipe() +int EXAM_IMPL(sockios_test::sigpipe) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -290,8 +279,10 @@ shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ */ @@ -331,7 +322,7 @@ xmt::__condition<true> *long_msg_processor::cnd; -void sockios_test::long_msg() +int EXAM_IMPL(sockios_test::long_msg) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -387,8 +378,10 @@ shm_cnd.deallocate( &srv_cnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ @@ -441,9 +434,9 @@ ConnectionProcessor5::ConnectionProcessor5( std::sockstream& s ) { // pr_lock.lock(); - // BOOST_MESSAGE( "Server seen connection" ); + // EXAM_MESSAGE( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); // pr_lock.unlock(); // cerr << "ConnectionProcessor5::ConnectionProcessor5\n"; @@ -462,7 +455,7 @@ void ConnectionProcessor5::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } @@ -478,15 +471,15 @@ cnd.set( true ); // Note: due to this is another process then main, boost can report // about errors here, but don't count error it in summary, if it occur! - BOOST_CHECK( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line - BOOST_CHECK( buff == 1 ); + EXAM_CHECK_ASYNC( sock.read( (char *)&buff, sizeof(int) ).good() ); // <---- key line + EXAM_CHECK_ASYNC( buff == 1 ); // cerr << "Read pass" << endl; rt.iword = 0; return rt; } -void sockios_test::read0() +int EXAM_IMPL(sockios_test::read0) { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); @@ -536,7 +529,7 @@ shm_cnd.deallocate( &fcnd, 1 ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } } @@ -558,9 +551,9 @@ ConnectionProcessor6::ConnectionProcessor6( std::sockstream& s ) { // pr_lock.lock(); - // BOOST_MESSAGE( "Server seen connection" ); + // EXAM_MESSAGE( "Server seen connection" ); - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); // pr_lock.unlock(); cnd.set( true ); @@ -573,16 +566,16 @@ void ConnectionProcessor6::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } -void sockios_test::read0_srv() +int EXAM_IMPL(sockios_test::read0_srv) { try { sockmgr_stream_MP<ConnectionProcessor6> srv( ::port ); - BOOST_CHECK( srv.good() ); + EXAM_CHECK( srv.good() ); ConnectionProcessor6::cnd.set( false ); { @@ -591,7 +584,7 @@ s << "1" << endl; - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); ConnectionProcessor6::cnd.try_wait(); } @@ -600,7 +593,7 @@ system( "echo > /dev/null" ); // <------ key line - BOOST_CHECK( srv.good() ); + EXAM_CHECK( srv.good() ); { // ... as after system call. @@ -608,19 +601,21 @@ s << "1" << endl; - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); ConnectionProcessor6::cnd.try_wait(); } - BOOST_CHECK( srv.good() ); // server must correctly process interrupt during system call + EXAM_CHECK( srv.good() ); // server must correctly process interrupt during system call srv.close(); srv.wait(); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ************************************************************ */ @@ -640,7 +635,7 @@ LongBlockReader::LongBlockReader( std::sockstream& s ) { - BOOST_REQUIRE( s.good() ); + EXAM_CHECK_ASYNC( s.good() ); } void LongBlockReader::connect( std::sockstream& s ) @@ -657,23 +652,23 @@ void LongBlockReader::close() { // pr_lock.lock(); - // BOOST_MESSAGE( "Server: client close connection" ); + // EXAM_MESSAGE( "Server: client close connection" ); // pr_lock.unlock(); } -void sockios_test::long_block_read() +int EXAM_IMPL(sockios_test::long_block_read) { LongBlockReader::cnd.set( false ); sockmgr_stream_MP<LongBlockReader> srv( ::port ); - BOOST_REQUIRE( srv.good() ); + EXAM_REQUIRE( srv.good() ); sockstream s; s.open( "localhost", ::port ); - BOOST_REQUIRE( s.good() ); + EXAM_REQUIRE( s.good() ); char buf[1024]; @@ -682,7 +677,7 @@ } s.flush(); - BOOST_CHECK( s.good() ); + EXAM_CHECK( s.good() ); s.close(); LongBlockReader::cnd.try_wait(); Modified: trunk/complement/explore/test/sockios/sockios_test.h =================================================================== --- trunk/complement/explore/test/sockios/sockios_test.h 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test.h 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/02/26 15:09:26 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 08:52:26 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006, 2007 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -12,34 +12,41 @@ #ifndef __sockios_test_h #define __sockios_test_h +#include <exam/suite.h> +#include <mt/shm.h> + struct names_sockios_test { - void hostname_test(); - void service_test(); + int EXAM_DECL(hostname_test); + int EXAM_DECL(service_test); - void hostaddr_test1(); - void hostaddr_test2(); - void hostaddr_test3(); + int EXAM_DECL(hostaddr_test1); + int EXAM_DECL(hostaddr_test2); + int EXAM_DECL(hostaddr_test3); }; -struct sockios_test +class sockios_test { + public: sockios_test(); ~sockios_test(); - void init(); - void finit(); + int EXAM_DECL(ctor_dtor); - void ctor_dtor(); + int EXAM_DECL(long_msg); - void long_msg(); + int EXAM_DECL(sigpipe); + int EXAM_DECL(read0); + int EXAM_DECL(read0_srv); + int EXAM_DECL(long_block_read); - void sigpipe(); - void read0(); - void read0_srv(); - void long_block_read(); + int EXAM_DECL(srv2_fork); - void srv2_fork(); + private: + const std::string fname; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; }; #endif // __sockios_test_h Modified: trunk/complement/explore/test/sockios/sockios_test_suite.cc =================================================================== --- trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-17 12:05:15 UTC (rev 1619) +++ trunk/complement/explore/test/sockios/sockios_test_suite.cc 2007-07-18 06:29:40 UTC (rev 1620) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/02/26 15:33:23 ptr> +// -*- C++ -*- Time-stamp: <07/07/18 10:23:40 ptr> /* * - * Copyright (c) 2002, 2003, 2005, 2006, 2007 + * Copyright (c) 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -12,58 +12,386 @@ #include "sockios_test_suite.h" #include "sockios_test.h" -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; +#include <iostream> +#include <list> +#include <mt/xmt.h> +#include <sockios/sockstream> +#include <sockios/sockmgr.h> -sockios_test_suite::sockios_test_suite() : - test_suite( "sockios library test suite" ) +#include "message.h" + +#include "ConnectionProcessor.h" + +#include "client-wc.h" + +using namespace std; + +int EXAM_IMPL(test_client_server_poll_nonlocal_ack) { - boost::shared_ptr<names_sockios_test> names_instance( new names_sockios_test() ); +#ifndef __FIT_NO_POLL + try { - test_case *hostname_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostname_test, names_instance ); - test_case *service_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::service_test, names_instance ); + // Oh, this trick not work well: hostname may be assigned to 127.0.0.1 too... + // I need list of interfaces... - test_case *hostaddr1_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test1, names_instance ); - test_case *hostaddr2_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test2, names_instance ); - test_case *hostaddr3_tc = BOOST_CLASS_TEST_CASE( &names_sockios_test::hostaddr_test3, names_instance ); + // take primary host IP: + in_addr hostaddr( findhost( hostname().c_str() ) ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); - add( hostname_tc ); - add( service_tc ); + // server not listen localhost, but listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server - add( hostaddr1_tc ); - add( hostaddr2_tc ); - add( hostaddr3_tc ); + EXAM_CHECK( srv.is_open() ); + EXAM_CHECK( srv.good() ); + { + EXAM_MESSAGE( "Client start" ); - boost::shared_ptr<sockios_test> instance( new sockios_test() ); - test_case *init_tc = BOOST_CLASS_TEST_CASE( &sockios_test::init, instance ); - test_case *finit_tc = BOOST_CLASS_TEST_CASE( &sockios_test::finit, instance ); + // in_addr hostaddr( findhost( hostname().c_str() ) ); + sockaddr hostaddr; - test_case *ctor_dtor_tc = BOOST_CLASS_TEST_CASE( &sockios_test::ctor_dtor, instance ); - test_case *long_msg_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_msg, instance ); - test_case *sigpipe_tc = BOOST_CLASS_TEST_CASE( &sockios_test::sigpipe, instance ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); - test_case *read0_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0, instance ); - test_case *read0_srv_tc = BOOST_CLASS_TEST_CASE( &sockios_test::read0_srv, instance ); - test_case *long_block_read_tc = BOOST_CLASS_TEST_CASE( &sockios_test::long_block_read, instance ); + // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); + std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); + string srv_line; - long_msg_tc->depends_on( init_tc ); - long_msg_tc->depends_on( ctor_dtor_tc ); - sigpipe_tc->depends_on( ctor_dtor_tc ); - sigpipe_tc->depends_on( init_tc ); - read0_tc->depends_on( sigpipe_tc ); - read0_srv_tc->depends_on( sigpipe_tc ); - long_block_read_tc->depends_on( init_tc ); - finit_tc->depends_on( init_tc ); + EXAM_CHECK( sock.good() ); - add( init_tc ); - add( ctor_dtor_tc ); - add( long_msg_tc ); - add( sigpipe_tc ); - add( read0_tc, 0, 5 ); - add( read0_srv_tc ); - add( long_block_read_tc ); - add( finit_tc ); + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; } + +int EXAM_IMPL(test_client_server_poll_nonlocal_nac) +{ +#ifndef __FIT_NO_POLL + try { + // take primary host IP: + in_addr hostaddr( findhost( hostname().c_str() ) ); + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); + + // server not listen localhost, but listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( hostaddr, port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + + // in_addr hostaddr( findhost( hostname().c_str() ) ); + sockaddr hostaddr; + + list<net_iface> ifaces; + try { + get_ifaces( ifaces ); + } + catch ( runtime_error& err ) { + EXAM_ERROR( err.what() ); + } + + list<net_iface>::const_iterator i; + for ( i = ifaces.begin(); i != ifaces.end(); ++i ) { + if ( i->name == "eth0" ) { + hostaddr = i->addr.any; // .inet.sin_addr; + break; + } + } + EXAM_CHECK( i != ifaces.end() ); + + // std::sockstream sock( hostname(hostaddr.s_addr).c_str(), ::port ); + std::sockstream sock( (*(sockaddr_in *)&hostaddr).sin_addr, ::port ); + string srv_line; + + EXAM_CHECK( sock.good() ); + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int EXAM_IMPL(test_client_server_poll_local_ack) +{ +#ifndef __FIT_NO_POLL + try { + // server listen localhost (127.0.0.1), but not listen ext interface: + sockmgr_stream_MP<ConnectionProcessor> srv( 0x7f000001, port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + + std::sockstream sock( "127.0.0.1", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + // sock.close(); // no needs, that will done in sock destructor + } + + srv.close(); // close server, so we don't wait server termination on next line + srv.wait(); // Wait for server stop to serve clients connections + } + catch ( std::domain_error& err ) { + EXAM_ERROR( "host not found by name" ); + } +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int generator_1() +{ + static int i = 0; + + return i++; +} + +#include "client-mw.h" + +int EXAM_IMPL(test_mass_processing_poll) +{ +#ifndef __FIT_NO_POLL + using namespace test_area; + + EXAM_REQUIRE( bin_buff1_size == 0 ); // test integrity of test suite + EXAM_REQUIRE( bin_buff1 == 0 ); // test integrity of test suite + + bin_buff1_size = 48; + bin_buff1 = new char [bin_buff1_size]; + EXAM_REQUIRE( bin_buff1 != 0 ); + generate_n( bin_buff1, bin_buff1_size, generator_1 ); + + ni1 = 10; + ni2 = 5; + + delete bin_buff1; + bin_buff1 = 0; + bin_buff1_size = 0; +#else + EXAM_ERROR( "poll-based sockmgr not implemented on this platform" ); +#endif + + return EXAM_RESULT; +} + +int EXAM_IMPL(test_shared_socket) +{ +#ifndef __FIT_NO_POLL + sockmgr_stream_MP<ConnectionProcessor2> srv( port ); // start server + + { + EXAM_MESSAGE( "Client start" ); + std::sockstream sock( "localhost", ::port ); + string srv_line; + + sock << ::message << endl; + + EXAM_CHECK( sock.good() ); + + // sock.clear(); + getline( sock, srv_line ); + + EXAM_CHECK( sock.good() ); + + EXAM_CHECK( srv_line == ::message_rsp ); + + EXAM_MESSAGE( "Client close connection (client's end of life)" ); + + { + std::sockstream sock2; + sock2.attach( sock.rdbuf()->fd() ); + + sock2 << ::message1 << endl; + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + srv_line.clear(); + getline( sock2, srv_line ); + + EXAM_CHECK( sock.good() ); + EXAM_CHECK( sock2.good() ); + + EXAM_CHECK( srv_line == ::message_rsp1 ); + + EXAM_MESSAGE( "Subclient close connection (subclient's end of life)" ); + } + + ... [truncated message content] |
From: <com...@us...> - 2007-07-17 12:05:18
|
Revision: 1619 http://svn.sourceforge.net/complement/?rev=1619&view=rev Author: complement Date: 2007-07-17 05:05:15 -0700 (Tue, 17 Jul 2007) Log Message: ----------- fix tests dependecies, add missed returns, refine tests structure Modified Paths: -------------- trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-07-17 06:33:12 UTC (rev 1618) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-07-17 12:05:15 UTC (rev 1619) @@ -39,7 +39,7 @@ } /* ****************************************************** - * Start thread, join it. + * Start thread, join it. Check return value. */ static int x = 0; @@ -49,7 +49,7 @@ x = 1; xmt::Thread::ret_code rt; - rt.iword = 0; + rt.iword = 2; return rt; } @@ -60,7 +60,7 @@ xmt::Thread t( thread_entry_call ); - t.join(); + EXAM_CHECK( t.join().iword == 2 ); EXAM_CHECK( x == 1 ); @@ -74,7 +74,7 @@ xmt::Thread::ret_code thread2_entry_call( void *p ) { xmt::Thread::ret_code rt; - rt.iword = 0; + rt.iword = 1; xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); @@ -89,8 +89,9 @@ xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread2_entry_call, &b ); - t2.join(); - t1.join(); + EXAM_CHECK( (t2.join().iword + t1.join().iword) == 2 ); + + return EXAM_RESULT; } /* ****************************************************** @@ -112,11 +113,15 @@ int EXAM_IMPL(mt_test::yield) { - xmt::barrier b; + { + xmt::barrier b; - xmt::Thread t1( thread2_entry_call, &b ); - xmt::Thread t2( thread3_entry_call, &b ); - // .join()'s are in Thread's destructors + xmt::Thread t1( thread2_entry_call, &b ); + xmt::Thread t2( thread3_entry_call, &b ); + // .join()'s are in Thread's destructors + } + + return EXAM_RESULT; } /* ****************************************************** @@ -455,7 +460,7 @@ try { // Child code - EXAM_CHECK( my_pid == xmt::getppid() ); + EXAM_CHECK_ASYNC( my_pid == xmt::getppid() ); *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) = xmt::getpid(); fcnd.set( true ); @@ -493,7 +498,7 @@ /* ****************************************************** */ -int EXAM_IMPL(mt_test::shm_segment) +int EXAM_IMPL(shm_test::shm_segment) { const char fname[] = "/tmp/mt_test.shm"; try { @@ -565,7 +570,7 @@ /* ****************************************************** */ -int EXAM_IMPL(mt_test::shm_alloc) +int EXAM_IMPL(shm_test::shm_alloc) { const char fname[] = "/tmp/mt_test.shm"; try { @@ -645,7 +650,7 @@ * This test is similar mt_test::fork() above, but instead plain shm_* * functions it use allocator based on shared memory segment */ -int EXAM_IMPL(mt_test::fork_shm) +int EXAM_IMPL(shm_test::fork_shm) { const char fname[] = "/tmp/mt_test.shm"; try { @@ -693,12 +698,14 @@ catch ( xmt::shm_bad_alloc& err ) { EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ****************************************************** * Test: how to take named object in shared memory segment */ -int EXAM_IMPL(mt_test::shm_named_obj) +int EXAM_IMPL(shm_test::shm_named_obj) { const char fname[] = "/tmp/mt_test.shm"; enum { @@ -737,13 +744,13 @@ fcnd_ch.set( true ); } catch ( const xmt::shm_bad_alloc& err ) { - EXAM_ERROR( err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR( err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } catch ( ... ) { - EXAM_ERROR( "Fail in child" ); + EXAM_ERROR_ASYNC( "Fail in child" ); } exit( 0 ); @@ -779,29 +786,30 @@ /* ****************************************************** */ -static const char fname1[] = "/tmp/mt_test.shm.1"; -xmt::shm_alloc<1> seg1; +const char shm_test::fname1[] = "/tmp/mt_test.shm.1"; -int EXAM_IMPL(mt_test::shm_init) +shm_test::shm_test() { - seg1.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); - return EXAM_RESULT; + try { + seg1.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); + } + catch ( xmt::shm_bad_alloc& err ) { + EXAM_ERROR_ASYNC( err.what() ); + } } /* ****************************************************** */ -int EXAM_IMPL(mt_test::shm_finit) +shm_test::~shm_test() { seg1.deallocate(); fs::remove( fname1 ); - - return EXAM_RESULT; } /* ****************************************************** */ -int EXAM_IMPL(mt_test::shm_named_obj_more) +int EXAM_IMPL(shm_test::shm_named_obj_more) { enum { ObjName = 1 @@ -827,7 +835,7 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR( err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } exit( 0 ); } @@ -853,7 +861,7 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR( err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } exit( 0 ); @@ -881,7 +889,7 @@ nm_ch.release<xmt::__barrier<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - EXAM_ERROR( err.what() ); + EXAM_ERROR_ASYNC( err.what() ); } exit( 0 ); Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-07-17 06:33:12 UTC (rev 1618) +++ trunk/complement/explore/test/mt/mt_test.h 2007-07-17 12:05:15 UTC (rev 1619) @@ -14,6 +14,7 @@ #define FIT_EXAM #include <exam/suite.h> +#include <mt/shm.h> class mt_test { @@ -28,20 +29,29 @@ int EXAM_DECL(fork); int EXAM_DECL(pid); + int EXAM_DECL(thr_mgr); + + private: + // static xmt::Thread::ret_code thread_entry_call( void * ); + // static int x; +}; + +class shm_test +{ + public: + shm_test(); + ~shm_test(); + int EXAM_DECL(shm_segment); int EXAM_DECL(shm_alloc); int EXAM_DECL(fork_shm); int EXAM_DECL(shm_named_obj); - int EXAM_DECL(thr_mgr); - int EXAM_DECL(shm_init); - int EXAM_DECL(shm_finit); - int EXAM_DECL(shm_named_obj_more); private: - // static xmt::Thread::ret_code thread_entry_call( void * ); - // static int x; + xmt::shm_alloc<1> seg1; + static const char fname1[]; }; #endif // __MT_TEST_H Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-07-17 06:33:12 UTC (rev 1618) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-07-17 12:05:15 UTC (rev 1619) @@ -35,32 +35,33 @@ // t.add( signal_2_test, "signal_2_test" ); t.add( signal_3_test, "signal_3_test" ); - exam::test_suite::test_case_type tc[5]; + exam::test_suite::test_case_type tc[3]; tc[0] = t.add( &mt_test::barrier, test, "mt_test::barrier" ); tc[1] = t.add( &mt_test::join_test, test, "mt_test::join_test" ); tc[2] = t.add( &mt_test::yield, test, "mt_test::yield", t.add( &mt_test::barrier2, test, "mt_test::barrier2", - tc, tc+2 ) ); - tc[3] = t.add( &mt_test::mutex_test, test, "mt_test::mutex_test", tc[2] ); + tc, tc + 2 ) ); + t.add( &mt_test::recursive_mutex_test, test, "mt_test::recursive_mutex_test", + t.add( &mt_test::mutex_test, test, "mt_test::mutex_test", tc[2] ) ); #ifdef __FIT_PTHREAD_SPINLOCK t.add( &mt_test::spinlock_test, test, "mt_test::spinlock_test", tc[2] ); #endif - t.add( &mt_test::recursive_mutex_test, test, "mt_test::recursive_mutex_test", tc[3] ); t.add( &mt_test::pid, test, "mt_test::pid", t.add( &mt_test::fork, test, "mt_test::fork" ) ); - tc[4] = t.add( &mt_test::shm_alloc, test, "mt_test::shm_alloc", - t.add( &mt_test::shm_segment, test, "mt_test::shm_segment" ) ); - t.add( &mt_test::shm_named_obj, test, "mt_test::shm_named_obj", - t.add( &mt_test::fork_shm, test, "mt_test::fork_shm", tc[4] ) ); - t.add( &mt_test::shm_named_obj_more, test, "mt_test::shm_named_obj_more" ); - t.add( &mt_test::thr_mgr, test, "mt_test::thr_mgr" ); + t.add( &mt_test::thr_mgr, test, "mt_test::thr_mgr", tc[1] ); - t.add( &mt_test::shm_finit, test, "mt_test::shm_finit", - t.add( &mt_test::shm_init, test, "mt_test::shm_init", tc[4] ) ); + shm_test shmtest; + t.add( &shm_test::shm_named_obj_more, shmtest, "mt_test::shm_named_obj_more", + t.add( &shm_test::shm_named_obj, shmtest, "mt_test::shm_named_obj", + t.add( &shm_test::fork_shm, shmtest, "mt_test::fork_shm", + t.add( &shm_test::shm_alloc, shmtest, "mt_test::shm_alloc", + t.add( &shm_test::shm_segment, shmtest, "mt_test::shm_segment" ) ) ) ) + ); + // add( barrier_tc, 0, 2 ); // add( join_tc ); // add( barrier2_tc, 0, 3 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-17 06:33:19
|
Revision: 1618 http://svn.sourceforge.net/complement/?rev=1618&view=rev Author: complement Date: 2007-07-16 23:33:12 -0700 (Mon, 16 Jul 2007) Log Message: ----------- boost unit test framework was replaced by exam Modified Paths: -------------- trunk/complement/explore/test/mt/Makefile trunk/complement/explore/test/mt/Makefile.inc trunk/complement/explore/test/mt/flck.cc trunk/complement/explore/test/mt/lfs.cc trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/mt_test.h trunk/complement/explore/test/mt/mt_test_suite.cc trunk/complement/explore/test/mt/mt_test_suite.h trunk/complement/explore/test/mt/signal-1.cc trunk/complement/explore/test/mt/signal-2.cc trunk/complement/explore/test/mt/signal-3.cc trunk/complement/explore/test/mt/timespec.cc trunk/complement/explore/test/mt/unit_test.cc Modified: trunk/complement/explore/test/mt/Makefile =================================================================== --- trunk/complement/explore/test/mt/Makefile 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/Makefile 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,4 +1,4 @@ -# -*- Makefile -*- Time-stamp: <06/08/04 10:54:19 ptr> +# -*- Makefile -*- Time-stamp: <07/07/17 10:01:41 ptr> SRCROOT := ../.. COMPILER_NAME := gcc @@ -18,13 +18,14 @@ # endif LIBMT_DIR = ${CoMT_DIR}/lib/mt -LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +# LIBUTF_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/test/unit_test_framework +LIBEXAM_DIR = ${CoMT_DIR}/lib/exam LIBFS_DIR = ${CoMT_DIR}/../extern/custom/boost/libs/filesystem ifeq ($(OSNAME),linux) -release-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR} -L${LIBUTF_DIR}/${OUTPUT_DIR} -L${LIBFS_DIR}/${OUTPUT_DIR} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR}:${LIBUTF_DIR}/${OUTPUT_DIR}:${LIBFS_DIR}/${OUTPUT_DIR}:${STLPORT_LIB_DIR} -stldbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG} -L${LIBFS_DIR}/${OUTPUT_DIR_STLDBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_STLDBG}:${LIBUTF_DIR}/${OUTPUT_DIR_STLDBG}:${LIBFS_DIR}/${OUTPUT_DIR_STLDBG}:${STLPORT_LIB_DIR} -dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -L${LIBUTF_DIR}/${OUTPUT_DIR_DBG} -L${LIBFS_DIR}/${OUTPUT_DIR_DBG} -Wl,--rpath=${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${LIBUTF_DIR}/${OUTPUT_DIR_DBG}:${LIBFS_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} +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} +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 ifeq ($(OSNAME),openbsd) @@ -33,9 +34,9 @@ dbg-shared: LDSEARCH += -L${LIBMT_DIR}/${OUTPUT_DIR_DBG} -Wl,-R${LIBMT_DIR}/${OUTPUT_DIR_DBG}:${STLPORT_LIB_DIR} endif -release-shared : LDLIBS = -lxmt -lboost_test_utf -lboost_fs -stldbg-shared : LDLIBS = -lxmtstlg -lboost_test_utfstlg -lboost_fsstlg -dbg-shared : LDLIBS = -lxmtg -lboost_test_utfg -lboost_fsg +release-shared : LDLIBS = -lxmt -lexam -lboost_fs +stldbg-shared : LDLIBS = -lxmtstlg -lexamstlg -lboost_fsstlg +dbg-shared : LDLIBS = -lxmtg -lexamg -lboost_fsg ifeq ($(OSNAME),freebsd) release-shared : LDLIBS += -lthr Modified: trunk/complement/explore/test/mt/Makefile.inc =================================================================== --- trunk/complement/explore/test/mt/Makefile.inc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/Makefile.inc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,6 +1,6 @@ -# -*- makefile -*- Time-stamp: <07/02/06 10:04:25 ptr> +# -*- makefile -*- Time-stamp: <07/07/16 22:12:31 ptr> PRGNAME = mt_ut SRC_CC = unit_test.cc timespec.cc \ - signal-1.cc signal-2.cc signal-3.cc flck.cc lfs.cc \ + signal-1.cc signal-3.cc \ mt_test.cc mt_test_suite.cc Modified: trunk/complement/explore/test/mt/flck.cc =================================================================== --- trunk/complement/explore/test/mt/flck.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/flck.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <06/12/15 10:43:07 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 21:34:09 ptr> /* - * Copyright (c) 2004, 2006 + * Copyright (c) 2004, 2006, 2007 * Petr Ovtchenkov * * Copyright (c) 2004 @@ -11,7 +11,8 @@ * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> + #include "mt/flck.h" #include <mt/xmt.h> @@ -21,8 +22,6 @@ #include <iostream> -using namespace boost::unit_test_framework; - using namespace xmt; using namespace std; @@ -207,7 +206,7 @@ return rt; } -void flock_test() +int EXAM_IMPL(flock_test) { unlink( fname ); Thread t1( thread_func ); @@ -220,4 +219,6 @@ t3.join(); t4.join(); unlink( fname ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/lfs.cc =================================================================== --- trunk/complement/explore/test/mt/lfs.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/lfs.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:22:41 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 21:33:58 ptr> /* - * Copyright (c) 2004, 2006 + * Copyright (c) 2004, 2006, 2007 * Petr Ovtchenkov * * Copyright (c) 2004 @@ -11,7 +11,8 @@ * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> + #include "mt/lfstream.h" #include <mt/xmt.h> @@ -21,8 +22,6 @@ #include <iostream> -using namespace boost::unit_test_framework; - using namespace xmt; using namespace std; @@ -236,7 +235,7 @@ return rt; } -void lfs_test() +int EXAM_IMPL(lfs_test) { unlink( fname ); cnd.set( false ); @@ -268,4 +267,6 @@ unlink( fname ); #endif + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/mt_test.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/mt_test.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 22:08:56 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 09:58:22 ptr> /* * Copyright (c) 2006, 2007 @@ -8,8 +8,6 @@ * */ -#include <boost/test/unit_test.hpp> - #include "mt_test.h" #include <mt/xmt.h> @@ -27,15 +25,13 @@ #include <iostream> using namespace std; - -using namespace boost::unit_test_framework; namespace fs = boost::filesystem; /* ****************************************************** * Degenerate case: check that one thread pass throw * own barrier. */ -void mt_test::barrier() +int EXAM_IMPL(mt_test::barrier) { xmt::barrier b( 1 ); @@ -58,15 +54,17 @@ return rt; } -void mt_test::join_test() +int EXAM_IMPL(mt_test::join_test) { - BOOST_CHECK( x == 0 ); + EXAM_CHECK( x == 0 ); xmt::Thread t( thread_entry_call ); t.join(); - BOOST_CHECK( x == 1 ); + EXAM_CHECK( x == 1 ); + + return EXAM_RESULT; } /* ****************************************************** @@ -84,7 +82,7 @@ return rt; } -void mt_test::barrier2() +int EXAM_IMPL(mt_test::barrier2) { xmt::barrier b; @@ -107,12 +105,12 @@ xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); - BOOST_CHECK( xmt::Thread::yield() == 0 ); + EXAM_CHECK_ASYNC( xmt::Thread::yield() == 0 ); return rt; } -void mt_test::yield() +int EXAM_IMPL(mt_test::yield) { xmt::barrier b; @@ -139,11 +137,11 @@ b.wait(); m1.lock(); - BOOST_CHECK( x == 0 ); + EXAM_CHECK_ASYNC( x == 0 ); xmt::Thread::yield(); - BOOST_CHECK( x == 0 ); + EXAM_CHECK_ASYNC( x == 0 ); x = 1; m1.unlock(); @@ -163,7 +161,7 @@ } m1.lock(); - BOOST_CHECK( x == 1 ); + EXAM_CHECK_ASYNC( x == 1 ); x = 2; m1.unlock(); @@ -173,7 +171,7 @@ return rt; } -void mt_test::mutex_test() +int EXAM_IMPL(mt_test::mutex_test) { x = 0; xmt::barrier b; @@ -184,7 +182,9 @@ t1.join(); t2.join(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK( x == 2 ); + + return EXAM_RESULT; } /* ****************************************************** @@ -206,11 +206,11 @@ b.wait(); sl1.lock(); - BOOST_CHECK( x == 0 ); + EXAM_CHECK_ASYNC( x == 0 ); xmt::Thread::yield(); - BOOST_CHECK( x == 0 ); + EXAM_CHECK_ASYNC( x == 0 ); x = 1; sl1.unlock(); @@ -230,7 +230,7 @@ } sl1.lock(); - BOOST_CHECK( x == 1 ); + EXAM_CHECK_ASYNC( x == 1 ); x = 2; sl1.unlock(); @@ -242,7 +242,7 @@ #endif -void mt_test::spinlock_test() +int EXAM_IMPL(mt_test::spinlock_test) { #ifdef __FIT_PTHREAD_SPINLOCK x = 0; @@ -254,8 +254,9 @@ t1.join(); t2.join(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK( x == 2 ); #endif + return EXAM_RESULT; } /* ****************************************************** */ @@ -295,7 +296,7 @@ x = 2; xmt::Thread::yield(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK_ASYNC( x == 2 ); m2.unlock(); } @@ -307,12 +308,12 @@ m2.lock(); - BOOST_CHECK( x == 0 ); + EXAM_CHECK_ASYNC( x == 0 ); x = 1; xmt::Thread::yield(); - BOOST_CHECK( x == 1 ); + EXAM_CHECK_ASYNC( x == 1 ); recursive(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK_ASYNC( x == 2 ); x = 3; m2.unlock(); @@ -335,10 +336,10 @@ m2.lock(); - BOOST_CHECK( x == 3 ); + EXAM_CHECK_ASYNC( x == 3 ); xmt::Thread::yield(); recursive(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK_ASYNC( x == 2 ); m2.unlock(); @@ -349,7 +350,7 @@ return rt; } -void mt_test::recursive_mutex_test() +int EXAM_IMPL(mt_test::recursive_mutex_test) { x = 0; xmt::barrier b; @@ -360,25 +361,27 @@ t1.join(); t2.join(); - BOOST_CHECK( x == 2 ); + EXAM_CHECK( x == 2 ); + + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::fork() +int EXAM_IMPL(mt_test::fork) { shmid_ds ds; int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); - BOOST_REQUIRE( id != -1 ); + EXAM_REQUIRE( id != -1 ); // if ( id == -1 ) { // cerr << "Error on shmget" << endl; // } - BOOST_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); + EXAM_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); // if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { // cerr << "Error on shmctl" << endl; // } void *buf = shmat( id, 0, 0 ); - BOOST_REQUIRE( buf != reinterpret_cast<void *>(-1) ); + EXAM_REQUIRE( buf != reinterpret_cast<void *>(-1) ); // if ( buf == reinterpret_cast<void *>(-1) ) { // cerr << "Error on shmat" << endl; // } @@ -401,12 +404,12 @@ } catch ( xmt::fork_in_parent& child ) { try { - BOOST_CHECK( child.pid() > 0 ); + EXAM_CHECK( child.pid() > 0 ); fcnd.set( true ); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } catch ( ... ) { } @@ -418,24 +421,26 @@ shmdt( buf ); shmctl( id, IPC_RMID, &ds ); + + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::pid() +int EXAM_IMPL(mt_test::pid) { shmid_ds ds; int id = shmget( 5000, 1024, IPC_CREAT | IPC_EXCL | 0600 ); - BOOST_REQUIRE( id != -1 ); + EXAM_REQUIRE( id != -1 ); // if ( id == -1 ) { // cerr << "Error on shmget" << endl; // } - BOOST_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); + EXAM_REQUIRE( shmctl( id, IPC_STAT, &ds ) != -1 ); // if ( shmctl( id, IPC_STAT, &ds ) == -1 ) { // cerr << "Error on shmctl" << endl; // } void *buf = shmat( id, 0, 0 ); - BOOST_REQUIRE( buf != reinterpret_cast<void *>(-1) ); + EXAM_REQUIRE( buf != reinterpret_cast<void *>(-1) ); // if ( buf == reinterpret_cast<void *>(-1) ) { // cerr << "Error on shmat" << endl; // } @@ -450,7 +455,7 @@ try { // Child code - BOOST_CHECK( my_pid == xmt::getppid() ); + EXAM_CHECK( my_pid == xmt::getppid() ); *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) = xmt::getpid(); fcnd.set( true ); @@ -463,14 +468,14 @@ } catch ( xmt::fork_in_parent& child ) { try { - BOOST_CHECK( child.pid() > 0 ); + EXAM_CHECK( child.pid() > 0 ); fcnd.try_wait(); - BOOST_CHECK( *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) == child.pid() ); + EXAM_CHECK( *reinterpret_cast<pid_t *>(static_cast<char *>(buf) + sizeof(xmt::__condition<true>)) == child.pid() ); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } catch ( ... ) { } @@ -482,38 +487,40 @@ shmdt( buf ); shmctl( id, IPC_RMID, &ds ); + + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::shm_segment() +int EXAM_IMPL(mt_test::shm_segment) { const char fname[] = "/tmp/mt_test.shm"; try { xmt::detail::__shm_alloc<0> seg( 5000, 1024, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); - BOOST_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); + EXAM_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); seg.deallocate(); - BOOST_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); + EXAM_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); - BOOST_REQUIRE( !fs::exists( fname ) ); + EXAM_REQUIRE( !fs::exists( fname ) ); seg.allocate( fname, 1024, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); - BOOST_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); + EXAM_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); seg.deallocate(); - BOOST_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); - BOOST_CHECK( fs::exists( fname ) ); // well, now I don't remove ref file, because shm segment may be created with another way + EXAM_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); + EXAM_CHECK( fs::exists( fname ) ); // well, now I don't remove ref file, because shm segment may be created with another way // not exclusive, should pass seg.allocate( fname, 1024, xmt::shm_base::create, 0660 ); - BOOST_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); + EXAM_CHECK( seg.address() != reinterpret_cast<void *>(-1) ); try { // This instance has segment in usage, should throw seg.allocate( fname, 1024, 0, 0660 ); - BOOST_CHECK( false ); + EXAM_CHECK( false ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK( true ); // Ok + EXAM_CHECK( true ); // Ok } /* @@ -533,30 +540,32 @@ */ seg.deallocate(); - BOOST_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); + EXAM_CHECK( seg.address() == reinterpret_cast<void *>(-1) ); // ---- try { // exclusive, should throw seg.allocate( fname, 1024, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); - BOOST_CHECK( false ); // Fail, should throw + EXAM_CHECK( false ); // Fail, should throw } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK( true ); // Ok + EXAM_CHECK( true ); // Ok } - BOOST_CHECK( fs::exists( fname ) ); + EXAM_CHECK( fs::exists( fname ) ); // ---- fs::remove( fname ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::shm_alloc() +int EXAM_IMPL(mt_test::shm_alloc) { const char fname[] = "/tmp/mt_test.shm"; try { @@ -569,64 +578,66 @@ size_t sz = shmall.max_size(); // two blocks char *ch1 = shmall.allocate( 3500 ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); char *ch2 = shmall.allocate( 3500 ); - BOOST_CHECK( ch2 != 0 ); + EXAM_CHECK( ch2 != 0 ); try { // try to allocate third block, not enough room char *ch3 = shmall.allocate( 8 * 1024 - 7000 ); - BOOST_CHECK( false ); + EXAM_CHECK( false ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK( true ); + EXAM_CHECK( true ); } // free first blocks shmall.deallocate( ch1, 3500 ); ch1 = shmall.allocate( 3500 ); // allocate [first] block again - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); // free second block shmall.deallocate( ch2, 3500 ); // allocate [second] block again ch2 = shmall.allocate( 3500 ); - BOOST_CHECK( ch2 != 0 ); + EXAM_CHECK( ch2 != 0 ); // free both blocks shmall.deallocate( ch1, 3500 ); shmall.deallocate( ch2, 3500 ); // allocate big block, enough for initial memory chunk ch1 = shmall.allocate( 7000 ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); // free it shmall.deallocate( ch1, 7000 ); // allocate block of maximum size ch1 = shmall.allocate( sz ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); // free it shmall.deallocate( ch1, sz ); // allocate block, enough for initial memory chunk ch1 = shmall.allocate( 7000 ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); // free it shmall.deallocate( ch1, 7000 ); ch1 = shmall.allocate( 3000 ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); ch2 = shmall.allocate( 400 ); - BOOST_CHECK( ch2 != 0 ); + EXAM_CHECK( ch2 != 0 ); char *ch3 = shmall.allocate( 3500 ); - BOOST_CHECK( ch3 != 0 ); + EXAM_CHECK( ch3 != 0 ); shmall.deallocate( ch1, 3000 ); shmall.deallocate( ch2, 400 ); shmall.deallocate( ch3, 3500 ); ch1 = shmall.allocate( sz ); - BOOST_CHECK( ch1 != 0 ); + EXAM_CHECK( ch1 != 0 ); shmall.deallocate( ch1, sz ); } seg.deallocate(); fs::remove( fname ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } @@ -634,7 +645,7 @@ * This test is similar mt_test::fork() above, but instead plain shm_* * functions it use allocator based on shared memory segment */ -void mt_test::fork_shm() +int EXAM_IMPL(mt_test::fork_shm) { const char fname[] = "/tmp/mt_test.shm"; try { @@ -661,12 +672,12 @@ } catch ( xmt::fork_in_parent& child ) { try { - BOOST_CHECK( child.pid() > 0 ); + EXAM_CHECK( child.pid() > 0 ); fcnd.set( true ); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } catch ( ... ) { } @@ -680,14 +691,14 @@ fs::remove( fname ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } } /* ****************************************************** * Test: how to take named object in shared memory segment */ -void mt_test::shm_named_obj() +int EXAM_IMPL(mt_test::shm_named_obj) { const char fname[] = "/tmp/mt_test.shm"; enum { @@ -726,32 +737,32 @@ fcnd_ch.set( true ); } catch ( const xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "Fail in child: " << err.what() ); + EXAM_ERROR( err.what() ); } catch ( const std::invalid_argument& err ) { - BOOST_CHECK_MESSAGE( false, "Fail in child: " << err.what() ); + EXAM_ERROR( err.what() ); } catch ( ... ) { - BOOST_CHECK_MESSAGE( false, "Fail in child" ); + EXAM_ERROR( "Fail in child" ); } exit( 0 ); } catch ( xmt::fork_in_parent& child ) { try { - BOOST_CHECK( child.pid() > 0 ); + EXAM_CHECK( child.pid() > 0 ); fcnd.try_wait(); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } catch ( ... ) { - BOOST_CHECK_MESSAGE( false, "Fail in parent" ); + EXAM_ERROR( "Fail in parent" ); } } catch ( ... ) { - BOOST_CHECK_MESSAGE( false, "Fail in fork" ); + EXAM_ERROR( "Fail in fork" ); } (&fcnd)->~__condition<true>(); @@ -760,8 +771,10 @@ fs::remove( fname ); } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ****************************************************** @@ -769,23 +782,26 @@ static const char fname1[] = "/tmp/mt_test.shm.1"; xmt::shm_alloc<1> seg1; -void mt_test::shm_init() +int EXAM_IMPL(mt_test::shm_init) { seg1.allocate( fname1, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0660 ); + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::shm_finit() +int EXAM_IMPL(mt_test::shm_finit) { seg1.deallocate(); fs::remove( fname1 ); + + return EXAM_RESULT; } /* ****************************************************** */ -void mt_test::shm_named_obj_more() +int EXAM_IMPL(mt_test::shm_named_obj_more) { enum { ObjName = 1 @@ -811,14 +827,14 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } exit( 0 ); } catch ( xmt::fork_in_parent& child ) { fcnd.try_wait(); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here @@ -837,7 +853,7 @@ nm_ch.release<xmt::__condition<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } exit( 0 ); @@ -845,7 +861,7 @@ catch ( xmt::fork_in_parent& child ) { fcnd1.try_wait(); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here @@ -865,7 +881,7 @@ nm_ch.release<xmt::__barrier<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } exit( 0 ); @@ -873,16 +889,18 @@ catch ( xmt::fork_in_parent& child ) { b.wait(); int stat; - BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } nm.release<xmt::__barrier<true> >( ObjName ); // barrier should be destroyed here } catch ( xmt::shm_bad_alloc& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } catch ( const std::invalid_argument& err ) { - BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); + EXAM_ERROR( err.what() ); } + + return EXAM_RESULT; } /* ****************************************************** @@ -914,7 +932,7 @@ return rt; } -void mt_test::thr_mgr() +int EXAM_IMPL(mt_test::thr_mgr) { xmt::ThreadMgr mgr; @@ -925,7 +943,9 @@ // cerr << "Join!\n"; mgr.join(); - BOOST_CHECK( my_thr_scnt == 200 ); - BOOST_CHECK( my_thr_cnt == 0 ); - BOOST_CHECK( mgr.size() == 0 ); + EXAM_CHECK( my_thr_scnt == 200 ); + EXAM_CHECK( my_thr_cnt == 0 ); + EXAM_CHECK( mgr.size() == 0 ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/mt_test.h =================================================================== --- trunk/complement/explore/test/mt/mt_test.h 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/mt_test.h 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/19 13:21:37 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 21:01:43 ptr> /* * Copyright (c) 2006, 2007 @@ -11,29 +11,33 @@ #ifndef __MT_TEST_H #define __MT_TEST_H +#define FIT_EXAM + +#include <exam/suite.h> + class mt_test { public: - void barrier(); - void join_test(); - void barrier2(); - void yield(); - void mutex_test(); - void spinlock_test(); - void recursive_mutex_test(); + int EXAM_DECL(barrier); + int EXAM_DECL(join_test); + int EXAM_DECL(barrier2); + int EXAM_DECL(yield); + int EXAM_DECL(mutex_test); + int EXAM_DECL(spinlock_test); + int EXAM_DECL(recursive_mutex_test); - void fork(); - void pid(); - void shm_segment(); - void shm_alloc(); - void fork_shm(); - void shm_named_obj(); - void thr_mgr(); + int EXAM_DECL(fork); + int EXAM_DECL(pid); + int EXAM_DECL(shm_segment); + int EXAM_DECL(shm_alloc); + int EXAM_DECL(fork_shm); + int EXAM_DECL(shm_named_obj); + int EXAM_DECL(thr_mgr); - void shm_init(); - void shm_finit(); + int EXAM_DECL(shm_init); + int EXAM_DECL(shm_finit); - void shm_named_obj_more(); + int EXAM_DECL(shm_named_obj_more); private: // static xmt::Thread::ret_code thread_entry_call( void * ); Modified: trunk/complement/explore/test/mt/mt_test_suite.cc =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/mt_test_suite.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/19 13:43:38 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 10:20:08 ptr> /* * Copyright (c) 2006, 2007 @@ -13,73 +13,76 @@ #include <config/feature.h> -using namespace boost::unit_test_framework; +int EXAM_DECL(timespec_diff); +int EXAM_DECL(signal_1_test); +// int EXAM_DECL(signal_2_test); +int EXAM_DECL(signal_3_test); -mt_test_suite::mt_test_suite() : - test_suite( "mt test suite" ) +// flock requre revision, commented now. +// int EXAM_DECL( flock_test ); +// int EXAM_DECL( lfs_test ); + +int EXAM_IMPL(mt_test_suite) { - boost::shared_ptr<mt_test> instance( new mt_test() ); + exam::test_suite t( "libxmt test" ); + mt_test test; - test_case *barrier_tc = BOOST_CLASS_TEST_CASE( &mt_test::barrier, instance ); - test_case *join_tc = BOOST_CLASS_TEST_CASE( &mt_test::join_test, instance ); - test_case *barrier2_tc = BOOST_CLASS_TEST_CASE( &mt_test::barrier2, instance ); - test_case *yield_tc = BOOST_CLASS_TEST_CASE( &mt_test::yield, instance ); - test_case *mutex_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::mutex_test, instance ); -#ifdef __FIT_PTHREAD_SPINLOCK - test_case *spinlock_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::spinlock_test, instance ); -#endif - test_case *recursive_mutex_test_tc = BOOST_CLASS_TEST_CASE( &mt_test::recursive_mutex_test, instance ); - test_case *fork_tc = BOOST_CLASS_TEST_CASE( &mt_test::fork, instance ); - test_case *pid_tc = BOOST_CLASS_TEST_CASE( &mt_test::pid, instance ); - test_case *shm_segment_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_segment, instance ); - test_case *shm_alloc_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_alloc, instance ); - test_case *fork_shm_tc = BOOST_CLASS_TEST_CASE( &mt_test::fork_shm, instance ); - test_case *shm_nm_obj_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_named_obj, instance ); - test_case *shm_nm_obj_more_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_named_obj_more, instance ); + t.add( timespec_diff, "timespec_diff" ); + t.add( signal_1_test, "signal_1_test" ); + // You can't throw exception from signal handler + // (stack saved/restored, that confuse stack unwind); + // by this reason next test is commented: + // t.add( signal_2_test, "signal_2_test" ); + t.add( signal_3_test, "signal_3_test" ); - test_case *thr_mgr_tc = BOOST_CLASS_TEST_CASE( &mt_test::thr_mgr, instance ); + exam::test_suite::test_case_type tc[5]; - test_case *shm_init_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_init, instance ); - test_case *shm_finit_tc = BOOST_CLASS_TEST_CASE( &mt_test::shm_finit, instance ); + tc[0] = t.add( &mt_test::barrier, test, "mt_test::barrier" ); + tc[1] = t.add( &mt_test::join_test, test, "mt_test::join_test" ); + tc[2] = t.add( &mt_test::yield, test, "mt_test::yield", + t.add( &mt_test::barrier2, test, "mt_test::barrier2", + tc, tc+2 ) ); + tc[3] = t.add( &mt_test::mutex_test, test, "mt_test::mutex_test", tc[2] ); - barrier2_tc->depends_on( barrier_tc ); - barrier2_tc->depends_on( join_tc ); - yield_tc->depends_on( barrier2_tc ); - mutex_test_tc->depends_on( yield_tc ); #ifdef __FIT_PTHREAD_SPINLOCK - spinlock_test_tc->depends_on( yield_tc ); + t.add( &mt_test::spinlock_test, test, "mt_test::spinlock_test", tc[2] ); #endif - recursive_mutex_test_tc->depends_on( mutex_test_tc ); + t.add( &mt_test::recursive_mutex_test, test, "mt_test::recursive_mutex_test", tc[3] ); + t.add( &mt_test::pid, test, "mt_test::pid", + t.add( &mt_test::fork, test, "mt_test::fork" ) ); + tc[4] = t.add( &mt_test::shm_alloc, test, "mt_test::shm_alloc", + t.add( &mt_test::shm_segment, test, "mt_test::shm_segment" ) ); + t.add( &mt_test::shm_named_obj, test, "mt_test::shm_named_obj", + t.add( &mt_test::fork_shm, test, "mt_test::fork_shm", tc[4] ) ); + t.add( &mt_test::shm_named_obj_more, test, "mt_test::shm_named_obj_more" ); - pid_tc->depends_on( fork_tc ); - shm_alloc_tc->depends_on( shm_segment_tc ); - fork_shm_tc->depends_on( shm_alloc_tc ); - shm_nm_obj_tc->depends_on( fork_shm_tc ); + t.add( &mt_test::thr_mgr, test, "mt_test::thr_mgr" ); - shm_init_tc->depends_on( shm_alloc_tc ); - shm_nm_obj_more_tc->depends_on( shm_init_tc ); - shm_finit_tc->depends_on( shm_init_tc ); + t.add( &mt_test::shm_finit, test, "mt_test::shm_finit", + t.add( &mt_test::shm_init, test, "mt_test::shm_init", tc[4] ) ); - add( barrier_tc, 0, 2 ); - add( join_tc ); - add( barrier2_tc, 0, 3 ); - add( yield_tc, 0, 3 ); - add( mutex_test_tc, 0, 3 ); + // add( barrier_tc, 0, 2 ); + // add( join_tc ); + // add( barrier2_tc, 0, 3 ); + // add( yield_tc, 0, 3 ); + // add( mutex_test_tc, 0, 3 ); #ifdef __FIT_PTHREAD_SPINLOCK - add( spinlock_test_tc, 0, 3 ); + // add( spinlock_test_tc, 0, 3 ); #endif - add( recursive_mutex_test_tc, 0, 3 ); + // add( recursive_mutex_test_tc, 0, 3 ); - add( fork_tc ); - add( pid_tc ); - add( shm_segment_tc ); - add( shm_alloc_tc ); - add( fork_shm_tc, 0, 5 ); - add( shm_nm_obj_tc, 0, 5 ); + // add( fork_tc ); + // add( pid_tc ); + // add( shm_segment_tc ); + // add( shm_alloc_tc ); + // add( fork_shm_tc, 0, 5 ); + // add( shm_nm_obj_tc, 0, 5 ); - add( thr_mgr_tc ); + // add( thr_mgr_tc ); - add( shm_init_tc ); - add( shm_nm_obj_more_tc ); - add( shm_finit_tc ); + // add( shm_init_tc ); + // add( shm_nm_obj_more_tc ); + // add( shm_finit_tc ); + + return t.girdle(); }; Modified: trunk/complement/explore/test/mt/mt_test_suite.h =================================================================== --- trunk/complement/explore/test/mt/mt_test_suite.h 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/mt_test_suite.h 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <06/12/14 10:42:18 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 22:08:39 ptr> /* - * Copyright (c) 2006 + * Copyright (c) 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 @@ -11,12 +11,8 @@ #ifndef __MT_TEST_SUITE_H #define __MT_TEST_SUITE_H -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -struct mt_test_suite : - public boost::unit_test_framework::test_suite -{ - mt_test_suite(); -}; +int EXAM_DECL(mt_test_suite); #endif // __MT_TEST_SUITE_H Modified: trunk/complement/explore/test/mt/signal-1.cc =================================================================== --- trunk/complement/explore/test/mt/signal-1.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/signal-1.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,17 +1,15 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:21:38 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 09:49:18 ptr> /* - * Copyright (c) 2003, 2006 + * Copyright (c) 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <mt/xmt.h> using namespace xmt; @@ -40,7 +38,7 @@ void handler( int ) { - BOOST_CHECK( v == 1 ); + EXAM_CHECK_ASYNC( v == 1 ); v = 4; /* Note: you have very restricted list of system calls that you can use here @@ -64,7 +62,7 @@ // That's why I set own handler: xmt::signal_handler( SIGINT, handler ); - BOOST_CHECK( v == 1 ); + EXAM_CHECK_ASYNC( v == 1 ); cnd.try_wait(); @@ -89,7 +87,7 @@ t.join(); - BOOST_CHECK( v == 4 ); + EXAM_CHECK_ASYNC( v == 4 ); Thread::ret_code rt; rt.iword = 0; @@ -97,11 +95,13 @@ return rt; } -void signal_1_test() +int EXAM_IMPL(signal_1_test) { Thread t( thread_two ); t.join(); - BOOST_CHECK( v == 4 ); + EXAM_CHECK( v == 4 ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/signal-2.cc =================================================================== --- trunk/complement/explore/test/mt/signal-2.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/signal-2.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,17 +1,15 @@ -// -*- C++ -*- Time-stamp: <06/12/15 10:41:46 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 21:34:49 ptr> /* - * Copyright (c) 2003, 2006 + * Copyright (c) 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <mt/xmt.h> #include <iostream> @@ -116,11 +114,13 @@ return rt; } -void signal_2_test() +int EXAM_IMPL(signal_2_test) { Thread t( thread_two ); t.join(); - BOOST_CHECK( v == 5 ); + EXAM_CHECK( v == 5 ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/signal-3.cc =================================================================== --- trunk/complement/explore/test/mt/signal-3.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/signal-3.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,17 +1,15 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:22:05 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 09:50:35 ptr> /* - * Copyright (c) 2003, 2006 + * Copyright (c) 2003, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - #include <mt/xmt.h> using namespace xmt; @@ -45,7 +43,7 @@ void handler( int ) { - BOOST_CHECK( v == 1 ); + EXAM_CHECK_ASYNC( v == 1 ); v = 4; /* Note: you have very restricted list of system calls that you can use here @@ -63,7 +61,7 @@ Thread::ret_code thread_one( void * ) { - BOOST_CHECK( v == 1 ); + EXAM_CHECK_ASYNC( v == 1 ); cnd.try_wait(); @@ -86,11 +84,11 @@ t.join(); - BOOST_CHECK( v == 1 ); // signal was blocked! + EXAM_CHECK_ASYNC( v == 1 ); // signal was blocked! xmt::unblock_signal( SIGINT ); // unblock signal - BOOST_CHECK( v == 4 ); + EXAM_CHECK_ASYNC( v == 4 ); Thread::ret_code rt; rt.iword = 0; @@ -98,7 +96,7 @@ return rt; } -void signal_3_test() +int EXAM_IMPL(signal_3_test) { cnd.set( false ); @@ -110,5 +108,7 @@ t.join(); - BOOST_CHECK( v == 4 ); + EXAM_CHECK( v == 4 ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/timespec.cc =================================================================== --- trunk/complement/explore/test/mt/timespec.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/timespec.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,36 +1,18 @@ -// -*- C++ -*- Time-stamp: <04/05/06 18:38:06 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 21:38:13 ptr> /* - * Copyright (c) 2004 + * Copyright (c) 2004, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.0 + * Licensed under the Academic Free License Version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. */ -#ifdef __unix -# ifdef __HP_aCC -#pragma VERSIONID "@(#)$Id$" -# else -#ident "@(#)$Id$" -# endif -#endif - #include <mt/xmt.h> -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> -using namespace boost::unit_test_framework; - -void timespec_diff() +int EXAM_IMPL(timespec_diff) { timespec t1; t1.tv_sec = 1083852875; @@ -42,14 +24,14 @@ timespec t3 = t1 - t2; - BOOST_CHECK( t3.tv_sec == 3 ); - BOOST_CHECK( t3.tv_nsec == 651251000 ); + EXAM_CHECK( t3.tv_sec == 3 ); + EXAM_CHECK( t3.tv_nsec == 651251000 ); t3 = t1; t3 -= t2; - BOOST_CHECK( t3.tv_sec == 3 ); - BOOST_CHECK( t3.tv_nsec == 651251000 ); + EXAM_CHECK( t3.tv_sec == 3 ); + EXAM_CHECK( t3.tv_nsec == 651251000 ); t1.tv_sec = 1; t1.tv_nsec = 1; @@ -59,12 +41,14 @@ t3 = t1 - t2; - BOOST_CHECK( t3.tv_sec == 1 ); - BOOST_CHECK( t3.tv_nsec == 0 ); + EXAM_CHECK( t3.tv_sec == 1 ); + EXAM_CHECK( t3.tv_nsec == 0 ); t3 = t1; t3 -= t2; - BOOST_CHECK( t3.tv_sec == 1 ); - BOOST_CHECK( t3.tv_nsec == 0 ); + EXAM_CHECK( t3.tv_sec == 1 ); + EXAM_CHECK( t3.tv_nsec == 0 ); + + return EXAM_RESULT; } Modified: trunk/complement/explore/test/mt/unit_test.cc =================================================================== --- trunk/complement/explore/test/mt/unit_test.cc 2007-07-17 06:29:46 UTC (rev 1617) +++ trunk/complement/explore/test/mt/unit_test.cc 2007-07-17 06:33:12 UTC (rev 1618) @@ -1,49 +1,19 @@ -// -*- C++ -*- Time-stamp: <07/02/06 10:08:47 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 22:12:10 ptr> /* - * Copyright (c) 2002, 2003, 2004, 2006 + * Copyright (c) 2002, 2003, 2004, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License Version 3.0 * */ -#include <boost/test/unit_test.hpp> +#include <exam/suite.h> #include <config/feature.h> #include "mt_test_suite.h" -using namespace boost::unit_test_framework; - -void timespec_diff(); -void signal_1_test(); -void signal_2_test(); -void signal_3_test(); -void flock_test(); -void lfs_test(); - - -#ifdef WIN32 -test_suite *__cdecl init_unit_test_suite( int argc, char * * const argv ) -#else -test_suite *init_unit_test_suite( int argc, char * * const argv ) -#endif /* !WIN32 */ +int main( int, char ** ) { - test_suite *ts = BOOST_TEST_SUITE( "libxmt test" ); - - ts->add( BOOST_TEST_CASE( ×pec_diff ) ); - ts->add( BOOST_TEST_CASE( &signal_1_test ) ); - // You can't throw exception from signal handler - // (stack saved/restored, that confuse stack unwind); - // by this reason next test is commented: - // ts->add( BOOST_TEST_CASE( &signal_2_test ) ); - ts->add( BOOST_TEST_CASE( &signal_3_test ) ); - - // flock requre revision, commented now. - // ts->add( BOOST_TEST_CASE( &flock_test ) ); - // ts->add( BOOST_TEST_CASE( &lfs_test ) ); - - ts->add( new mt_test_suite() ); - - return ts; + return mt_test_suite(0); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-17 06:29:47
|
Revision: 1617 http://svn.sourceforge.net/complement/?rev=1617&view=rev Author: complement Date: 2007-07-16 23:29:46 -0700 (Mon, 16 Jul 2007) Log Message: ----------- was introduced stack of test suites, functions for asynchronous checks; add macros for asynchronous checkes [in case when point can't be unambiguously associated with some test case] Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/suite.cc Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/include/exam/suite.h 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 23:07:02 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 09:47:24 ptr> #ifndef __suite_h #define __suite_h @@ -6,6 +6,7 @@ #include <iostream> #include <sstream> #include <map> +#include <stack> #include <boost/graph/adjacency_list.hpp> #include <string> #include <exception> @@ -205,7 +206,10 @@ void report( const char *, int, bool, const char * ); base_logger *set_global_logger( base_logger * ); base_logger *set_logger( base_logger * ); + void set_fail(); + static test_suite& top(); + private: enum { pass = 0, @@ -226,6 +230,7 @@ }; typedef std::map<vertex_t,test_case_collect> test_case_map_type; + int _last_state; test_case_map_type _test; base_logger::stat _stat; std::string _suite_name; @@ -233,6 +238,8 @@ static int _root_func( test_suite *, int = 0 ); static base_logger *logger; + + static std::stack<test_suite *> _stack; }; template <class TC> @@ -300,19 +307,25 @@ # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT __exam_counter # define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_CHECK_ASYNC(C) if ( !(C) ) { exam::test_suite::top().report( __FILE__, __LINE__, false, #C ); exam::test_suite::top().set_fail(); } else exam::test_suite::top().report( __FILE__, __LINE__, true, #C ) # define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) +# define EXAM_MESSAGE_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, true, M ) # define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) # define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 # define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 +# define EXAM_ERROR_ASYNC(M) exam::test_suite::top().report( __FILE__, __LINE__, false, M ); exam::test_suite::top().set_fail() #else # define EXAM_IMPL(F) F( exam::test_suite *, int ) # define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) # define EXAM_RESULT 0 # define EXAM_CHECK(C) +# define EXAM_CHECK_ASYNC(C) # define EXAM_MESSAGE(M) +# define EXAM_MESSAGE_ASYNC(M) # define EXAM_REQUIRE(C) # define EXAM_FAIL(M) # define EXAM_ERROR(M) +# define EXAM_ERROR_ASYNC(M) #endif Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,5 +1,9 @@ 2007-07-17 Petr Ovtchenkov <pt...@is...> + * suite.h, suite.cc: was introduced stack of test suites, functions + for asynchronous checks; add macros for asynchronous checkes + [in case when point can't be unambiguously associated with some test case]; + * suite.h, suite.cc: added multiple dependencies; * ut/exam_test_suite.cc, ut/exam_test_suite.h, ut/dummy_test.cc: Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-16 21:14:15 UTC (rev 1616) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-17 06:29:46 UTC (rev 1617) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/17 00:36:02 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 10:03:02 ptr> #include <exam/suite.h> #include <boost/graph/breadth_first_search.hpp> @@ -101,26 +101,33 @@ test_suite::test_suite( const string& name ) : root( add_vertex( white_color, g ) ), + _last_state( 0 ), _suite_name( name ), local_logger( logger ) { testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + + _stack.push( this ); } test_suite::test_suite( const char *name ) : root( add_vertex( white_color, g ) ), + _last_state( 0 ), _suite_name( name ), local_logger( logger ) { testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + + _stack.push( this ); } test_suite::~test_suite() { + _stack.pop(); for ( test_case_map_type::iterator i = _test.begin(); i != _test.end(); ++i ) { delete i->second.tc; } @@ -193,10 +200,25 @@ return local_logger->flags( f ); } +void test_suite::set_fail() +{ + _last_state = fail; +} + trivial_logger __trivial_logger_inst( cerr ); base_logger *test_suite::logger = &__trivial_logger_inst; +stack<test_suite *> test_suite::_stack; +test_suite& test_suite::top() +{ + if ( _stack.empty() ) { + throw runtime_error( "stack of test suites empty" ); + } + + return *_stack.top(); +} + base_logger *test_suite::set_global_logger( base_logger *new_logger ) { base_logger *tmp = logger; @@ -225,8 +247,15 @@ ++_stat.total; if ( _test[v].state == 0 ) { if ( (*_test[v].tc)( this, 0 ) == 0 ) { - ++_stat.passed; - local_logger->tc( base_logger::pass, _test[v].name ); + if ( _last_state == 0 ) { + ++_stat.passed; + local_logger->tc( base_logger::pass, _test[v].name ); + } else { + _test[v].state = fail; + ++_stat.failed; + local_logger->tc( base_logger::fail, _test[v].name ); + _last_state = 0; + } } else { _test[v].state = fail; ++_stat.failed; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-16 21:14:16
|
Revision: 1616 http://svn.sourceforge.net/complement/?rev=1616&view=rev Author: complement Date: 2007-07-16 14:14:15 -0700 (Mon, 16 Jul 2007) Log Message: ----------- added multiple dependencies Modified Paths: -------------- trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/dummy_test.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.h Modified: trunk/complement/explore/include/exam/suite.h =================================================================== --- trunk/complement/explore/include/exam/suite.h 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/include/exam/suite.h 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 23:07:02 ptr> #ifndef __suite_h #define __suite_h @@ -178,12 +178,18 @@ test_case_type add( func_type, const std::string& name ); test_case_type add( func_type, const std::string& name, test_case_type ); + template <class InputIter> + test_case_type add( func_type, const std::string& name, InputIter, InputIter ); + template <class TC> test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name ); template <class TC> test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, test_case_type ); + template <class TC, class InputIter> + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, InputIter, InputIter ); + int girdle( test_case_type start ); int girdle() { return girdle( root ); } @@ -242,6 +248,21 @@ return v; } +template <class InputIter> +test_suite::test_case_type test_suite::add( test_suite::func_type f, const std::string& name, InputIter first, InputIter last ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + while ( first != last ) { + boost::add_edge( *first++, v, g ); + } + _test[v].tc = detail::make_test_case( detail::call( f ) ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + template <class TC> test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) { @@ -255,6 +276,21 @@ return v; } +template <class TC, class InputIter> +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, InputIter first, InputIter last ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + while ( first != last ) { + boost::add_edge( *first++, v, g ); + } + _test[v].tc = detail::make_test_case( f, instance ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + typedef test_suite::test_case_type test_case_type; } // namespace exam Modified: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,3 +1,11 @@ +2007-07-17 Petr Ovtchenkov <pt...@is...> + + * suite.h, suite.cc: added multiple dependencies; + + * ut/exam_test_suite.cc, ut/exam_test_suite.h, ut/dummy_test.cc: + test for multiple dependencies; discover problem with multiple + dependencies. + 2007-07-16 Petr Ovtchenkov <pt...@is...> * converted from prototype in app/exam; Modified: trunk/complement/explore/lib/exam/suite.cc =================================================================== --- trunk/complement/explore/lib/exam/suite.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:03 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 00:36:02 ptr> #include <exam/suite.h> #include <boost/graph/breadth_first_search.hpp> @@ -51,7 +51,10 @@ { // typename graph_traits<Graph>::vertex_descriptor u = boost::source( e, g ); // typename graph_traits<Graph>::vertex_descriptor v = boost::target( e, g ); + // boost::out_edges( v, g ); + // for () { _suite.check_test_case( boost::source( e, g ), boost::target( e, g ) ); + // } } test_suite& _suite; Modified: trunk/complement/explore/lib/exam/ut/dummy_test.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -34,3 +34,17 @@ return EXAM_RESULT; } + +int EXAM_IMPL(func_good2) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} + +int EXAM_IMPL(func_good3) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/17 00:38:11 ptr> #include "exam_test_suite.h" @@ -169,6 +169,70 @@ return EXAM_RESULT; } +int EXAM_IMPL(exam_basic_test::multiple_dep) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + + exam::test_suite::test_case_type tc[2]; + + tc[0] = t.add( &test_x::f_good, tx, "member function good" ); + tc[1] = t.add( func_good, "function good" ); + + t.add( func, "function fail", tc, tc + 2 ); + t.add( &test_x::f, tx, "member function fail", tc, tc + 2 ); + t.add( func_good2, "function 2 good", tc, tc + 2 ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r8 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::multiple_dep_complex) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + + exam::test_suite::test_case_type tc[2]; + exam::test_suite::test_case_type tcx[2]; + + tc[0] = t.add( &test_x::f_good, tx, "member function good" ); + tc[1] = t.add( func_good, "function good" ); + + tcx[0] = t.add( func, "function fail", tc, tc + 2 ); + t.add( &test_x::f, tx, "member function fail", tc, tc + 2 ); + tcx[1] = t.add( func_good2, "function 2 good", tc, tc + 2 ); + t.add( func_good3, "function 3 good", tcx, tcx + 2 ); // <-- problem + + logger.flags( exam::base_logger::verbose ); + t.girdle(); + logger.flags( 0 ); + + // EXAM_REQUIRE( buff.str() == r9 ); + + std::cerr << "%%%\n"; + std::cerr << buff.str() << std::endl; + std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + const std::string exam_basic_test::r0 = "\ *** PASS exam self test, good function (+2-0~0/2) ***\n"; @@ -223,17 +287,32 @@ FAIL slave test suite\n\ *** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; +const std::string exam_basic_test::r8 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function fail\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ +*** FAIL exam self test, fail function (+3-2~0/5) ***\n"; + +const std::string exam_basic_test::r9 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function fail\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ +*** FAIL exam self test, fail function (+3-2~1/6) ***\n"; + int EXAM_IMPL(exam_self_test) { exam::test_suite t( "exam self test" ); exam_basic_test exam_basic; - t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); - t.add( &exam_basic_test::function, exam_basic, "call test, fail calls" ); - exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency" ); + exam::test_suite::test_case_type d0 = t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); + t.add( &exam_basic_test::function, exam_basic, "call test, fail calls", d0 ); + exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency", d0 ); t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); + exam::test_suite::test_case_type d2 = t.add( &exam_basic_test::multiple_dep, exam_basic, "multiple dependencies", d ); + // t.add( &exam_basic_test::multiple_dep_complex, exam_basic, "complex multiple dependencies", d2 ); return t.girdle(); } - Modified: trunk/complement/explore/lib/exam/ut/exam_test_suite.h =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-16 15:17:55 UTC (rev 1615) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-16 21:14:15 UTC (rev 1616) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> +// -*- C++ -*- Time-stamp: <07/07/16 23:40:09 ptr> #ifndef __exam_test_suite_h #define __exam_test_suite_h @@ -22,6 +22,8 @@ int EXAM_DECL(dep); int EXAM_DECL(trace); int EXAM_DECL(dep_test_suite); + int EXAM_DECL(multiple_dep); + int EXAM_DECL(multiple_dep_complex); private: std::stringstream buff; @@ -35,6 +37,8 @@ static const std::string r5; static const std::string r6; static const std::string r7; + static const std::string r8; + static const std::string r9; }; int EXAM_DECL(exam_self_test); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-16 15:17:57
|
Revision: 1615 http://svn.sourceforge.net/complement/?rev=1615&view=rev Author: complement Date: 2007-07-16 08:17:55 -0700 (Mon, 16 Jul 2007) Log Message: ----------- libexam 0.1.0 Added Paths: ----------- trunk/complement/explore/lib/exam/ChangeLog trunk/complement/explore/lib/exam/Makefile trunk/complement/explore/lib/exam/Makefile.inc Added: trunk/complement/explore/lib/exam/ChangeLog =================================================================== --- trunk/complement/explore/lib/exam/ChangeLog (rev 0) +++ trunk/complement/explore/lib/exam/ChangeLog 2007-07-16 15:17:55 UTC (rev 1615) @@ -0,0 +1,31 @@ +2007-07-16 Petr Ovtchenkov <pt...@is...> + + * converted from prototype in app/exam; + + * logger.h, logger.cc: logger---interface and trivial_logger; + + * suite.h, suite.cc: test_suite framework; + + * ut/exam_test_suite.h, ut/exam_test_suite.cc: test suite for self; + + * ut/dummy_test.cc: dummy test suite for self-test; + + * ut/exam_self_test.cc, ut/Makefile, ut/Makefile.inc: self test program; + + * Makefile, Makefile.inc, libexam: version 0.1.0 + +2007-07-02 Petr Ovtchenkov <pt...@is...> + + * start prototyping. + +2007-05-18 Petr Ovtchenkov <pt...@is...> + + * exam's use-case views documented in SVN + +2007-03-09 Petr Ovtchenkov <pt...@is...> + + * exam's use-case views. + +2006-11-15 Petr Ovtchenkov <pt...@is...> + + * exam's idea. Added: trunk/complement/explore/lib/exam/Makefile =================================================================== --- trunk/complement/explore/lib/exam/Makefile (rev 0) +++ trunk/complement/explore/lib/exam/Makefile 2007-07-16 15:17:55 UTC (rev 1615) @@ -0,0 +1,31 @@ +# -*- Makefile -*- Time-stamp: <07/07/16 15:00:11 ptr> + +SRCROOT := ../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +INCLUDES += -I$(SRCROOT)/include + +check: all-shared + $(MAKE) -C ./ut + (cd ./ut; ${OUTPUT_DIR}/exam_self_test) || exit 1 + (cd ./ut; ${OUTPUT_DIR_DBG}/exam_self_test) || exit 1 + (cd ./ut; ${OUTPUT_DIR_STLDBG}/exam_self_test) || exit 1 + +check-release-shared: release-shared + $(MAKE) -C ./ut release-shared + (cd ./ut; ${OUTPUT_DIR}/exam_self_test) || exit 1 + +check-dbg-shared: dbg-shared + $(MAKE) -C ./ut dbg-shared + (cd ./ut; ${OUTPUT_DIR_DBG}/exam_self_test) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg-shared: stldbg-shared + $(MAKE) -C ./ut stldbg-shared + (cd ./ut; ${OUTPUT_DIR_STLDBG}/exam_self_test) || exit 1 +endif + +depend:: + $(MAKE) -C ./ut depend Added: trunk/complement/explore/lib/exam/Makefile.inc =================================================================== --- trunk/complement/explore/lib/exam/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/exam/Makefile.inc 2007-07-16 15:17:55 UTC (rev 1615) @@ -0,0 +1,7 @@ +# -*- Makefile -*- Time-stamp: <07/07/16 00:51:47 ptr> + +LIBNAME = exam +MAJOR = 0 +MINOR = 1 +PATCH = 0 +SRC_CC = logger.cc suite.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-16 14:34:45
|
Revision: 1614 http://svn.sourceforge.net/complement/?rev=1614&view=rev Author: complement Date: 2007-07-16 07:34:39 -0700 (Mon, 16 Jul 2007) Log Message: ----------- prepare exam for usage as lib and self-unit-test Added Paths: ----------- trunk/complement/explore/include/exam/ trunk/complement/explore/include/exam/logger.h trunk/complement/explore/include/exam/suite.h trunk/complement/explore/lib/exam/ trunk/complement/explore/lib/exam/logger.cc trunk/complement/explore/lib/exam/suite.cc trunk/complement/explore/lib/exam/ut/ trunk/complement/explore/lib/exam/ut/Makefile trunk/complement/explore/lib/exam/ut/Makefile.inc trunk/complement/explore/lib/exam/ut/dummy_test.cc trunk/complement/explore/lib/exam/ut/exam_self_test.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.cc trunk/complement/explore/lib/exam/ut/exam_test_suite.h Removed Paths: ------------- trunk/complement/explore/app/exam/dummy_test.cc trunk/complement/explore/app/exam/exam_self_test.cc trunk/complement/explore/app/exam/exam_test_suite.cc trunk/complement/explore/app/exam/exam_test_suite.h trunk/complement/explore/app/exam/logger.cc trunk/complement/explore/app/exam/logger.h trunk/complement/explore/app/exam/suite.cc trunk/complement/explore/app/exam/suite.h Deleted: trunk/complement/explore/app/exam/dummy_test.cc =================================================================== --- trunk/complement/explore/app/exam/dummy_test.cc 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/dummy_test.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,36 +0,0 @@ -#include "suite.h" - -int EXAM_IMPL(func) -{ - EXAM_CHECK(false); - - return EXAM_RESULT; -} - -class test_x -{ - public: - - int EXAM_IMPL(f) - { - EXAM_CHECK(false); - EXAM_CHECK(true); - - return EXAM_RESULT; - } - - int EXAM_IMPL(f_good) - { - EXAM_CHECK(true); - EXAM_CHECK(true); - - return EXAM_RESULT; - } -}; - -int EXAM_IMPL(func_good) -{ - EXAM_CHECK(true); - - return EXAM_RESULT; -} Deleted: trunk/complement/explore/app/exam/exam_self_test.cc =================================================================== --- trunk/complement/explore/app/exam/exam_self_test.cc 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/exam_self_test.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,14 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> - -#include "exam_test_suite.h" - -int main( int, char ** ) -{ - // exam::test_suite t( "exam self test" ); - // t.add( exam_self_test, "exam self test suite" ); - // - // return t.girdle(); - - return exam_self_test(0); -} - Deleted: trunk/complement/explore/app/exam/exam_test_suite.cc =================================================================== --- trunk/complement/explore/app/exam/exam_test_suite.cc 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/exam_test_suite.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,239 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> - -#include "exam_test_suite.h" - -#include "dummy_test.cc" - -int EXAM_IMPL(exam_basic_test::function_good) -{ - buff.str( "" ); - buff.clear(); - - exam::test_suite t( "exam self test, good function" ); - t.set_logger( &logger ); - - test_x tx; - t.add( func_good, "function" ); - t.add( &test_x::f_good, tx, "member function" ); - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r0 ); - - // std::cerr << "%%%\n"; - // std::cerr << buff.str() << std::endl; - // std::cerr << "%%%\n"; - - return EXAM_RESULT; -} - -int EXAM_IMPL(exam_basic_test::function) -{ - buff.str( "" ); - buff.clear(); - - exam::test_suite t( "exam self test, fail function" ); - t.set_logger( &logger ); - - test_x tx; - t.add( func, "function" ); - t.add( &test_x::f, tx, "member function" ); - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r1 ); - - // std::cerr << "%%%\n"; - // std::cerr << buff.str() << std::endl; - // std::cerr << "%%%\n"; - - return EXAM_RESULT; -} - -int EXAM_IMPL(exam_basic_test::dep) -{ - buff.str( "" ); - buff.clear(); - - exam::test_suite t( "exam self test, fail function" ); - t.set_logger( &logger ); - - test_x tx; - t.add( func_good, "function good", // "child" - t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" - t.add( func, "function fail", // <- skiped, because depends upon failed (next line) - t.add( &test_x::f, tx, "member function fail" ) ); // <- fail - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r2 ); - - // std::cerr << "%%%\n"; - // std::cerr << buff.str() << std::endl; - // std::cerr << "%%%\n"; - - return EXAM_RESULT; -} - -int EXAM_IMPL(exam_basic_test::trace) -{ - buff.str( "" ); - buff.clear(); - - exam::test_suite t( "exam self test, fail function" ); - t.set_logger( &logger ); - - logger.flags( exam::base_logger::trace_suite ); - - test_x tx; - t.add( func_good, "function good", // "child" - t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" - t.add( func, "function fail", // <- skiped, because depends upon failed (next line) - t.add( &test_x::f, tx, "member function fail" ) ); // <- fail - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r3 ); - - buff.str( "" ); - buff.clear(); - - logger.flags( exam::base_logger::silent ); - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r4 ); - - buff.str( "" ); - buff.clear(); - - logger.flags( exam::base_logger::trace ); - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r5 ); - - buff.str( "" ); - buff.clear(); - - logger.flags( exam::base_logger::verbose ); - - t.girdle(); - - logger.flags( 0 ); - - EXAM_REQUIRE( buff.str() == r6 ); - - // std::cerr << "%%%\n"; - // std::cerr << buff.str() << std::endl; - // std::cerr << "%%%\n"; - - return EXAM_RESULT; -} - -int EXAM_IMPL(exam_basic_test::dep_test_suite) -{ - buff.str( "" ); - buff.clear(); - - exam::test_suite t0( "exam self test, test suite master" ); - t0.set_logger( &logger ); - - test_x tx0; - t0.add( func_good, "function" ); - t0.add( &test_x::f_good, tx0, "member function" ); - - exam::test_suite t1( "exam self test, test suite slave" ); - t1.set_logger( &logger ); - - test_x tx1; - t1.add( func_good, "function good", // "child" - t1.add( &test_x::f_good, tx1, "member function good" ) ); // "parent" - t1.add( func, "function fail", // <- skiped, because depends upon failed (next line) - t1.add( &test_x::f, tx1, "member function fail" ) ); // <- fail - - exam::test_suite t( "exam self test, test suites dependency" ); - t.set_logger( &logger ); - - t.add( &exam::test_suite::run, t1, "slave test suite", - t.add( &exam::test_suite::run, t0, "master test suite" ) ); - - t.girdle(); - - EXAM_REQUIRE( buff.str() == r7 ); - - // std::cerr << "%%%\n"; - // std::cerr << buff.str() << std::endl; - // std::cerr << "%%%\n"; - - return EXAM_RESULT; -} - -const std::string exam_basic_test::r0 = "\ -*** PASS exam self test, good function (+2-0~0/2) ***\n"; - -const std::string exam_basic_test::r1 = "\ -dummy_test.cc:5: fail: false\n\ - FAIL function\n\ -dummy_test.cc:16: fail: false\n\ - FAIL member function\n\ -*** FAIL exam self test, fail function (+0-2~0/2) ***\n"; - -const std::string exam_basic_test::r2 = "\ -dummy_test.cc:16: fail: false\n\ - FAIL member function fail\n\ - SKIP function fail\n\ -*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; - -const std::string exam_basic_test::r3 = "\ -== Begin test suite\n\ -dummy_test.cc:16: fail: false\n\ - FAIL member function fail\n\ - SKIP function fail\n\ -== End test suite\n\ -*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; - -const std::string exam_basic_test::r4 = "\ -*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; - -const std::string exam_basic_test::r5 = "\ -dummy_test.cc:24: pass: true\n\ -dummy_test.cc:25: pass: true\n\ -dummy_test.cc:16: fail: false\n\ -dummy_test.cc:17: pass: true\n\ - FAIL member function fail\n\ - SKIP function fail\n\ -dummy_test.cc:33: pass: true\n\ -*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; - -const std::string exam_basic_test::r6 = "\ - PASS member function good\n\ -dummy_test.cc:16: fail: false\n\ - FAIL member function fail\n\ - SKIP function fail\n\ - PASS function good\n\ -*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; - -const std::string exam_basic_test::r7 = "\ -*** PASS exam self test, test suite master (+2-0~0/2) ***\n\ -dummy_test.cc:16: fail: false\n\ - FAIL member function fail\n\ - SKIP function fail\n\ -*** FAIL exam self test, test suite slave (+2-1~1/4) ***\n\ - FAIL slave test suite\n\ -*** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; - -int EXAM_IMPL(exam_self_test) -{ - exam::test_suite t( "exam self test" ); - exam_basic_test exam_basic; - - t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); - t.add( &exam_basic_test::function, exam_basic, "call test, fail calls" ); - exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency" ); - t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); - t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); - - return t.girdle(); -} - Deleted: trunk/complement/explore/app/exam/exam_test_suite.h =================================================================== --- trunk/complement/explore/app/exam/exam_test_suite.h 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/exam_test_suite.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,42 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> - -#ifndef __exam_test_suite_h -#define __exam_test_suite_h - -#define FIT_EXAM - -#include "suite.h" -#include <string> -#include <sstream> - -class exam_basic_test -{ - public: - exam_basic_test() : - buff(), - logger( buff ) - { } - - int EXAM_DECL(function_good); - int EXAM_DECL(function); - int EXAM_DECL(dep); - int EXAM_DECL(trace); - int EXAM_DECL(dep_test_suite); - - private: - std::stringstream buff; - exam::trivial_logger logger; - - static const std::string r0; - static const std::string r1; - static const std::string r2; - static const std::string r3; - static const std::string r4; - static const std::string r5; - static const std::string r6; - static const std::string r7; -}; - -int EXAM_DECL(exam_self_test); - -#endif // __exam_test_suite_h Deleted: trunk/complement/explore/app/exam/logger.cc =================================================================== --- trunk/complement/explore/app/exam/logger.cc 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/logger.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,111 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/13 10:53:32 ptr> - -#include "logger.h" -#include <iostream> - -namespace exam { - -using namespace std; - -int base_logger::flags() const -{ - return _flags; -} - -bool base_logger::is_trace() const -{ - return (_flags & trace) != 0; -} - -int base_logger::flags( int f ) -{ - int tmp = _flags; - _flags = f; - if ( (f & silent) != 0 ) { - _flags &= ~trace_suite; - } - return tmp; -} - -void trivial_logger::report( const char *file, int line, bool cnd, const char *expr ) -{ - if ( (cnd && ((_flags & trace) == 0)) || ((_flags & silent) != 0) ) { - return; - } - - if ( s != 0 ) { - *s << file << ":" << line << ": " << (cnd ? "pass" : "fail" ) << ": " << expr - << std::endl; - } else { - fprintf( f, "%s:%d: %s: %s\n", file, line, (cnd ? "pass" : "fail" ), expr ); - } -} - -void trivial_logger::begin_ts() -{ - if ( (_flags & trace_suite) == 0 ) { - return; - } - - if ( s != 0 ) { - *s << "== Begin test suite\n"; - } else { - fprintf( f, "== Begin test suite\n" ); - } -} - -void trivial_logger::end_ts() -{ - if ( (_flags & trace_suite) == 0 ) { - return; - } - - if ( *s ) { - *s << "== End test suite\n"; - } else { - fprintf( f, "== End test suite\n" ); - } -} - -void trivial_logger::result( const base_logger::stat& _stat, const string& suite_name ) -{ - if ( s != 0 ) { - *s << "*** " << (_stat.failed != 0 ? "FAIL " : "PASS " ) << suite_name - << " (+" << _stat.passed - << "-" << _stat.failed - << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; - } else { - fprintf( f, "*** %s (+%d-%d~%d/%d) ***\n", (_stat.failed != 0 ? "FAIL" : "PASS" ), _stat.passed, _stat.failed, _stat.skipped, _stat.total ); - } -} - -void trivial_logger::tc( base_logger::tc_result r, const std::string& name ) -{ - if ( ((_flags & silent) != 0) || ((r == pass) && ((_flags & verbose) == 0) )) { - return; - } - - static const char *m[] = { " PASS ", " FAIL ", " SKIP " }; - const char *rs = ""; - - switch ( r ) - { - case pass: - rs = m[0]; - break; - case fail: - rs = m[1]; - break; - case skip: - rs = m[2]; - break; - } - - if ( s != 0 ) { - *s << rs << name << endl; - } else { - fprintf( f, "%s%s\n", rs, name.c_str() ); - } -} - -} //namespace exam Deleted: trunk/complement/explore/app/exam/logger.h =================================================================== --- trunk/complement/explore/app/exam/logger.h 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/logger.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,94 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/13 11:01:52 ptr> - -#ifndef __logger_h -#define __logger_h - -#include <string> -#include <cstdio> -#include <ostream> - -namespace exam { - -class base_logger -{ - public: - - enum trace_flags { - trace = 1, - trace_suite = 2, - silent = 4, - verbose = 8 - }; - - enum tc_result { - pass = 0, - fail, - skip - }; - - struct stat - { - stat() : - total(0), - passed(0), - failed(0), - skipped(0) - { } - - int total; - int passed; - int failed; - int skipped; - }; - - base_logger() : - _flags( 0 ) - { } - virtual ~base_logger() - { } - - int flags() const; - bool is_trace() const; - - int flags( int ); - - virtual void report( const char *, int, bool, const char * ) = 0; - - virtual void begin_ts() = 0; - virtual void end_ts() = 0; - virtual void result( const base_logger::stat&, const std::string& suite_name ) = 0; - virtual void tc( tc_result, const std::string& ) = 0; - - protected: - int _flags; -}; - -class trivial_logger : - public base_logger -{ - public: - explicit trivial_logger( std::ostream& str ) : - s( &str ), - f( 0 ) - { } - - explicit trivial_logger( FILE *fs ) : - s( 0 ), - f( fs ) - { } - - virtual void report( const char *, int, bool, const char * ); - - virtual void begin_ts(); - virtual void end_ts(); - virtual void result( const base_logger::stat&, const std::string& ); - virtual void tc( base_logger::tc_result, const std::string& ); - - private: - std::ostream *s; - FILE *f; -}; - -} // namespace exam - -#endif // __logger_h Deleted: trunk/complement/explore/app/exam/suite.cc =================================================================== --- trunk/complement/explore/app/exam/suite.cc 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/suite.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,265 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:03 ptr> - -#include "suite.h" -#include <boost/graph/breadth_first_search.hpp> -#include <stack> - -#include <cstdio> -#include <iostream> - -namespace exam { - -using namespace std; -using namespace boost; -using namespace detail; - -namespace detail { - -template <class Tag> -struct vertex_recorder : - public base_visitor<vertex_recorder<Tag> > -{ - typedef Tag event_filter; - - vertex_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Vertex, class Graph> - void operator()(Vertex v, const Graph& g) - { _suite.run_test_case( v ); } - - test_suite& _suite; -}; - -template <class Tag> -vertex_recorder<Tag> record_vertexes(test_suite& ts, Tag) -{ return vertex_recorder<Tag>(ts); } - -template <class Tag> -struct skip_recorder : - public base_visitor<skip_recorder<Tag> > -{ - typedef Tag event_filter; - - skip_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Edge, class Graph> - void operator()(Edge e, const Graph& g) - { - // typename graph_traits<Graph>::vertex_descriptor u = boost::source( e, g ); - // typename graph_traits<Graph>::vertex_descriptor v = boost::target( e, g ); - _suite.check_test_case( boost::source( e, g ), boost::target( e, g ) ); - } - - test_suite& _suite; -}; - -template <class Tag> -skip_recorder<Tag> record_skip(test_suite& ts, Tag) -{ return skip_recorder<Tag>(ts); } - -template <class Tag> -struct white_recorder : - public base_visitor<white_recorder<Tag> > -{ - typedef Tag event_filter; - - white_recorder(test_suite& ts) : - _suite(ts) - { } - - template <class Vertex, class Graph> - void operator()(Vertex v, const Graph& g) - { - // std::cerr << "On vertex " << v << std::endl; - // boost::put( boost::vertex_color, g, v, white_color ); - _suite.clean_test_case_state( v ); - } - - test_suite& _suite; -}; - -template <class Tag> -white_recorder<Tag> record_white(test_suite& ts, Tag) -{ return white_recorder<Tag>(ts); } - - -} // namespace detail - -int EXAM_IMPL(test_suite::_root_func) -{ - throw init_exception(); - - return -1; -} - -test_suite::test_suite( const string& name ) : - root( add_vertex( white_color, g ) ), - _suite_name( name ), - local_logger( logger ) -{ - testcase = get( vertex_testcase, g ); - _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); - _test[root].state = 0; -} - -test_suite::test_suite( const char *name ) : - root( add_vertex( white_color, g ) ), - _suite_name( name ), - local_logger( logger ) -{ - testcase = get( vertex_testcase, g ); - _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); - _test[root].state = 0; -} - -test_suite::~test_suite() -{ - for ( test_case_map_type::iterator i = _test.begin(); i != _test.end(); ++i ) { - delete i->second.tc; - } -} - -int test_suite::girdle( test_suite::test_case_type start ) -{ - stack<vertex_t> buffer; - vertex_color_map_t color = get( vertex_color, g ); - - // detail::white_recorder<on_initialize_vertex> vis( *this ); - // - // vertex_iterator_t i, i_end; - - // for ( tie(i, i_end) = vertices(g); i != i_end; ++i ) { - // // vis.initialize_vertex( *i, g ); - // put( color, *i, white_color ); - // } - - _stat = base_logger::stat(); - local_logger->begin_ts(); - breadth_first_search( g, start, buffer, - make_bfs_visitor( - make_pair( record_white(*this,on_initialize_vertex()), - make_pair( record_vertexes(*this,on_discover_vertex()), - record_skip(*this,on_examine_edge()) ) ) ), - color ); - local_logger->end_ts(); - local_logger->result( _stat, _suite_name ); - - return _stat.failed; -} - -test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) -{ - vertex_t v = add_vertex( white_color, g); - add_edge( root, v, g ); - _test[v].tc = detail::make_test_case( detail::call( f ) ); - _test[v].state = 0; - _test[v].name = name; - // ++_stat.total; - - return v; -} - -test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name, test_suite::test_case_type depends ) -{ - vertex_t v = add_vertex( white_color, g); - add_edge( depends, v, g ); - _test[v].tc = detail::make_test_case( detail::call( f ) ); - _test[v].state = 0; - _test[v].name = name; - // ++_stat.total; - - return v; -} - -int test_suite::flags() -{ - return local_logger->flags(); -} - -bool test_suite::is_trace() -{ - return local_logger->is_trace(); -} - -int test_suite::flags( int f ) -{ - return local_logger->flags( f ); -} - -trivial_logger __trivial_logger_inst( cerr ); - -base_logger *test_suite::logger = &__trivial_logger_inst; - -base_logger *test_suite::set_global_logger( base_logger *new_logger ) -{ - base_logger *tmp = logger; - logger = new_logger; - if ( tmp == local_logger ) { // if local_logger was identical to logger, switch it too - local_logger = logger; - } - return tmp; -} - -base_logger *test_suite::set_logger( base_logger *new_logger ) -{ - base_logger *tmp = local_logger; - local_logger = new_logger; - return tmp; -} - -void test_suite::report( const char *file, int line, bool cnd, const char *expr ) -{ - local_logger->report( file, line, cnd, expr ); -} - -void test_suite::run_test_case( test_suite::vertex_t v ) -{ - try { - ++_stat.total; - if ( _test[v].state == 0 ) { - if ( (*_test[v].tc)( this, 0 ) == 0 ) { - ++_stat.passed; - local_logger->tc( base_logger::pass, _test[v].name ); - } else { - _test[v].state = fail; - ++_stat.failed; - local_logger->tc( base_logger::fail, _test[v].name ); - } - } else { - ++_stat.skipped; - local_logger->tc( base_logger::skip, _test[v].name ); - } - } - catch ( init_exception& ) { - --_stat.total; - } - catch ( ... ) { - ++_stat.failed; - _test[v].state = fail; - local_logger->tc( base_logger::fail, _test[v].name ); - } -} - -void test_suite::check_test_case( test_suite::vertex_t u, test_suite::vertex_t v ) -{ - if ( _test[u].state != 0 ) { - _test[v].state = skip; - } -} - -void test_suite::clean_test_case_state( vertex_t v ) -{ - _test[v].state = 0; -} - -int test_suite::run( test_suite *, int ) -{ - return girdle( root ); -} - - -} // namespace exam Deleted: trunk/complement/explore/app/exam/suite.h =================================================================== --- trunk/complement/explore/app/exam/suite.h 2007-07-16 14:04:06 UTC (rev 1613) +++ trunk/complement/explore/app/exam/suite.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -1,284 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/15 16:33:17 ptr> - -#ifndef __suite_h -#define __suite_h - -#include <iostream> -#include <sstream> -#include <map> -#include <boost/graph/adjacency_list.hpp> -#include <string> -#include <exception> - -#include "logger.h" - -enum vertex_testcase_t { vertex_testcase }; - -namespace boost { - BOOST_INSTALL_PROPERTY( vertex, testcase ); -} // namespace boost - -namespace exam { - -class test_suite; - -namespace detail { - -struct call_impl -{ - virtual ~call_impl() - { } - // virtual int invoke() = 0; - virtual int invoke( test_suite *, int = 0 ) = 0; -}; - -template <typename F> -class call_impl_t : - public call_impl -{ - public: - explicit call_impl_t( F f ) : - _f( f ) - { } - - // virtual int invoke() - // { return _f(); } - - virtual int invoke( test_suite *s, int count = 0 ) - { return _f( s, count ); } - - - private: - F _f; -}; - -class dummy -{ - public: - // virtual int f() - // { return 0; } - - virtual int f( test_suite *, int count = 0 ) - { return count; } - - private: - virtual ~dummy() - { } -}; - -template <class TC> -class method_invoker -{ - public: - // typedef int (TC::*mf_type_a)(); - typedef int (TC::*mf_type)( test_suite *, int ); - - explicit method_invoker( TC& instance, mf_type f ) : - _inst(instance), - _func(f) - { } - - method_invoker( const method_invoker<TC>& m ) : - _inst( m._inst ), - _func( m._func ) - { } - - // int operator()() - // { return (_inst.*_func)(); } - - int operator()( test_suite *ts, int count = 0 ) - { return (_inst.*_func)( ts, count ); } - - private: - method_invoker& operator =( const method_invoker<TC>& ) - { return *this; } - - TC& _inst; - mf_type _func; -}; - -class call -{ - public: - call() - { } - - template <class F> - call( F f ) - { new (&_buf[0]) call_impl_t<F>(f); } - - // int operator()() - // { return reinterpret_cast<call_impl *>(&_buf[0])->invoke(); } - - int operator()( test_suite *ts, int count = 0 ) - { return reinterpret_cast<call_impl *>(&_buf[0])->invoke( ts, count ); } - - private: - // call_impl *_f; - char _buf[((sizeof(call_impl_t<method_invoker<dummy> >)+64) / 64) << 6]; -}; - - -class test_case -{ - public: - test_case( const call& f ) : - _tc( f ) - { } - - // int operator ()() - // { return _tc(); } - - int operator ()( test_suite *ts, int count = 0 ) - { return _tc( ts, count ); } - - private: - call _tc; -}; - -inline test_case *make_test_case( const call& f ) -{ - return new test_case( f ); -} - -template <class TC> -inline test_case *make_test_case( int (TC::*f)( test_suite *, int ), TC& instance ) -{ - return new test_case( method_invoker<TC>(instance, f) ); -} - -} // namespace detail - -class init_exception : - public std::exception -{ -}; - -class test_suite -{ - private: - typedef boost::property<vertex_testcase_t,int> TestCaseProperty; - typedef boost::property<boost::vertex_color_t, boost::default_color_type, TestCaseProperty> VColorProperty; - - typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, VColorProperty > graph_t; - typedef boost::graph_traits<graph_t>::vertex_iterator vertex_iterator_t; - - typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; - typedef boost::property_map<graph_t,boost::vertex_color_t>::type vertex_color_map_t; - typedef boost::property_map<graph_t,vertex_testcase_t>::type vertex_testcase_map_t; - - public: - typedef int (*func_type)( test_suite *, int ); - typedef vertex_t test_case_type; - - test_suite( const std::string& name ); - test_suite( const char *name ); - ~test_suite(); - - test_case_type add( func_type, const std::string& name ); - test_case_type add( func_type, const std::string& name, test_case_type ); - - template <class TC> - test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name ); - - template <class TC> - test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, test_case_type ); - - int girdle( test_case_type start ); - int girdle() - { return girdle( root ); } - int run( test_suite *, int count = 0 ); - - void run_test_case( vertex_t v ); - void check_test_case( vertex_t u, vertex_t v ); - void clean_test_case_state( vertex_t v ); - - int flags(); - int flags( int ); - bool is_trace(); - void report( const char *, int, bool, const char * ); - base_logger *set_global_logger( base_logger * ); - base_logger *set_logger( base_logger * ); - - private: - enum { - pass = 0, - fail = 1, - skip = 2 - }; - - graph_t g; - vertex_t root; - vertex_testcase_map_t testcase; - base_logger *local_logger; - - struct test_case_collect - { - detail::test_case *tc; - int state; - std::string name; - }; - - typedef std::map<vertex_t,test_case_collect> test_case_map_type; - test_case_map_type _test; - base_logger::stat _stat; - std::string _suite_name; - - static int _root_func( test_suite *, int = 0 ); - - static base_logger *logger; -}; - -template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name ) -{ - vertex_t v = boost::add_vertex( boost::white_color, g); - boost::add_edge( root, v, g ); - _test[v].tc = detail::make_test_case( f, instance ); - _test[v].state = 0; - _test[v].name = name; - // ++_stat.total; - - return v; -} - -template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) -{ - vertex_t v = boost::add_vertex( boost::white_color, g); - boost::add_edge( depends, v, g ); - _test[v].tc = detail::make_test_case( f, instance ); - _test[v].state = 0; - _test[v].name = name; - // ++_stat.total; - - return v; -} - -typedef test_suite::test_case_type test_case_type; - -} // namespace exam - -#ifdef FIT_EXAM -# define EXAM_IMPL(F) F( exam::test_suite *__exam_ts, int __exam_counter ) -# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) -# define EXAM_RESULT __exam_counter -# define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) -# define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) -# define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) -# define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 -# define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 -#else -# define EXAM_IMPL(F) F( exam::test_suite *, int ) -# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) -# define EXAM_RESULT 0 -# define EXAM_CHECK(C) -# define EXAM_MESSAGE(M) -# define EXAM_REQUIRE(C) -# define EXAM_FAIL(M) -# define EXAM_ERROR(M) -#endif - - -#endif // __suite_h - Copied: trunk/complement/explore/include/exam/logger.h (from rev 1612, trunk/complement/explore/app/exam/logger.h) =================================================================== --- trunk/complement/explore/include/exam/logger.h (rev 0) +++ trunk/complement/explore/include/exam/logger.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,94 @@ +// -*- C++ -*- Time-stamp: <07/07/13 11:01:52 ptr> + +#ifndef __logger_h +#define __logger_h + +#include <string> +#include <cstdio> +#include <ostream> + +namespace exam { + +class base_logger +{ + public: + + enum trace_flags { + trace = 1, + trace_suite = 2, + silent = 4, + verbose = 8 + }; + + enum tc_result { + pass = 0, + fail, + skip + }; + + struct stat + { + stat() : + total(0), + passed(0), + failed(0), + skipped(0) + { } + + int total; + int passed; + int failed; + int skipped; + }; + + base_logger() : + _flags( 0 ) + { } + virtual ~base_logger() + { } + + int flags() const; + bool is_trace() const; + + int flags( int ); + + virtual void report( const char *, int, bool, const char * ) = 0; + + virtual void begin_ts() = 0; + virtual void end_ts() = 0; + virtual void result( const base_logger::stat&, const std::string& suite_name ) = 0; + virtual void tc( tc_result, const std::string& ) = 0; + + protected: + int _flags; +}; + +class trivial_logger : + public base_logger +{ + public: + explicit trivial_logger( std::ostream& str ) : + s( &str ), + f( 0 ) + { } + + explicit trivial_logger( FILE *fs ) : + s( 0 ), + f( fs ) + { } + + virtual void report( const char *, int, bool, const char * ); + + virtual void begin_ts(); + virtual void end_ts(); + virtual void result( const base_logger::stat&, const std::string& ); + virtual void tc( base_logger::tc_result, const std::string& ); + + private: + std::ostream *s; + FILE *f; +}; + +} // namespace exam + +#endif // __logger_h Copied: trunk/complement/explore/include/exam/suite.h (from rev 1612, trunk/complement/explore/app/exam/suite.h) =================================================================== --- trunk/complement/explore/include/exam/suite.h (rev 0) +++ trunk/complement/explore/include/exam/suite.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,284 @@ +// -*- C++ -*- Time-stamp: <07/07/15 16:33:17 ptr> + +#ifndef __suite_h +#define __suite_h + +#include <iostream> +#include <sstream> +#include <map> +#include <boost/graph/adjacency_list.hpp> +#include <string> +#include <exception> + +#include "logger.h" + +enum vertex_testcase_t { vertex_testcase }; + +namespace boost { + BOOST_INSTALL_PROPERTY( vertex, testcase ); +} // namespace boost + +namespace exam { + +class test_suite; + +namespace detail { + +struct call_impl +{ + virtual ~call_impl() + { } + // virtual int invoke() = 0; + virtual int invoke( test_suite *, int = 0 ) = 0; +}; + +template <typename F> +class call_impl_t : + public call_impl +{ + public: + explicit call_impl_t( F f ) : + _f( f ) + { } + + // virtual int invoke() + // { return _f(); } + + virtual int invoke( test_suite *s, int count = 0 ) + { return _f( s, count ); } + + + private: + F _f; +}; + +class dummy +{ + public: + // virtual int f() + // { return 0; } + + virtual int f( test_suite *, int count = 0 ) + { return count; } + + private: + virtual ~dummy() + { } +}; + +template <class TC> +class method_invoker +{ + public: + // typedef int (TC::*mf_type_a)(); + typedef int (TC::*mf_type)( test_suite *, int ); + + explicit method_invoker( TC& instance, mf_type f ) : + _inst(instance), + _func(f) + { } + + method_invoker( const method_invoker<TC>& m ) : + _inst( m._inst ), + _func( m._func ) + { } + + // int operator()() + // { return (_inst.*_func)(); } + + int operator()( test_suite *ts, int count = 0 ) + { return (_inst.*_func)( ts, count ); } + + private: + method_invoker& operator =( const method_invoker<TC>& ) + { return *this; } + + TC& _inst; + mf_type _func; +}; + +class call +{ + public: + call() + { } + + template <class F> + call( F f ) + { new (&_buf[0]) call_impl_t<F>(f); } + + // int operator()() + // { return reinterpret_cast<call_impl *>(&_buf[0])->invoke(); } + + int operator()( test_suite *ts, int count = 0 ) + { return reinterpret_cast<call_impl *>(&_buf[0])->invoke( ts, count ); } + + private: + // call_impl *_f; + char _buf[((sizeof(call_impl_t<method_invoker<dummy> >)+64) / 64) << 6]; +}; + + +class test_case +{ + public: + test_case( const call& f ) : + _tc( f ) + { } + + // int operator ()() + // { return _tc(); } + + int operator ()( test_suite *ts, int count = 0 ) + { return _tc( ts, count ); } + + private: + call _tc; +}; + +inline test_case *make_test_case( const call& f ) +{ + return new test_case( f ); +} + +template <class TC> +inline test_case *make_test_case( int (TC::*f)( test_suite *, int ), TC& instance ) +{ + return new test_case( method_invoker<TC>(instance, f) ); +} + +} // namespace detail + +class init_exception : + public std::exception +{ +}; + +class test_suite +{ + private: + typedef boost::property<vertex_testcase_t,int> TestCaseProperty; + typedef boost::property<boost::vertex_color_t, boost::default_color_type, TestCaseProperty> VColorProperty; + + typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, VColorProperty > graph_t; + typedef boost::graph_traits<graph_t>::vertex_iterator vertex_iterator_t; + + typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; + typedef boost::property_map<graph_t,boost::vertex_color_t>::type vertex_color_map_t; + typedef boost::property_map<graph_t,vertex_testcase_t>::type vertex_testcase_map_t; + + public: + typedef int (*func_type)( test_suite *, int ); + typedef vertex_t test_case_type; + + test_suite( const std::string& name ); + test_suite( const char *name ); + ~test_suite(); + + test_case_type add( func_type, const std::string& name ); + test_case_type add( func_type, const std::string& name, test_case_type ); + + template <class TC> + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name ); + + template <class TC> + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, test_case_type ); + + int girdle( test_case_type start ); + int girdle() + { return girdle( root ); } + int run( test_suite *, int count = 0 ); + + void run_test_case( vertex_t v ); + void check_test_case( vertex_t u, vertex_t v ); + void clean_test_case_state( vertex_t v ); + + int flags(); + int flags( int ); + bool is_trace(); + void report( const char *, int, bool, const char * ); + base_logger *set_global_logger( base_logger * ); + base_logger *set_logger( base_logger * ); + + private: + enum { + pass = 0, + fail = 1, + skip = 2 + }; + + graph_t g; + vertex_t root; + vertex_testcase_map_t testcase; + base_logger *local_logger; + + struct test_case_collect + { + detail::test_case *tc; + int state; + std::string name; + }; + + typedef std::map<vertex_t,test_case_collect> test_case_map_type; + test_case_map_type _test; + base_logger::stat _stat; + std::string _suite_name; + + static int _root_func( test_suite *, int = 0 ); + + static base_logger *logger; +}; + +template <class TC> +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + boost::add_edge( root, v, g ); + _test[v].tc = detail::make_test_case( f, instance ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + +template <class TC> +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) +{ + vertex_t v = boost::add_vertex( boost::white_color, g); + boost::add_edge( depends, v, g ); + _test[v].tc = detail::make_test_case( f, instance ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + +typedef test_suite::test_case_type test_case_type; + +} // namespace exam + +#ifdef FIT_EXAM +# define EXAM_IMPL(F) F( exam::test_suite *__exam_ts, int __exam_counter ) +# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) +# define EXAM_RESULT __exam_counter +# define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) +# define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 +# define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 +#else +# define EXAM_IMPL(F) F( exam::test_suite *, int ) +# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) +# define EXAM_RESULT 0 +# define EXAM_CHECK(C) +# define EXAM_MESSAGE(M) +# define EXAM_REQUIRE(C) +# define EXAM_FAIL(M) +# define EXAM_ERROR(M) +#endif + + +#endif // __suite_h + Property changes on: trunk/complement/explore/lib/exam ___________________________________________________________________ Name: svn:ignore + obj Copied: trunk/complement/explore/lib/exam/logger.cc (from rev 1612, trunk/complement/explore/app/exam/logger.cc) =================================================================== --- trunk/complement/explore/lib/exam/logger.cc (rev 0) +++ trunk/complement/explore/lib/exam/logger.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,111 @@ +// -*- C++ -*- Time-stamp: <07/07/13 10:53:32 ptr> + +#include <exam/logger.h> +#include <iostream> + +namespace exam { + +using namespace std; + +int base_logger::flags() const +{ + return _flags; +} + +bool base_logger::is_trace() const +{ + return (_flags & trace) != 0; +} + +int base_logger::flags( int f ) +{ + int tmp = _flags; + _flags = f; + if ( (f & silent) != 0 ) { + _flags &= ~trace_suite; + } + return tmp; +} + +void trivial_logger::report( const char *file, int line, bool cnd, const char *expr ) +{ + if ( (cnd && ((_flags & trace) == 0)) || ((_flags & silent) != 0) ) { + return; + } + + if ( s != 0 ) { + *s << file << ":" << line << ": " << (cnd ? "pass" : "fail" ) << ": " << expr + << std::endl; + } else { + fprintf( f, "%s:%d: %s: %s\n", file, line, (cnd ? "pass" : "fail" ), expr ); + } +} + +void trivial_logger::begin_ts() +{ + if ( (_flags & trace_suite) == 0 ) { + return; + } + + if ( s != 0 ) { + *s << "== Begin test suite\n"; + } else { + fprintf( f, "== Begin test suite\n" ); + } +} + +void trivial_logger::end_ts() +{ + if ( (_flags & trace_suite) == 0 ) { + return; + } + + if ( *s ) { + *s << "== End test suite\n"; + } else { + fprintf( f, "== End test suite\n" ); + } +} + +void trivial_logger::result( const base_logger::stat& _stat, const string& suite_name ) +{ + if ( s != 0 ) { + *s << "*** " << (_stat.failed != 0 ? "FAIL " : "PASS " ) << suite_name + << " (+" << _stat.passed + << "-" << _stat.failed + << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; + } else { + fprintf( f, "*** %s (+%d-%d~%d/%d) ***\n", (_stat.failed != 0 ? "FAIL" : "PASS" ), _stat.passed, _stat.failed, _stat.skipped, _stat.total ); + } +} + +void trivial_logger::tc( base_logger::tc_result r, const std::string& name ) +{ + if ( ((_flags & silent) != 0) || ((r == pass) && ((_flags & verbose) == 0) )) { + return; + } + + static const char *m[] = { " PASS ", " FAIL ", " SKIP " }; + const char *rs = ""; + + switch ( r ) + { + case pass: + rs = m[0]; + break; + case fail: + rs = m[1]; + break; + case skip: + rs = m[2]; + break; + } + + if ( s != 0 ) { + *s << rs << name << endl; + } else { + fprintf( f, "%s%s\n", rs, name.c_str() ); + } +} + +} //namespace exam Copied: trunk/complement/explore/lib/exam/suite.cc (from rev 1612, trunk/complement/explore/app/exam/suite.cc) =================================================================== --- trunk/complement/explore/lib/exam/suite.cc (rev 0) +++ trunk/complement/explore/lib/exam/suite.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,265 @@ +// -*- C++ -*- Time-stamp: <07/07/15 16:33:03 ptr> + +#include <exam/suite.h> +#include <boost/graph/breadth_first_search.hpp> +#include <stack> + +#include <cstdio> +#include <iostream> + +namespace exam { + +using namespace std; +using namespace boost; +using namespace detail; + +namespace detail { + +template <class Tag> +struct vertex_recorder : + public base_visitor<vertex_recorder<Tag> > +{ + typedef Tag event_filter; + + vertex_recorder(test_suite& ts) : + _suite(ts) + { } + + template <class Vertex, class Graph> + void operator()(Vertex v, const Graph& g) + { _suite.run_test_case( v ); } + + test_suite& _suite; +}; + +template <class Tag> +vertex_recorder<Tag> record_vertexes(test_suite& ts, Tag) +{ return vertex_recorder<Tag>(ts); } + +template <class Tag> +struct skip_recorder : + public base_visitor<skip_recorder<Tag> > +{ + typedef Tag event_filter; + + skip_recorder(test_suite& ts) : + _suite(ts) + { } + + template <class Edge, class Graph> + void operator()(Edge e, const Graph& g) + { + // typename graph_traits<Graph>::vertex_descriptor u = boost::source( e, g ); + // typename graph_traits<Graph>::vertex_descriptor v = boost::target( e, g ); + _suite.check_test_case( boost::source( e, g ), boost::target( e, g ) ); + } + + test_suite& _suite; +}; + +template <class Tag> +skip_recorder<Tag> record_skip(test_suite& ts, Tag) +{ return skip_recorder<Tag>(ts); } + +template <class Tag> +struct white_recorder : + public base_visitor<white_recorder<Tag> > +{ + typedef Tag event_filter; + + white_recorder(test_suite& ts) : + _suite(ts) + { } + + template <class Vertex, class Graph> + void operator()(Vertex v, const Graph& g) + { + // std::cerr << "On vertex " << v << std::endl; + // boost::put( boost::vertex_color, g, v, white_color ); + _suite.clean_test_case_state( v ); + } + + test_suite& _suite; +}; + +template <class Tag> +white_recorder<Tag> record_white(test_suite& ts, Tag) +{ return white_recorder<Tag>(ts); } + + +} // namespace detail + +int EXAM_IMPL(test_suite::_root_func) +{ + throw init_exception(); + + return -1; +} + +test_suite::test_suite( const string& name ) : + root( add_vertex( white_color, g ) ), + _suite_name( name ), + local_logger( logger ) +{ + testcase = get( vertex_testcase, g ); + _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); + _test[root].state = 0; +} + +test_suite::test_suite( const char *name ) : + root( add_vertex( white_color, g ) ), + _suite_name( name ), + local_logger( logger ) +{ + testcase = get( vertex_testcase, g ); + _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); + _test[root].state = 0; +} + +test_suite::~test_suite() +{ + for ( test_case_map_type::iterator i = _test.begin(); i != _test.end(); ++i ) { + delete i->second.tc; + } +} + +int test_suite::girdle( test_suite::test_case_type start ) +{ + stack<vertex_t> buffer; + vertex_color_map_t color = get( vertex_color, g ); + + // detail::white_recorder<on_initialize_vertex> vis( *this ); + // + // vertex_iterator_t i, i_end; + + // for ( tie(i, i_end) = vertices(g); i != i_end; ++i ) { + // // vis.initialize_vertex( *i, g ); + // put( color, *i, white_color ); + // } + + _stat = base_logger::stat(); + local_logger->begin_ts(); + breadth_first_search( g, start, buffer, + make_bfs_visitor( + make_pair( record_white(*this,on_initialize_vertex()), + make_pair( record_vertexes(*this,on_discover_vertex()), + record_skip(*this,on_examine_edge()) ) ) ), + color ); + local_logger->end_ts(); + local_logger->result( _stat, _suite_name ); + + return _stat.failed; +} + +test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) +{ + vertex_t v = add_vertex( white_color, g); + add_edge( root, v, g ); + _test[v].tc = detail::make_test_case( detail::call( f ) ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + +test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name, test_suite::test_case_type depends ) +{ + vertex_t v = add_vertex( white_color, g); + add_edge( depends, v, g ); + _test[v].tc = detail::make_test_case( detail::call( f ) ); + _test[v].state = 0; + _test[v].name = name; + // ++_stat.total; + + return v; +} + +int test_suite::flags() +{ + return local_logger->flags(); +} + +bool test_suite::is_trace() +{ + return local_logger->is_trace(); +} + +int test_suite::flags( int f ) +{ + return local_logger->flags( f ); +} + +trivial_logger __trivial_logger_inst( cerr ); + +base_logger *test_suite::logger = &__trivial_logger_inst; + +base_logger *test_suite::set_global_logger( base_logger *new_logger ) +{ + base_logger *tmp = logger; + logger = new_logger; + if ( tmp == local_logger ) { // if local_logger was identical to logger, switch it too + local_logger = logger; + } + return tmp; +} + +base_logger *test_suite::set_logger( base_logger *new_logger ) +{ + base_logger *tmp = local_logger; + local_logger = new_logger; + return tmp; +} + +void test_suite::report( const char *file, int line, bool cnd, const char *expr ) +{ + local_logger->report( file, line, cnd, expr ); +} + +void test_suite::run_test_case( test_suite::vertex_t v ) +{ + try { + ++_stat.total; + if ( _test[v].state == 0 ) { + if ( (*_test[v].tc)( this, 0 ) == 0 ) { + ++_stat.passed; + local_logger->tc( base_logger::pass, _test[v].name ); + } else { + _test[v].state = fail; + ++_stat.failed; + local_logger->tc( base_logger::fail, _test[v].name ); + } + } else { + ++_stat.skipped; + local_logger->tc( base_logger::skip, _test[v].name ); + } + } + catch ( init_exception& ) { + --_stat.total; + } + catch ( ... ) { + ++_stat.failed; + _test[v].state = fail; + local_logger->tc( base_logger::fail, _test[v].name ); + } +} + +void test_suite::check_test_case( test_suite::vertex_t u, test_suite::vertex_t v ) +{ + if ( _test[u].state != 0 ) { + _test[v].state = skip; + } +} + +void test_suite::clean_test_case_state( vertex_t v ) +{ + _test[v].state = 0; +} + +int test_suite::run( test_suite *, int ) +{ + return girdle( root ); +} + + +} // namespace exam Property changes on: trunk/complement/explore/lib/exam/ut ___________________________________________________________________ Name: svn:ignore + obj Copied: trunk/complement/explore/lib/exam/ut/Makefile (from rev 1606, trunk/complement/explore/app/exam/Makefile) =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile (rev 0) +++ trunk/complement/explore/lib/exam/ut/Makefile 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,11 @@ +# -*- Makefile -*- Time-stamp: <07/07/05 09:31:15 ptr> + +SRCROOT := ../../.. + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +# INCLUDES += -I${BOOST_DIR} +INCLUDES += -I${CoMT_INCLUDE_DIR} + +LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} Copied: trunk/complement/explore/lib/exam/ut/Makefile.inc (from rev 1613, trunk/complement/explore/app/exam/Makefile.inc) =================================================================== --- trunk/complement/explore/lib/exam/ut/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/exam/ut/Makefile.inc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,7 @@ +# -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> + +PRGNAME = exam_self_test +SRC_CC = exam_self_test.cc \ + exam_test_suite.cc \ + ../suite.cc \ + ../logger.cc Copied: trunk/complement/explore/lib/exam/ut/dummy_test.cc (from rev 1612, trunk/complement/explore/app/exam/dummy_test.cc) =================================================================== --- trunk/complement/explore/lib/exam/ut/dummy_test.cc (rev 0) +++ trunk/complement/explore/lib/exam/ut/dummy_test.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,36 @@ +#include <exam/suite.h> + +int EXAM_IMPL(func) +{ + EXAM_CHECK(false); + + return EXAM_RESULT; +} + +class test_x +{ + public: + + int EXAM_IMPL(f) + { + EXAM_CHECK(false); + EXAM_CHECK(true); + + return EXAM_RESULT; + } + + int EXAM_IMPL(f_good) + { + EXAM_CHECK(true); + EXAM_CHECK(true); + + return EXAM_RESULT; + } +}; + +int EXAM_IMPL(func_good) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} Copied: trunk/complement/explore/lib/exam/ut/exam_self_test.cc (from rev 1613, trunk/complement/explore/app/exam/exam_self_test.cc) =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_self_test.cc (rev 0) +++ trunk/complement/explore/lib/exam/ut/exam_self_test.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,14 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#include "exam_test_suite.h" + +int main( int, char ** ) +{ + // exam::test_suite t( "exam self test" ); + // t.add( exam_self_test, "exam self test suite" ); + // + // return t.girdle(); + + return exam_self_test(0); +} + Copied: trunk/complement/explore/lib/exam/ut/exam_test_suite.cc (from rev 1612, trunk/complement/explore/app/exam/exam_test_suite.cc) =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.cc (rev 0) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.cc 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,239 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#include "exam_test_suite.h" + +#include "dummy_test.cc" + +int EXAM_IMPL(exam_basic_test::function_good) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, good function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func_good, "function" ); + t.add( &test_x::f_good, tx, "member function" ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r0 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::function) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func, "function" ); + t.add( &test_x::f, tx, "member function" ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r1 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::dep) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func_good, "function good", // "child" + t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" + t.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t.add( &test_x::f, tx, "member function fail" ) ); // <- fail + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r2 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::trace) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + logger.flags( exam::base_logger::trace_suite ); + + test_x tx; + t.add( func_good, "function good", // "child" + t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" + t.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t.add( &test_x::f, tx, "member function fail" ) ); // <- fail + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r3 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::silent ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r4 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::trace ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r5 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::verbose ); + + t.girdle(); + + logger.flags( 0 ); + + EXAM_REQUIRE( buff.str() == r6 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::dep_test_suite) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t0( "exam self test, test suite master" ); + t0.set_logger( &logger ); + + test_x tx0; + t0.add( func_good, "function" ); + t0.add( &test_x::f_good, tx0, "member function" ); + + exam::test_suite t1( "exam self test, test suite slave" ); + t1.set_logger( &logger ); + + test_x tx1; + t1.add( func_good, "function good", // "child" + t1.add( &test_x::f_good, tx1, "member function good" ) ); // "parent" + t1.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t1.add( &test_x::f, tx1, "member function fail" ) ); // <- fail + + exam::test_suite t( "exam self test, test suites dependency" ); + t.set_logger( &logger ); + + t.add( &exam::test_suite::run, t1, "slave test suite", + t.add( &exam::test_suite::run, t0, "master test suite" ) ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r7 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +const std::string exam_basic_test::r0 = "\ +*** PASS exam self test, good function (+2-0~0/2) ***\n"; + +const std::string exam_basic_test::r1 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function\n\ +*** FAIL exam self test, fail function (+0-2~0/2) ***\n"; + +const std::string exam_basic_test::r2 = "\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r3 = "\ +== Begin test suite\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +== End test suite\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r4 = "\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r5 = "\ +dummy_test.cc:24: pass: true\n\ +dummy_test.cc:25: pass: true\n\ +dummy_test.cc:16: fail: false\n\ +dummy_test.cc:17: pass: true\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +dummy_test.cc:33: pass: true\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r6 = "\ + PASS member function good\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ + PASS function good\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r7 = "\ +*** PASS exam self test, test suite master (+2-0~0/2) ***\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +*** FAIL exam self test, test suite slave (+2-1~1/4) ***\n\ + FAIL slave test suite\n\ +*** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; + +int EXAM_IMPL(exam_self_test) +{ + exam::test_suite t( "exam self test" ); + exam_basic_test exam_basic; + + t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); + t.add( &exam_basic_test::function, exam_basic, "call test, fail calls" ); + exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency" ); + t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); + t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); + + return t.girdle(); +} + Copied: trunk/complement/explore/lib/exam/ut/exam_test_suite.h (from rev 1612, trunk/complement/explore/app/exam/exam_test_suite.h) =================================================================== --- trunk/complement/explore/lib/exam/ut/exam_test_suite.h (rev 0) +++ trunk/complement/explore/lib/exam/ut/exam_test_suite.h 2007-07-16 14:34:39 UTC (rev 1614) @@ -0,0 +1,42 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#ifndef __exam_test_suite_h +#define __exam_test_suite_h + +#define FIT_EXAM + +#include <exam/suite.h> +#include <string> +#include <sstream> + +class exam_basic_test +{ + public: + exam_basic_test() : + buff(), + logger( buff ) + { } + + int EXAM_DECL(function_good); + int EXAM_DECL(function); + int EXAM_DECL(dep); + int EXAM_DECL(trace); + int EXAM_DECL(dep_test_suite); + + private: + std::stringstream buff; + exam::trivial_logger logger; + + static const std::string r0; + static const std::string r1; + static const std::string r2; + static const std::string r3; + static const std::string r4; + static const std::string r5; + static const std::string r6; + static const std::string r7; +}; + +int EXAM_DECL(exam_self_test); + +#endif // __exam_test_suite_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-16 14:04:41
|
Revision: 1613 http://svn.sourceforge.net/complement/?rev=1613&view=rev Author: complement Date: 2007-07-16 07:04:06 -0700 (Mon, 16 Jul 2007) Log Message: ----------- rename main guard Modified Paths: -------------- trunk/complement/explore/app/exam/Makefile.inc Added Paths: ----------- trunk/complement/explore/app/exam/exam_self_test.cc Removed Paths: ------------- trunk/complement/explore/app/exam/zero.cc Modified: trunk/complement/explore/app/exam/Makefile.inc =================================================================== --- trunk/complement/explore/app/exam/Makefile.inc 2007-07-16 14:00:18 UTC (rev 1612) +++ trunk/complement/explore/app/exam/Makefile.inc 2007-07-16 14:04:06 UTC (rev 1613) @@ -1,4 +1,4 @@ # -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> -PRGNAME = zero -SRC_CC = zero.cc suite.cc logger.cc exam_test_suite.cc +PRGNAME = exam_self_test +SRC_CC = exam_self_test.cc suite.cc logger.cc exam_test_suite.cc Copied: trunk/complement/explore/app/exam/exam_self_test.cc (from rev 1612, trunk/complement/explore/app/exam/zero.cc) =================================================================== --- trunk/complement/explore/app/exam/exam_self_test.cc (rev 0) +++ trunk/complement/explore/app/exam/exam_self_test.cc 2007-07-16 14:04:06 UTC (rev 1613) @@ -0,0 +1,14 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#include "exam_test_suite.h" + +int main( int, char ** ) +{ + // exam::test_suite t( "exam self test" ); + // t.add( exam_self_test, "exam self test suite" ); + // + // return t.girdle(); + + return exam_self_test(0); +} + Deleted: trunk/complement/explore/app/exam/zero.cc =================================================================== --- trunk/complement/explore/app/exam/zero.cc 2007-07-16 14:00:18 UTC (rev 1612) +++ trunk/complement/explore/app/exam/zero.cc 2007-07-16 14:04:06 UTC (rev 1613) @@ -1,14 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> - -#include "exam_test_suite.h" - -int main( int, char ** ) -{ - // exam::test_suite t( "exam self test" ); - // t.add( exam_self_test, "exam self test suite" ); - // - // return t.girdle(); - - return exam_self_test(0); -} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-16 14:00:52
|
Revision: 1612 http://svn.sourceforge.net/complement/?rev=1612&view=rev Author: complement Date: 2007-07-16 07:00:18 -0700 (Mon, 16 Jul 2007) Log Message: ----------- self test established Modified Paths: -------------- trunk/complement/explore/app/exam/Makefile.inc trunk/complement/explore/app/exam/suite.cc trunk/complement/explore/app/exam/suite.h trunk/complement/explore/app/exam/zero.cc Added Paths: ----------- trunk/complement/explore/app/exam/dummy_test.cc trunk/complement/explore/app/exam/exam_test_suite.cc trunk/complement/explore/app/exam/exam_test_suite.h trunk/complement/explore/app/exam/logger.cc trunk/complement/explore/app/exam/logger.h Modified: trunk/complement/explore/app/exam/Makefile.inc =================================================================== --- trunk/complement/explore/app/exam/Makefile.inc 2007-07-12 07:33:00 UTC (rev 1611) +++ trunk/complement/explore/app/exam/Makefile.inc 2007-07-16 14:00:18 UTC (rev 1612) @@ -1,4 +1,4 @@ # -*- makefile -*- Time-stamp: <02/07/14 14:03:13 ptr> PRGNAME = zero -SRC_CC = zero.cc suite.cc +SRC_CC = zero.cc suite.cc logger.cc exam_test_suite.cc Added: trunk/complement/explore/app/exam/dummy_test.cc =================================================================== --- trunk/complement/explore/app/exam/dummy_test.cc (rev 0) +++ trunk/complement/explore/app/exam/dummy_test.cc 2007-07-16 14:00:18 UTC (rev 1612) @@ -0,0 +1,36 @@ +#include "suite.h" + +int EXAM_IMPL(func) +{ + EXAM_CHECK(false); + + return EXAM_RESULT; +} + +class test_x +{ + public: + + int EXAM_IMPL(f) + { + EXAM_CHECK(false); + EXAM_CHECK(true); + + return EXAM_RESULT; + } + + int EXAM_IMPL(f_good) + { + EXAM_CHECK(true); + EXAM_CHECK(true); + + return EXAM_RESULT; + } +}; + +int EXAM_IMPL(func_good) +{ + EXAM_CHECK(true); + + return EXAM_RESULT; +} Added: trunk/complement/explore/app/exam/exam_test_suite.cc =================================================================== --- trunk/complement/explore/app/exam/exam_test_suite.cc (rev 0) +++ trunk/complement/explore/app/exam/exam_test_suite.cc 2007-07-16 14:00:18 UTC (rev 1612) @@ -0,0 +1,239 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#include "exam_test_suite.h" + +#include "dummy_test.cc" + +int EXAM_IMPL(exam_basic_test::function_good) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, good function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func_good, "function" ); + t.add( &test_x::f_good, tx, "member function" ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r0 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::function) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func, "function" ); + t.add( &test_x::f, tx, "member function" ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r1 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::dep) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + test_x tx; + t.add( func_good, "function good", // "child" + t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" + t.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t.add( &test_x::f, tx, "member function fail" ) ); // <- fail + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r2 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::trace) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t( "exam self test, fail function" ); + t.set_logger( &logger ); + + logger.flags( exam::base_logger::trace_suite ); + + test_x tx; + t.add( func_good, "function good", // "child" + t.add( &test_x::f_good, tx, "member function good" ) ); // "parent" + t.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t.add( &test_x::f, tx, "member function fail" ) ); // <- fail + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r3 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::silent ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r4 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::trace ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r5 ); + + buff.str( "" ); + buff.clear(); + + logger.flags( exam::base_logger::verbose ); + + t.girdle(); + + logger.flags( 0 ); + + EXAM_REQUIRE( buff.str() == r6 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +int EXAM_IMPL(exam_basic_test::dep_test_suite) +{ + buff.str( "" ); + buff.clear(); + + exam::test_suite t0( "exam self test, test suite master" ); + t0.set_logger( &logger ); + + test_x tx0; + t0.add( func_good, "function" ); + t0.add( &test_x::f_good, tx0, "member function" ); + + exam::test_suite t1( "exam self test, test suite slave" ); + t1.set_logger( &logger ); + + test_x tx1; + t1.add( func_good, "function good", // "child" + t1.add( &test_x::f_good, tx1, "member function good" ) ); // "parent" + t1.add( func, "function fail", // <- skiped, because depends upon failed (next line) + t1.add( &test_x::f, tx1, "member function fail" ) ); // <- fail + + exam::test_suite t( "exam self test, test suites dependency" ); + t.set_logger( &logger ); + + t.add( &exam::test_suite::run, t1, "slave test suite", + t.add( &exam::test_suite::run, t0, "master test suite" ) ); + + t.girdle(); + + EXAM_REQUIRE( buff.str() == r7 ); + + // std::cerr << "%%%\n"; + // std::cerr << buff.str() << std::endl; + // std::cerr << "%%%\n"; + + return EXAM_RESULT; +} + +const std::string exam_basic_test::r0 = "\ +*** PASS exam self test, good function (+2-0~0/2) ***\n"; + +const std::string exam_basic_test::r1 = "\ +dummy_test.cc:5: fail: false\n\ + FAIL function\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function\n\ +*** FAIL exam self test, fail function (+0-2~0/2) ***\n"; + +const std::string exam_basic_test::r2 = "\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r3 = "\ +== Begin test suite\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +== End test suite\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r4 = "\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r5 = "\ +dummy_test.cc:24: pass: true\n\ +dummy_test.cc:25: pass: true\n\ +dummy_test.cc:16: fail: false\n\ +dummy_test.cc:17: pass: true\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +dummy_test.cc:33: pass: true\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r6 = "\ + PASS member function good\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ + PASS function good\n\ +*** FAIL exam self test, fail function (+2-1~1/4) ***\n"; + +const std::string exam_basic_test::r7 = "\ +*** PASS exam self test, test suite master (+2-0~0/2) ***\n\ +dummy_test.cc:16: fail: false\n\ + FAIL member function fail\n\ + SKIP function fail\n\ +*** FAIL exam self test, test suite slave (+2-1~1/4) ***\n\ + FAIL slave test suite\n\ +*** FAIL exam self test, test suites dependency (+1-1~0/2) ***\n"; + +int EXAM_IMPL(exam_self_test) +{ + exam::test_suite t( "exam self test" ); + exam_basic_test exam_basic; + + t.add( &exam_basic_test::function_good, exam_basic, "call test, good calls" ); + t.add( &exam_basic_test::function, exam_basic, "call test, fail calls" ); + exam::test_suite::test_case_type d = t.add( &exam_basic_test::dep, exam_basic, "call test, tests dependency" ); + t.add( &exam_basic_test::trace, exam_basic, "trace flags test", d ); + t.add( &exam_basic_test::dep_test_suite, exam_basic, "test suites grouping", d ); + + return t.girdle(); +} + Added: trunk/complement/explore/app/exam/exam_test_suite.h =================================================================== --- trunk/complement/explore/app/exam/exam_test_suite.h (rev 0) +++ trunk/complement/explore/app/exam/exam_test_suite.h 2007-07-16 14:00:18 UTC (rev 1612) @@ -0,0 +1,42 @@ +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> + +#ifndef __exam_test_suite_h +#define __exam_test_suite_h + +#define FIT_EXAM + +#include "suite.h" +#include <string> +#include <sstream> + +class exam_basic_test +{ + public: + exam_basic_test() : + buff(), + logger( buff ) + { } + + int EXAM_DECL(function_good); + int EXAM_DECL(function); + int EXAM_DECL(dep); + int EXAM_DECL(trace); + int EXAM_DECL(dep_test_suite); + + private: + std::stringstream buff; + exam::trivial_logger logger; + + static const std::string r0; + static const std::string r1; + static const std::string r2; + static const std::string r3; + static const std::string r4; + static const std::string r5; + static const std::string r6; + static const std::string r7; +}; + +int EXAM_DECL(exam_self_test); + +#endif // __exam_test_suite_h Added: trunk/complement/explore/app/exam/logger.cc =================================================================== --- trunk/complement/explore/app/exam/logger.cc (rev 0) +++ trunk/complement/explore/app/exam/logger.cc 2007-07-16 14:00:18 UTC (rev 1612) @@ -0,0 +1,111 @@ +// -*- C++ -*- Time-stamp: <07/07/13 10:53:32 ptr> + +#include "logger.h" +#include <iostream> + +namespace exam { + +using namespace std; + +int base_logger::flags() const +{ + return _flags; +} + +bool base_logger::is_trace() const +{ + return (_flags & trace) != 0; +} + +int base_logger::flags( int f ) +{ + int tmp = _flags; + _flags = f; + if ( (f & silent) != 0 ) { + _flags &= ~trace_suite; + } + return tmp; +} + +void trivial_logger::report( const char *file, int line, bool cnd, const char *expr ) +{ + if ( (cnd && ((_flags & trace) == 0)) || ((_flags & silent) != 0) ) { + return; + } + + if ( s != 0 ) { + *s << file << ":" << line << ": " << (cnd ? "pass" : "fail" ) << ": " << expr + << std::endl; + } else { + fprintf( f, "%s:%d: %s: %s\n", file, line, (cnd ? "pass" : "fail" ), expr ); + } +} + +void trivial_logger::begin_ts() +{ + if ( (_flags & trace_suite) == 0 ) { + return; + } + + if ( s != 0 ) { + *s << "== Begin test suite\n"; + } else { + fprintf( f, "== Begin test suite\n" ); + } +} + +void trivial_logger::end_ts() +{ + if ( (_flags & trace_suite) == 0 ) { + return; + } + + if ( *s ) { + *s << "== End test suite\n"; + } else { + fprintf( f, "== End test suite\n" ); + } +} + +void trivial_logger::result( const base_logger::stat& _stat, const string& suite_name ) +{ + if ( s != 0 ) { + *s << "*** " << (_stat.failed != 0 ? "FAIL " : "PASS " ) << suite_name + << " (+" << _stat.passed + << "-" << _stat.failed + << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; + } else { + fprintf( f, "*** %s (+%d-%d~%d/%d) ***\n", (_stat.failed != 0 ? "FAIL" : "PASS" ), _stat.passed, _stat.failed, _stat.skipped, _stat.total ); + } +} + +void trivial_logger::tc( base_logger::tc_result r, const std::string& name ) +{ + if ( ((_flags & silent) != 0) || ((r == pass) && ((_flags & verbose) == 0) )) { + return; + } + + static const char *m[] = { " PASS ", " FAIL ", " SKIP " }; + const char *rs = ""; + + switch ( r ) + { + case pass: + rs = m[0]; + break; + case fail: + rs = m[1]; + break; + case skip: + rs = m[2]; + break; + } + + if ( s != 0 ) { + *s << rs << name << endl; + } else { + fprintf( f, "%s%s\n", rs, name.c_str() ); + } +} + +} //namespace exam Added: trunk/complement/explore/app/exam/logger.h =================================================================== --- trunk/complement/explore/app/exam/logger.h (rev 0) +++ trunk/complement/explore/app/exam/logger.h 2007-07-16 14:00:18 UTC (rev 1612) @@ -0,0 +1,94 @@ +// -*- C++ -*- Time-stamp: <07/07/13 11:01:52 ptr> + +#ifndef __logger_h +#define __logger_h + +#include <string> +#include <cstdio> +#include <ostream> + +namespace exam { + +class base_logger +{ + public: + + enum trace_flags { + trace = 1, + trace_suite = 2, + silent = 4, + verbose = 8 + }; + + enum tc_result { + pass = 0, + fail, + skip + }; + + struct stat + { + stat() : + total(0), + passed(0), + failed(0), + skipped(0) + { } + + int total; + int passed; + int failed; + int skipped; + }; + + base_logger() : + _flags( 0 ) + { } + virtual ~base_logger() + { } + + int flags() const; + bool is_trace() const; + + int flags( int ); + + virtual void report( const char *, int, bool, const char * ) = 0; + + virtual void begin_ts() = 0; + virtual void end_ts() = 0; + virtual void result( const base_logger::stat&, const std::string& suite_name ) = 0; + virtual void tc( tc_result, const std::string& ) = 0; + + protected: + int _flags; +}; + +class trivial_logger : + public base_logger +{ + public: + explicit trivial_logger( std::ostream& str ) : + s( &str ), + f( 0 ) + { } + + explicit trivial_logger( FILE *fs ) : + s( 0 ), + f( fs ) + { } + + virtual void report( const char *, int, bool, const char * ); + + virtual void begin_ts(); + virtual void end_ts(); + virtual void result( const base_logger::stat&, const std::string& ); + virtual void tc( base_logger::tc_result, const std::string& ); + + private: + std::ostream *s; + FILE *f; +}; + +} // namespace exam + +#endif // __logger_h Modified: trunk/complement/explore/app/exam/suite.cc =================================================================== --- trunk/complement/explore/app/exam/suite.cc 2007-07-12 07:33:00 UTC (rev 1611) +++ trunk/complement/explore/app/exam/suite.cc 2007-07-16 14:00:18 UTC (rev 1612) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 11:10:45 ptr> +// -*- C++ -*- Time-stamp: <07/07/15 16:33:03 ptr> #include "suite.h" #include <boost/graph/breadth_first_search.hpp> @@ -61,39 +61,59 @@ skip_recorder<Tag> record_skip(test_suite& ts, Tag) { return skip_recorder<Tag>(ts); } +template <class Tag> +struct white_recorder : + public base_visitor<white_recorder<Tag> > +{ + typedef Tag event_filter; + + white_recorder(test_suite& ts) : + _suite(ts) + { } + + template <class Vertex, class Graph> + void operator()(Vertex v, const Graph& g) + { + // std::cerr << "On vertex " << v << std::endl; + // boost::put( boost::vertex_color, g, v, white_color ); + _suite.clean_test_case_state( v ); + } + + test_suite& _suite; +}; + +template <class Tag> +white_recorder<Tag> record_white(test_suite& ts, Tag) +{ return white_recorder<Tag>(ts); } + + } // namespace detail -int test_suite::_root_func() +int EXAM_IMPL(test_suite::_root_func) { - return test_suite::init; + throw init_exception(); + + return -1; } test_suite::test_suite( const string& name ) : root( add_vertex( white_color, g ) ), - _suite_name( name ) + _suite_name( name ), + local_logger( logger ) { - color = get( vertex_color, g ); testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; - _stat.total = 0; - _stat.passed = 0; - _stat.failed = 0; - _stat.skipped = 0; } test_suite::test_suite( const char *name ) : root( add_vertex( white_color, g ) ), - _suite_name( name ) + _suite_name( name ), + local_logger( logger ) { - color = get( vertex_color, g ); testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; - _stat.total = 0; - _stat.passed = 0; - _stat.failed = 0; - _stat.skipped = 0; } test_suite::~test_suite() @@ -103,49 +123,34 @@ } } -void test_suite::girdle() +int test_suite::girdle( test_suite::test_case_type start ) { stack<vertex_t> buffer; - cerr << "== Begin test suite\n"; - breadth_first_visit( g, root, buffer, - make_bfs_visitor( - make_pair( record_vertexes(*this,on_discover_vertex()), - record_skip(*this,on_examine_edge()) ) ), - color ); - cerr << "== End test suite\n"; - if ( _stat.failed != 0 ) { - cerr << "*** FAIL "; - } else { - cerr << "*** PASS "; - } - cerr << _suite_name - << " (+" << _stat.passed - << "-" << _stat.failed - << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; -} + vertex_color_map_t color = get( vertex_color, g ); -void test_suite::girdle( test_suite::test_case_type start ) -{ - stack<vertex_t> buffer; - cerr << "== Begin test suite\n"; - breadth_first_visit( g, start, buffer, - make_bfs_visitor( - make_pair( record_vertexes(*this,on_discover_vertex()), - record_skip(*this,on_examine_edge()) ) ), - color ); - cerr << "== End test suite\n"; - if ( _stat.failed != 0 ) { - cerr << "*** FAIL "; - } else { - cerr << "*** PASS "; - } - cerr << _suite_name - << " (+" << _stat.passed - << "-" << _stat.failed - << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; + // detail::white_recorder<on_initialize_vertex> vis( *this ); + // + // vertex_iterator_t i, i_end; + + // for ( tie(i, i_end) = vertices(g); i != i_end; ++i ) { + // // vis.initialize_vertex( *i, g ); + // put( color, *i, white_color ); + // } + + _stat = base_logger::stat(); + local_logger->begin_ts(); + breadth_first_search( g, start, buffer, + make_bfs_visitor( + make_pair( record_white(*this,on_initialize_vertex()), + make_pair( record_vertexes(*this,on_discover_vertex()), + record_skip(*this,on_examine_edge()) ) ) ), + color ); + local_logger->end_ts(); + local_logger->result( _stat, _suite_name ); + + return _stat.failed; } - test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) { vertex_t v = add_vertex( white_color, g); @@ -153,7 +158,7 @@ _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; _test[v].name = name; - ++_stat.total; + // ++_stat.total; return v; } @@ -165,69 +170,77 @@ _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; _test[v].name = name; - ++_stat.total; + // ++_stat.total; return v; } int test_suite::flags() { - return _flags; + return local_logger->flags(); } bool test_suite::is_trace() { - return (_flags & trace) != 0; + return local_logger->is_trace(); } -void _report0( const char *file, int line, bool cnd, const char *expr ) +int test_suite::flags( int f ) { - std::cerr << file << ":" << line << ": " << (cnd ? "pass" : "fail" ) << ": " << expr - << std::endl; + return local_logger->flags( f ); } -void _report1( const char *file, int line, bool cnd, const char *expr ) +trivial_logger __trivial_logger_inst( cerr ); + +base_logger *test_suite::logger = &__trivial_logger_inst; + +base_logger *test_suite::set_global_logger( base_logger *new_logger ) { - printf( "%s:%d: %s: %s\n", file, line, (cnd ? "pass" : "fail"), expr ); + base_logger *tmp = logger; + logger = new_logger; + if ( tmp == local_logger ) { // if local_logger was identical to logger, switch it too + local_logger = logger; + } + return tmp; } -void _report2( const char *file, int line, bool cnd, const char *expr ) +base_logger *test_suite::set_logger( base_logger *new_logger ) { - fprintf( stderr, "%s:%d: %s: %s\n", file, line, (cnd ? "pass" : "fail"), expr ); + base_logger *tmp = local_logger; + local_logger = new_logger; + return tmp; } -int test_suite::_flags = 0; -void (*test_suite::_report)( const char *, int, bool, const char * ) = _report0; - void test_suite::report( const char *file, int line, bool cnd, const char *expr ) { - (*test_suite::_report)( file, line, cnd, expr ); + local_logger->report( file, line, cnd, expr ); } void test_suite::run_test_case( test_suite::vertex_t v ) { try { + ++_stat.total; if ( _test[v].state == 0 ) { - int res = (*_test[v].tc)(); - if ( (res & init) != 0 ) { - // do nothing - } else if ( res == 0 ) { + if ( (*_test[v].tc)( this, 0 ) == 0 ) { ++_stat.passed; - cerr << " PASS " << _test[v].name << "\n"; + local_logger->tc( base_logger::pass, _test[v].name ); } else { _test[v].state = fail; ++_stat.failed; - cerr << " FAIL " << _test[v].name << "\n"; + local_logger->tc( base_logger::fail, _test[v].name ); } } else { ++_stat.skipped; - cerr << " SKIP " << _test[v].name << "\n"; + local_logger->tc( base_logger::skip, _test[v].name ); } } + catch ( init_exception& ) { + --_stat.total; + } catch ( ... ) { ++_stat.failed; _test[v].state = fail; - cerr << " FAIL " << _test[v].name << "\n"; + local_logger->tc( base_logger::fail, _test[v].name ); } } @@ -238,4 +251,15 @@ } } +void test_suite::clean_test_case_state( vertex_t v ) +{ + _test[v].state = 0; +} + +int test_suite::run( test_suite *, int ) +{ + return girdle( root ); +} + + } // namespace exam Modified: trunk/complement/explore/app/exam/suite.h =================================================================== --- trunk/complement/explore/app/exam/suite.h 2007-07-12 07:33:00 UTC (rev 1611) +++ trunk/complement/explore/app/exam/suite.h 2007-07-16 14:00:18 UTC (rev 1612) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 11:02:41 ptr> +// -*- C++ -*- Time-stamp: <07/07/15 16:33:17 ptr> #ifndef __suite_h #define __suite_h @@ -8,7 +8,10 @@ #include <map> #include <boost/graph/adjacency_list.hpp> #include <string> +#include <exception> +#include "logger.h" + enum vertex_testcase_t { vertex_testcase }; namespace boost { @@ -17,13 +20,16 @@ namespace exam { +class test_suite; + namespace detail { struct call_impl { virtual ~call_impl() { } - virtual int invoke() = 0; + // virtual int invoke() = 0; + virtual int invoke( test_suite *, int = 0 ) = 0; }; template <typename F> @@ -35,9 +41,13 @@ _f( f ) { } - virtual int invoke() - { return _f(); } + // virtual int invoke() + // { return _f(); } + virtual int invoke( test_suite *s, int count = 0 ) + { return _f( s, count ); } + + private: F _f; }; @@ -45,8 +55,12 @@ class dummy { public: - virtual int f() - { } + // virtual int f() + // { return 0; } + + virtual int f( test_suite *, int count = 0 ) + { return count; } + private: virtual ~dummy() { } @@ -56,7 +70,8 @@ class method_invoker { public: - typedef int (TC::*mf_type)(); + // typedef int (TC::*mf_type_a)(); + typedef int (TC::*mf_type)( test_suite *, int ); explicit method_invoker( TC& instance, mf_type f ) : _inst(instance), @@ -68,9 +83,12 @@ _func( m._func ) { } - int operator()() - { return (_inst.*_func)(); } + // int operator()() + // { return (_inst.*_func)(); } + int operator()( test_suite *ts, int count = 0 ) + { return (_inst.*_func)( ts, count ); } + private: method_invoker& operator =( const method_invoker<TC>& ) { return *this; } @@ -89,9 +107,12 @@ call( F f ) { new (&_buf[0]) call_impl_t<F>(f); } - int operator()() - { return reinterpret_cast<call_impl *>(&_buf[0])->invoke(); } + // int operator()() + // { return reinterpret_cast<call_impl *>(&_buf[0])->invoke(); } + int operator()( test_suite *ts, int count = 0 ) + { return reinterpret_cast<call_impl *>(&_buf[0])->invoke( ts, count ); } + private: // call_impl *_f; char _buf[((sizeof(call_impl_t<method_invoker<dummy> >)+64) / 64) << 6]; @@ -105,9 +126,12 @@ _tc( f ) { } - int operator ()() - { return _tc(); } + // int operator ()() + // { return _tc(); } + int operator ()( test_suite *ts, int count = 0 ) + { return _tc( ts, count ); } + private: call _tc; }; @@ -118,13 +142,18 @@ } template <class TC> -inline test_case *make_test_case( int (TC::*f)(), TC& instance ) +inline test_case *make_test_case( int (TC::*f)( test_suite *, int ), TC& instance ) { return new test_case( method_invoker<TC>(instance, f) ); } } // namespace detail +class init_exception : + public std::exception +{ +}; + class test_suite { private: @@ -139,7 +168,7 @@ typedef boost::property_map<graph_t,vertex_testcase_t>::type vertex_testcase_map_t; public: - typedef int (*func_type)(); + typedef int (*func_type)( test_suite *, int ); typedef vertex_t test_case_type; test_suite( const std::string& name ); @@ -150,45 +179,38 @@ test_case_type add( func_type, const std::string& name, test_case_type ); template <class TC> - test_case_type add( int (TC::*)(), TC&, const std::string& name ); + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name ); template <class TC> - test_case_type add( int (TC::*)(), TC&, const std::string& name, test_case_type ); + test_case_type add( int (TC::*)( test_suite *, int ), TC&, const std::string& name, test_case_type ); - struct stat - { - int total; - int passed; - int failed; - int skipped; - }; + int girdle( test_case_type start ); + int girdle() + { return girdle( root ); } + int run( test_suite *, int count = 0 ); - void girdle(); - void girdle( test_case_type start ); - void run_test_case( vertex_t v ); void check_test_case( vertex_t u, vertex_t v ); + void clean_test_case_state( vertex_t v ); - enum { - trace = 1, - trace_suite = 2 - }; + int flags(); + int flags( int ); + bool is_trace(); + void report( const char *, int, bool, const char * ); + base_logger *set_global_logger( base_logger * ); + base_logger *set_logger( base_logger * ); - static int flags(); - static bool is_trace(); - static void report( const char *, int, bool, const char * ); - private: enum { + pass = 0, fail = 1, - skip = 2, - init = 1024 + skip = 2 }; graph_t g; vertex_t root; - vertex_color_map_t color; vertex_testcase_map_t testcase; + base_logger *local_logger; struct test_case_collect { @@ -199,36 +221,36 @@ typedef std::map<vertex_t,test_case_collect> test_case_map_type; test_case_map_type _test; - test_suite::stat _stat; + base_logger::stat _stat; std::string _suite_name; - static int _flags; - static void (*_report)( const char *, int, bool, const char * ); - static int _root_func(); + static int _root_func( test_suite *, int = 0 ); + + static base_logger *logger; }; template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance, const std::string& name ) +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name ) { vertex_t v = boost::add_vertex( boost::white_color, g); boost::add_edge( root, v, g ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; _test[v].name = name; - ++_stat.total; + // ++_stat.total; return v; } template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance, const std::string& name, test_suite::test_case_type depends ) +test_suite::test_case_type test_suite::add( int (TC::*f)( test_suite *, int ), TC& instance, const std::string& name, test_suite::test_case_type depends ) { vertex_t v = boost::add_vertex( boost::white_color, g); boost::add_edge( depends, v, g ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; _test[v].name = name; - ++_stat.total; + // ++_stat.total; return v; } @@ -238,11 +260,23 @@ } // namespace exam #ifdef FIT_EXAM -# define EXAM_CHECK(C) if ( !(C) ) { exam::test_suite::report( __FILE__, __LINE__, false, #C ); return 1; } else if ( exam::test_suite::is_trace() ) { exam::test_suite::report( __FILE__, __LINE__, true, #C ); } -# define EXAM_MESSAGE(M) +# define EXAM_IMPL(F) F( exam::test_suite *__exam_ts, int __exam_counter ) +# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) +# define EXAM_RESULT __exam_counter +# define EXAM_CHECK(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); __exam_counter |= 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_MESSAGE(M) __exam_ts->report( __FILE__, __LINE__, true, M ) +# define EXAM_REQUIRE(C) if ( !(C) ) { __exam_ts->report( __FILE__, __LINE__, false, #C ); return 1; } else __exam_ts->report( __FILE__, __LINE__, true, #C ) +# define EXAM_FAIL(M) __exam_ts->report( __FILE__, __LINE__, false, M ); return 1 +# define EXAM_ERROR(M) __exam_ts->report( __FILE__, __LINE__, false, M ); __exam_counter |= 1 #else +# define EXAM_IMPL(F) F( exam::test_suite *, int ) +# define EXAM_DECL(F) F( exam::test_suite *, int = 0 ) +# define EXAM_RESULT 0 # define EXAM_CHECK(C) # define EXAM_MESSAGE(M) +# define EXAM_REQUIRE(C) +# define EXAM_FAIL(M) +# define EXAM_ERROR(M) #endif Modified: trunk/complement/explore/app/exam/zero.cc =================================================================== --- trunk/complement/explore/app/exam/zero.cc 2007-07-12 07:33:00 UTC (rev 1611) +++ trunk/complement/explore/app/exam/zero.cc 2007-07-16 14:00:18 UTC (rev 1612) @@ -1,49 +1,14 @@ -#define FIT_EXAM +// -*- C++ -*- Time-stamp: <07/07/16 16:33:17 ptr> -#include "suite.h" +#include "exam_test_suite.h" -int func() +int main( int, char ** ) { - EXAM_CHECK(false); + // exam::test_suite t( "exam self test" ); + // t.add( exam_self_test, "exam self test suite" ); + // + // return t.girdle(); - return 0; + return exam_self_test(0); } -int func2() -{ - EXAM_CHECK(true); - - return 0; -} - -class test_x -{ - public: - - int f() - { - EXAM_CHECK(false); - - return 0; - } -}; - - -int main( int argc, char **argv ) -{ - exam::test_suite t( "exam level 0" ); - - test_x tx; - - t.add( func, "simple function" ); - t.add( &test_x::f, tx, "member function" ); - - t.add( func, "simple function, depends", - t.add( &test_x::f, tx, "member function, depends", - t.add( func2, "simple good function" ) ) ); - - t.girdle(); - - return 0; -} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-12 07:33:02
|
Revision: 1611 http://svn.sourceforge.net/complement/?rev=1611&view=rev Author: complement Date: 2007-07-12 00:33:00 -0700 (Thu, 12 Jul 2007) Log Message: ----------- play with ieee754 Added Paths: ----------- trunk/complement/explore/inquiry/shades/double/ trunk/complement/explore/inquiry/shades/double/Makefile trunk/complement/explore/inquiry/shades/double/Makefile.inc trunk/complement/explore/inquiry/shades/double/test.c Property Changed: ---------------- trunk/complement/explore/inquiry/shades/float/ Property changes on: trunk/complement/explore/inquiry/shades/double ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/shades/double/Makefile =================================================================== --- trunk/complement/explore/inquiry/shades/double/Makefile (rev 0) +++ trunk/complement/explore/inquiry/shades/double/Makefile 2007-07-12 07:33:00 UTC (rev 1611) @@ -0,0 +1,11 @@ +# -*- Makefile -*- Time-stamp: <04/01/09 16:53:50 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +#release-shared : LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} +#dbg-shared : LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} +#stldbg-shared : LDFLAGS += -Wl,-rpath=${STLPORT_LIB_DIR} Added: trunk/complement/explore/inquiry/shades/double/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/shades/double/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/shades/double/Makefile.inc 2007-07-12 07:33:00 UTC (rev 1611) @@ -0,0 +1,5 @@ +# -*- makefile -*- Time-stamp: <04/01/12 15:37:40 ptr> + +PRGNAME = test +SRC_C = test.c +#SRC_CC = test.cc Added: trunk/complement/explore/inquiry/shades/double/test.c =================================================================== --- trunk/complement/explore/inquiry/shades/double/test.c (rev 0) +++ trunk/complement/explore/inquiry/shades/double/test.c 2007-07-12 07:33:00 UTC (rev 1611) @@ -0,0 +1,49 @@ +#include <stdlib.h> +#include <stdio.h> +#include <ieee754.h> + +union D { + unsigned char c[16]; + double d; +}; + +union U { + unsigned u[2]; + double d; +}; + +int main( int argc, char **argv ) +{ + union D d; + union ieee754_double ieee754; + union U u; + int i; + + for ( i = 0; i < 16; ++i ) { + d.c[i] = 0; + } + + d.d = 1.0; + ieee754.d = 1.0; + u.u[0] = 0; + u.u[1] = 0x3ff << 20; + + for ( i = 0; i < 16; ++i ) { + printf( "%.2x ", d.c[i] ); + } + printf( "\n" ); + + for ( i = 0; i < 8; ++i ) { + printf( "%.2x ", *((unsigned char *)&ieee754.d + i) ); + } + printf( "\n" ); + + printf( "%.1x %.3x %.5x %.8x\n", ieee754.ieee.negative, ieee754.ieee.exponent, ieee754.ieee.mantissa0, ieee754.ieee.mantissa1 ); + + for ( i = 0; i < 8; ++i ) { + printf( "%.2x ", *((unsigned char *)&u.d + i) ); + } + printf( "\n" ); + + return 0; +} Property changes on: trunk/complement/explore/inquiry/shades/float ___________________________________________________________________ Name: svn:ignore + obj This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-12 07:30:57
|
Revision: 1610 http://svn.sourceforge.net/complement/?rev=1610&view=rev Author: complement Date: 2007-07-12 00:30:55 -0700 (Thu, 12 Jul 2007) Log Message: ----------- remove_if issue Added Paths: ----------- trunk/complement/explore/inquiry/shades/remove/ trunk/complement/explore/inquiry/shades/remove/Makefile trunk/complement/explore/inquiry/shades/remove/Makefile.inc trunk/complement/explore/inquiry/shades/remove/test.cc Property changes on: trunk/complement/explore/inquiry/shades/remove ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/shades/remove/Makefile =================================================================== --- trunk/complement/explore/inquiry/shades/remove/Makefile (rev 0) +++ trunk/complement/explore/inquiry/shades/remove/Makefile 2007-07-12 07:30:55 UTC (rev 1610) @@ -0,0 +1,9 @@ +# -*- Makefile -*- Time-stamp: <04/01/09 16:53:50 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +LDFLAGS += -Wl,--rpath=${STLPORT_LIB_DIR} Added: trunk/complement/explore/inquiry/shades/remove/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/shades/remove/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/shades/remove/Makefile.inc 2007-07-12 07:30:55 UTC (rev 1610) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <04/01/12 15:37:40 ptr> + +PRGNAME = test +SRC_CC = test.cc Added: trunk/complement/explore/inquiry/shades/remove/test.cc =================================================================== --- trunk/complement/explore/inquiry/shades/remove/test.cc (rev 0) +++ trunk/complement/explore/inquiry/shades/remove/test.cc 2007-07-12 07:30:55 UTC (rev 1610) @@ -0,0 +1,63 @@ +#include <vector> +#include <algorithm> +#include <functional> +#include <iostream> + +using namespace std; + +int main() +{ + vector<int> v; + + v.push_back( 1 ); + v.push_back( 2 ); + v.push_back( 3 ); + v.push_back( 4 ); + v.push_back( 1 ); + + for ( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) { + cout << *i << ", "; + } + cout << endl; + + vector<int>::iterator j = remove( v.begin(), v.end(), 1 ); + + for ( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) { + cout << *i << ", "; + } + cout << endl; + + cout << (j - v.begin()) << endl; + + v.clear(); + + v.push_back( 1 ); + v.push_back( 2 ); + v.push_back( 3 ); + v.push_back( 4 ); + v.push_back( 1 ); + + j = remove_copy( v.begin(), v.end(), v.begin(), 1 ); + for ( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) { + cout << *i << ", "; + } + cout << endl; + + v.clear(); + + v.push_back( 1 ); + v.push_back( 2 ); + v.push_back( 3 ); + v.push_back( 4 ); + v.push_back( 1 ); + + j = remove_if( v.begin(), v.end(), bind2nd( not_equal_to<int>(), 1 ) ); + + for ( vector<int>::iterator i = v.begin(); i != v.end(); ++i ) { + cout << *i << ", "; + } + cout << endl; + + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-12 07:28:58
|
Revision: 1609 http://svn.sourceforge.net/complement/?rev=1609&view=rev Author: complement Date: 2007-07-12 00:28:57 -0700 (Thu, 12 Jul 2007) Log Message: ----------- importance of _FILE_OFFSET_BITS macro Added Paths: ----------- trunk/complement/explore/inquiry/shades/file64/ trunk/complement/explore/inquiry/shades/file64/Makefile trunk/complement/explore/inquiry/shades/file64/Makefile.inc trunk/complement/explore/inquiry/shades/file64/file64.c Property changes on: trunk/complement/explore/inquiry/shades/file64 ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/inquiry/shades/file64/Makefile =================================================================== --- trunk/complement/explore/inquiry/shades/file64/Makefile (rev 0) +++ trunk/complement/explore/inquiry/shades/file64/Makefile 2007-07-12 07:28:57 UTC (rev 1609) @@ -0,0 +1,7 @@ +# -*- Makefile -*- Time-stamp: <04/01/09 16:53:50 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak Added: trunk/complement/explore/inquiry/shades/file64/Makefile.inc =================================================================== --- trunk/complement/explore/inquiry/shades/file64/Makefile.inc (rev 0) +++ trunk/complement/explore/inquiry/shades/file64/Makefile.inc 2007-07-12 07:28:57 UTC (rev 1609) @@ -0,0 +1,4 @@ +# -*- makefile -*- Time-stamp: <04/04/16 20:55:38 ptr> + +PRGNAME = file64 +SRC_C = file64.c Added: trunk/complement/explore/inquiry/shades/file64/file64.c =================================================================== --- trunk/complement/explore/inquiry/shades/file64/file64.c (rev 0) +++ trunk/complement/explore/inquiry/shades/file64/file64.c 2007-07-12 07:28:57 UTC (rev 1609) @@ -0,0 +1,10 @@ +#define _FILE_OFFSET_BITS 64 + +#include <stdio.h> + +int main() +{ + FILE *f = fopen( "sample", "r" ); + fclose( f ); + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-12 07:26:46
|
Revision: 1608 http://svn.sourceforge.net/complement/?rev=1608&view=rev Author: complement Date: 2007-07-12 00:26:45 -0700 (Thu, 12 Jul 2007) Log Message: ----------- in-loop declaration influence only position on stack, but not more Added Paths: ----------- trunk/complement/explore/inquiry/shades/in-loop-decl/ trunk/complement/explore/inquiry/shades/in-loop-decl/test.c trunk/complement/explore/inquiry/shades/in-loop-decl/test.s Added: trunk/complement/explore/inquiry/shades/in-loop-decl/test.c =================================================================== --- trunk/complement/explore/inquiry/shades/in-loop-decl/test.c (rev 0) +++ trunk/complement/explore/inquiry/shades/in-loop-decl/test.c 2007-07-12 07:26:45 UTC (rev 1608) @@ -0,0 +1,20 @@ +int q( int b ) +{ + int a; + int i = 0; + while ( i < 10 ) { + a = b; + ++i; + } + return 0; +} + +int qq( int b ) +{ + int i = 0; + while ( i < 10 ) { + int a = b; + ++i; + } + return 0; +} Added: trunk/complement/explore/inquiry/shades/in-loop-decl/test.s =================================================================== --- trunk/complement/explore/inquiry/shades/in-loop-decl/test.s (rev 0) +++ trunk/complement/explore/inquiry/shades/in-loop-decl/test.s 2007-07-12 07:26:45 UTC (rev 1608) @@ -0,0 +1,42 @@ + .file "test.c" + .text +.globl q + .type q, @function +q: + pushl %ebp + movl %esp, %ebp + subl $16, %esp + movl $0, -4(%ebp) + jmp .L2 +.L3: + movl 8(%ebp), %eax + movl %eax, -8(%ebp) + incl -4(%ebp) +.L2: + cmpl $9, -4(%ebp) + jle .L3 + movl $0, %eax + leave + ret + .size q, .-q +.globl qq + .type qq, @function +qq: + pushl %ebp + movl %esp, %ebp + subl $16, %esp + movl $0, -8(%ebp) + jmp .L7 +.L8: + movl 8(%ebp), %eax + movl %eax, -4(%ebp) + incl -8(%ebp) +.L7: + cmpl $9, -8(%ebp) + jle .L8 + movl $0, %eax + leave + ret + .size qq, .-qq + .ident "GCC: (GNU) 4.1.1" + .section .note.GNU-stack,"",@progbits This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-12 07:13:04
|
Revision: 1607 http://svn.sourceforge.net/complement/?rev=1607&view=rev Author: complement Date: 2007-07-12 00:12:59 -0700 (Thu, 12 Jul 2007) Log Message: ----------- add include option for boost's headers, if BOOST_DIR defined Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/gcc.mak trunk/complement/explore/Makefiles/gmake/top.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2007-07-11 21:01:08 UTC (rev 1606) +++ trunk/complement/explore/Makefiles/ChangeLog 2007-07-12 07:12:59 UTC (rev 1607) @@ -1,3 +1,8 @@ +2007-07-12 Petr Ovtchenkov <pt...@is...> + + * gmake/gcc.mak, gmake/top.mak: add include option for boost's + headers, if BOOST_DIR defined. + 2007-06-08 Petr Ovtchenkov <pt...@is...> * clean.mak, extern.mak, config.mak: move to gmake catalog Modified: trunk/complement/explore/Makefiles/gmake/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-07-11 21:01:08 UTC (rev 1606) +++ trunk/complement/explore/Makefiles/gmake/gcc.mak 2007-07-12 07:12:59 UTC (rev 1607) @@ -1,4 +1,4 @@ -# Time-stamp: <07/05/31 01:25:52 ptr> +# Time-stamp: <07/07/12 10:51:42 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 # Petr Ovtchenkov @@ -66,6 +66,10 @@ INCLUDES = -I${STLPORT_INCLUDE_DIR} endif +ifdef BOOST_INCLUDE_DIR +INCLUDES += -I${BOOST_INCLUDE_DIR} +endif + OUTPUT_OPTION = -o $@ LINK_OUTPUT_OPTION = ${OUTPUT_OPTION} CPPFLAGS = $(DEFS) $(INCLUDES) Modified: trunk/complement/explore/Makefiles/gmake/top.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/top.mak 2007-07-11 21:01:08 UTC (rev 1606) +++ trunk/complement/explore/Makefiles/gmake/top.mak 2007-07-12 07:12:59 UTC (rev 1607) @@ -1,4 +1,4 @@ -# Time-stamp: <07/06/08 23:23:03 ptr> +# Time-stamp: <07/07/12 10:55:41 ptr> # # Copyright (c) 1997-1999, 2002, 2003, 2005-2007 # Petr Ovtchenkov @@ -81,12 +81,12 @@ include ${RULESBASE}/gmake/$(BUILD_OSNAME)/sys.mak # target OS-specific definitions, like ar, etc. include ${RULESBASE}/gmake/$(OSNAME)/targetsys.mak +# Extern projects for everyday usage and settings for ones +include ${RULESBASE}/gmake/extern.mak # compiler, compiler options include ${RULESBASE}/gmake/$(COMPILER_NAME).mak # rules to make dirs for targets include ${RULESBASE}/gmake/targetdirs.mak -# Extern projects for everyday usage and settings for ones -include ${RULESBASE}/gmake/extern.mak # os-specific local rules (or other project-specific definitions) -include specific.mak This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-11 21:01:15
|
Revision: 1606 http://svn.sourceforge.net/complement/?rev=1606&view=rev Author: complement Date: 2007-07-11 14:01:08 -0700 (Wed, 11 Jul 2007) Log Message: ----------- step to interface like boost or http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2007/n2178.html; Locker* changed to basic_lock or basic_read_lock, internal lock flag added, lock/unlock methods added to basic_*_lock and exception lock_error added too. Spinlock was renamed to spinlock, LockerExt to native_scoped_lock. LockerRd renamed to rd_scoped_lock, LockerWr to wr_scoped_lock, __mutex_rw_base to __rw_mutex_base, mutexRW to rw_mutex; mutexRS renamed to recursive_mutex; LockerRS renamed to recursive_scoped_lock; obsolete LockerSDS removed; all Mutex replaced by mutex; replace Locker by scoped_lock. Barrier replaced by barrier, Semaphore by semaphore. Condition replaced by condition; libxmt: version 1.11.0 libsockios: Version 1.12.0 libstem: library version 4.6.0 This is result of merge with -r1584:1605 from branches/complement-xmt Modified Paths: -------------- trunk/complement/explore/include/mt/shm.h trunk/complement/explore/include/mt/thr_mgr.h trunk/complement/explore/include/mt/xmt.h trunk/complement/explore/include/sockios/sockmgr.cc trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/include/sockios/sockstream trunk/complement/explore/include/stem/Cron.h trunk/complement/explore/include/stem/EvManager.h trunk/complement/explore/include/stem/EventHandler.h trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/Makefile.inc trunk/complement/explore/lib/mt/thr_mgr.cc trunk/complement/explore/lib/mt/time.cc trunk/complement/explore/lib/mt/uid.cc trunk/complement/explore/lib/mt/xmt.cc trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile.inc trunk/complement/explore/lib/sockios/_sockmgr.cc trunk/complement/explore/lib/sockios/_sockstream.cc trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc trunk/complement/explore/lib/stem/Makefile.inc trunk/complement/explore/lib/stem/NetTransport.cc trunk/complement/explore/lib/stem/_EventHandler.cc trunk/complement/explore/test/mt/flck.cc trunk/complement/explore/test/mt/lfs.cc trunk/complement/explore/test/mt/mt_test.cc trunk/complement/explore/test/mt/signal-1.cc trunk/complement/explore/test/mt/signal-3.cc trunk/complement/explore/test/sockios/bytes_in_socket.cc trunk/complement/explore/test/sockios/bytes_in_socket2.cc trunk/complement/explore/test/sockios/client-wc.cc trunk/complement/explore/test/sockios/close_socket.cc trunk/complement/explore/test/sockios/message.cc trunk/complement/explore/test/sockios/message.h trunk/complement/explore/test/sockios/sockios_test.cc trunk/complement/explore/test/stem/Echo.h trunk/complement/explore/test/stem/NameService.h trunk/complement/explore/test/stem/Node.h trunk/complement/explore/test/stem/NodeDL.h trunk/complement/explore/test/stem/unit_test.cc Modified: trunk/complement/explore/include/mt/shm.h =================================================================== --- trunk/complement/explore/include/mt/shm.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/mt/shm.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/07 10:11:34 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:38:41 ptr> /* * Copyright (c) 2006, 2007 @@ -70,31 +70,31 @@ }; template <> -struct ipc_sharable<xmt::__Condition<true> > +struct ipc_sharable<xmt::__condition<true> > { typedef std::__true_type is_ipc_sharable; }; template <> -struct ipc_sharable<xmt::__Semaphore<true> > +struct ipc_sharable<xmt::__semaphore<true> > { typedef std::__true_type is_ipc_sharable; }; template <> -struct ipc_sharable<xmt::__Barrier<true> > +struct ipc_sharable<xmt::__barrier<true> > { typedef std::__true_type is_ipc_sharable; }; template <> -struct ipc_sharable<xmt::__Mutex<false,true> > +struct ipc_sharable<xmt::__mutex<false,true> > { typedef std::__true_type is_ipc_sharable; }; template <> -struct ipc_sharable<xmt::__Mutex<true,true> > +struct ipc_sharable<xmt::__mutex<true,true> > { typedef std::__true_type is_ipc_sharable; }; @@ -303,7 +303,7 @@ template <class T> void named( const T& obj, int name ) { - xmt::__Locker<__Mutex<false,true> > lk( _lock ); + xmt::basic_lock<__mutex<false,true> > lk( _lock ); if ( _last == 255 ) { throw std::range_error( "too many named objects" ); } @@ -328,7 +328,7 @@ template <class T> T& named( int name ) { - xmt::__Locker<__Mutex<false,true> > lk( _lock ); + xmt::basic_lock<__mutex<false,true> > lk( _lock ); for ( int i = 0; _nm_table[i].name != -1; ++i ) { if ( _nm_table[i].name == name ) { ++_nm_table[i].count; @@ -341,7 +341,7 @@ template <class T> const T& named( int name ) const { - xmt::__Locker<__Mutex<false,true> > lk( _lock ); + xmt::basic_lock<__mutex<false,true> > lk( _lock ); for ( int i = 0; _nm_table[i].name != -1; ++i ) { if ( _nm_table[i].name == name ) { ++_nm_table[i].count; @@ -354,7 +354,7 @@ template <class T> void release( int name ) { - xmt::__Locker<__Mutex<false,true> > lk( _lock ); + xmt::basic_lock<__mutex<false,true> > lk( _lock ); for ( int i = 0; _nm_table[i].name != -1; ++i ) { if ( _nm_table[i].name == name ) { if ( --_nm_table[i].count == 0 ) { @@ -371,7 +371,7 @@ int count( int name ) const throw() { - xmt::__Locker<__Mutex<false,true> > lk( _lock ); + xmt::basic_lock<__mutex<false,true> > lk( _lock ); for ( int i = 0; _nm_table[i].name != -1; ++i ) { if ( _nm_table[i].name == name ) { return _nm_table[i].count; @@ -391,7 +391,7 @@ shm_name_mgr& operator =( const shm_name_mgr& ) { return *this; } - xmt::__Mutex<false,true> _lock; + xmt::__mutex<false,true> _lock; struct _name_rec { int name; @@ -420,7 +420,7 @@ { uint64_t _magic; size_type _first; - xmt::__Mutex<false,true> _lock; + xmt::__mutex<false,true> _lock; size_type _nm; }; @@ -463,7 +463,7 @@ if ( p != reinterpret_cast<pointer>(-1) && (force || _seg.count() <= 1) ) { _master *m = reinterpret_cast<_master *>( _seg.address() ); - (&m->_lock)->~__Mutex<false,true>(); + (&m->_lock)->~__mutex<false,true>(); if ( m->_nm != 0 ) { reinterpret_cast<shm_name_mgr<_Inst> *>(reinterpret_cast<char *>(p) + m->_nm)->~shm_name_mgr<_Inst>(); } @@ -480,7 +480,7 @@ if ( p != reinterpret_cast<pointer>(-1) ) { _master *m = reinterpret_cast<_master *>( p ); if ( m->_nm == 0 ) { - xmt::__Locker<xmt::__Mutex<false,true> > lk( m->_lock ); + xmt::basic_lock<xmt::__mutex<false,true> > lk( m->_lock ); void *nm = _traverse( &m->_first, sizeof(shm_name_mgr<_Inst>) ); m->_nm = reinterpret_cast<char *>(nm) - reinterpret_cast<char *>(p); return *new ( nm ) shm_name_mgr<_Inst>(); @@ -496,7 +496,7 @@ { _master *m = reinterpret_cast<_master *>( _seg.address() ); if ( m != reinterpret_cast<_master *>(-1) ) { - xmt::__Locker<xmt::__Mutex<false,true> > lk( m->_lock ); + xmt::basic_lock<xmt::__mutex<false,true> > lk( m->_lock ); return _traverse( &m->_first, n ); } @@ -512,8 +512,8 @@ static void init( _master& m ) { m._magic = MAGIC; - new ( &m._lock ) xmt::__Mutex<false,true>(); - xmt::__Locker<xmt::__Mutex<false,true> > lk( m._lock ); + new ( &m._lock ) xmt::__mutex<false,true>(); + xmt::basic_lock<xmt::__mutex<false,true> > lk( m._lock ); m._first = sizeof( _master ); m._nm = 0; _fheader& h = *new ( reinterpret_cast<char *>(&m) + sizeof(_master) ) _fheader(); @@ -535,7 +535,7 @@ n = max( n + (__align - n % __align) % __align, sizeof(_fheader) ); _master *m = reinterpret_cast<_master *>( _seg.address() ); if ( m != reinterpret_cast<_master *>(-1) && (reinterpret_cast<char *>(p) - reinterpret_cast<char *>(_seg.address())) < (_seg.max_size() + sizeof(_master) + sizeof(_aheader) ) ) { - xmt::__Locker<xmt::__Mutex<false,true> > lk( m->_lock ); + xmt::basic_lock<xmt::__mutex<false,true> > lk( m->_lock ); _aheader *a = reinterpret_cast<_aheader *>( reinterpret_cast<char *>(p) - sizeof(_aheader) ); size_type off = reinterpret_cast<char *>(p) - reinterpret_cast<char *>(_seg.address()); if ( m->_first == 0 ) { Modified: trunk/complement/explore/include/mt/thr_mgr.h =================================================================== --- trunk/complement/explore/include/mt/thr_mgr.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/mt/thr_mgr.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -46,7 +46,7 @@ protected: _Sequence _M_c; - Mutex _lock; + mutex _lock; }; } // namespace xmt Modified: trunk/complement/explore/include/mt/xmt.h =================================================================== --- trunk/complement/explore/include/mt/xmt.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/mt/xmt.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 20:09:11 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:37:57 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -56,34 +56,16 @@ #ifdef _REENTRANT -# define MT_REENTRANT(point,nm) xmt::Locker nm(point) -# define MT_REENTRANT_RS(point,nm) xmt::LockerRS nm(point) -# define MT_REENTRANT_SDS(point,nm) xmt::LockerSDS nm(point) // obsolete, use MT_REENTRANT_RS +# define MT_REENTRANT(point,nm) xmt::scoped_lock nm(point) # define MT_LOCK(point) point.lock() # define MT_UNLOCK(point) point.unlock() -# ifdef __FIT_RWLOCK -# define MT_REENTRANT_RD(point,nm) xmt::LockerRd nm(point) -# define MT_REENTRANT_WR(point,nm) xmt::LockerWr nm(point) -# define MT_LOCK_RD(point) point.rdlock() -# define MT_LOCK_WR(point) point.wrlock() -# else // !__FIT_RWLOCK -# define MT_REENTRANT_RD(point,nm) ((void)0) -# define MT_REENTRANT_WR(point,nm) ((void)0) -# define MT_LOCK_RD(point) ((void)0) -# define MT_LOCK_WR(point) ((void)0) -# endif // __FIT_RWLOCK #else // !_REENTRANT # define MT_REENTRANT(point,nm) ((void)0) # define MT_REENTRANT_RS(point,nm) ((void)0) -# define MT_REENTRANT_SDS(point,nm) ((void)0) // obsolete, use MT_REENTRANT_RS # define MT_LOCK(point) ((void)0) # define MT_UNLOCK(point) ((void)0) -# define MT_REENTRANT_RD(point,nm) ((void)0) -# define MT_REENTRANT_WR(point,nm) ((void)0) -# define MT_LOCK_RD(point) ((void)0) -# define MT_LOCK_WR(point) ((void)0) #endif // _REENTRANT @@ -121,6 +103,32 @@ namespace xmt { + +// Exceptions + +// class thread_exit; +// class thread_cancel: public thread_exit; +// class thread_error: public exception; + +class lock_error : + public std::exception +{ + private: + int r_; + + public: + + explicit lock_error( int r ) : + r_( r ) + { } + + virtual char const *what() throw() + { return "std::lock_error"; } + + int error() const + { return r_; } +}; + namespace detail { #ifdef __FIT_PSHARED_MUTEX @@ -174,7 +182,7 @@ #endif // !_WIN32 -template <bool SCOPE> class __Condition; +template <bool SCOPE> class __condition; // if parameter SCOPE (process scope) true, PTHREAD_PROCESS_SHARED will // be used; otherwise PTHREAD_PROCESS_PRIVATE. @@ -256,7 +264,7 @@ #ifndef __FIT_WIN32THREADS private: - friend class __Condition<SCOPE>; + friend class __condition<SCOPE>; #endif }; @@ -288,23 +296,23 @@ #endif // __FIT_PTHREAD_SPINLOCK -// Portable Mutex implementation. If the parameter RECURSIVE_SAFE -// is true, Mutex will be recursive safe (detect deadlock). +// Portable mutex implementation. If the parameter RECURSIVE_SAFE +// is true, mutex will be recursive safe (detect deadlock). // If RECURSIVE_SAFE is false, implementation may not to be // recursive-safe. -// The SCOPE parameter designate Mutex scope---shared between +// The SCOPE parameter designate mutex scope---shared between // processes (true), or only inside threads of one process (false). // Note, that not all OS support interprocess mutex scope // (for example, Windows and Linux). template <bool RECURSIVE_SAFE, bool SCOPE> -class __Mutex : +class __mutex : public __mutex_base<RECURSIVE_SAFE,SCOPE> { public: - __Mutex() + __mutex() { } - ~__Mutex() + ~__mutex() { } void lock() @@ -321,7 +329,7 @@ } #if !defined( WIN32 ) || (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400) - int trylock() + int try_lock() { #ifdef _PTHREADS return pthread_mutex_trylock( &this->_M_lock ); @@ -352,29 +360,29 @@ } private: - __Mutex( const __Mutex& ) + __mutex( const __mutex& ) { } #ifndef __FIT_WIN32THREADS private: - friend class __Condition<SCOPE>; + friend class __condition<SCOPE>; #endif }; #ifdef __FIT_PTHREAD_SPINLOCK // Spinlock-based locks (IEEE Std. 1003.1j-2000) -template <bool RS, bool SCOPE> class __Spinlock; +template <bool RS, bool SCOPE> class __spinlock; template <bool SCOPE> -class __Spinlock<false,SCOPE> : +class __spinlock<false,SCOPE> : public __spinlock_base<SCOPE> { public: - __Spinlock() + __spinlock() { } - ~__Spinlock() + ~__spinlock() { } void lock() @@ -384,7 +392,7 @@ # endif } - int trylock() + int try_lock() { # ifdef _PTHREADS return pthread_spin_trylock( &this->_M_lock ); @@ -400,17 +408,22 @@ pthread_spin_unlock( &this->_M_lock ); # endif } + + private: + __spinlock( const __spinlock& ) + { } + }; template <bool SCOPE> -class __Spinlock<true,SCOPE> : // Recursive safe +class __spinlock<true,SCOPE> : // Recursive safe public __spinlock_base<SCOPE> { public: - __Spinlock() + __spinlock() { } - ~__Spinlock() + ~__spinlock() { } void lock() @@ -434,7 +447,7 @@ # endif // !_NOTHREADS } - int trylock() + int try_lock() { # ifdef _NOTHREADS return 0; @@ -485,6 +498,10 @@ # ifdef __FIT_UITHREADS thread_t _id; # endif + + private: + __spinlock( const __spinlock& ) + { } }; #endif // __FIT_PTHREAD_SPINLOCK @@ -505,11 +522,11 @@ // __mutex_base above). template <bool SCOPE> -class __Mutex<true,SCOPE> : // Recursive Safe +class __mutex<true,SCOPE> : // Recursive Safe public __mutex_base<true,SCOPE> { public: - __Mutex() : + __mutex() : _count( 0 ), # ifdef __FIT_UITHREADS _id( __STATIC_CAST(thread_t,-1) ) @@ -519,7 +536,7 @@ # endif { } - ~__Mutex() + ~__mutex() { } void lock() @@ -549,11 +566,11 @@ // Equivalent to lock(), except that if the mutex object referenced // by mutex is currently locked the call return immediately. // If mutex is currently owned by the calling thread, the mutex lock count - // incremented by one and the trylock() function immediately return success + // incremented by one and the try_lock() function immediately return success // (value 0). Otherwise, if mutex is currently owned by another thread, // return error (non-zero). - int trylock() + int try_lock() { # ifdef _NOTHREADS return 0; @@ -602,7 +619,7 @@ } private: - __Mutex( const __Mutex& ) + __mutex( const __mutex& ) { } protected: @@ -623,10 +640,10 @@ // Read-write mutex: IEEE Std 1003.1, 2001, 2004 Editions template <bool SCOPE> -class __mutex_rw_base +class __rw_mutex_base { public: - __mutex_rw_base() + __rw_mutex_base() { #ifdef _PTHREADS if ( SCOPE ) { @@ -659,7 +676,7 @@ #endif } - ~__mutex_rw_base() + ~__rw_mutex_base() { #ifdef _PTHREADS pthread_rwlock_destroy( &_M_lock ); @@ -675,7 +692,7 @@ } private: - __mutex_rw_base( const __mutex_rw_base& ) + __rw_mutex_base( const __rw_mutex_base& ) { } protected: @@ -693,14 +710,14 @@ }; template <bool SCOPE> -class __MutexRW : - public __mutex_rw_base<SCOPE> +class __rw_mutex : + public __rw_mutex_base<SCOPE> { public: - __MutexRW() + __rw_mutex() { } - ~__MutexRW() + ~__rw_mutex() { } void rdlock() @@ -718,7 +735,7 @@ #endif } - void wrlock() + void lock() { #ifdef _PTHREADS pthread_rwlock_wrlock( &this->_M_lock ); @@ -734,7 +751,7 @@ } #if !defined( WIN32 ) || (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400) - int tryrdlock() + int try_rdlock() { #ifdef _PTHREADS return pthread_rwlock_tryrdlock( &this->_M_lock ); @@ -753,7 +770,7 @@ #endif } - int trywrlock() + int try_lock() { #ifdef _PTHREADS return pthread_rwlock_trywrlock( &this->_M_lock ); @@ -790,96 +807,124 @@ } private: - __MutexRW( const __MutexRW& ) + __rw_mutex( const __rw_mutex& ) { } }; #endif // __FIT_RWLOCK template <class M> -class __Locker +class basic_lock { public: - __Locker( const M& point ) : - m( point ) - { const_cast<M&>(m).lock(); } - ~__Locker() - { const_cast<M&>(m).unlock(); } + basic_lock( const M& point, bool initially_locked = true ) : + m( point ), + lk( false ) + { if ( initially_locked ) lock(); } + ~basic_lock() + { if ( lk ) const_cast<M&>(m).unlock(); } + void lock() + { + if ( lk ) { + throw lock_error( 0 ); + } + const_cast<M&>(m).lock(); + lk = true; + } + + void unlock() + { + if ( !lk ) { + throw lock_error( 0 ); + } + lk = false; + const_cast<M&>(m).unlock(); + } + private: - __Locker( const __Locker& ) + basic_lock( const basic_lock& ) { } + basic_lock& operator =( const basic_lock& ) + { return *this; } + const M& m; + bool lk; }; #ifdef __FIT_RWLOCK -template <bool SCOPE> -class __LockerRd +template <class M> +class basic_read_lock { public: - __LockerRd( const __MutexRW<SCOPE>& point ) : - m( point ) - { const_cast<__MutexRW<SCOPE>&>(m).rdlock(); } - ~__LockerRd() - { const_cast<__MutexRW<SCOPE>&>(m).unlock(); } + basic_read_lock( const M& point, bool initially_locked = true ) : + m( point ), + lk( false ) + { if ( initially_locked ) lock(); } + ~basic_read_lock() + { if ( lk ) const_cast<M&>(m).unlock(); } - private: - __LockerRd( const __LockerRd& ) - { } - const __MutexRW<SCOPE>& m; -}; + void lock() + { + if ( lk ) { + throw lock_error( 0 ); + } + const_cast<M&>(m).rdlock(); + lk = true; + } -template <bool SCOPE> -class __LockerWr -{ - public: - __LockerWr( const __MutexRW<SCOPE>& point ) : - m( point ) - { const_cast<__MutexRW<SCOPE>&>(m).wrlock(); } - ~__LockerWr() - { const_cast<__MutexRW<SCOPE>&>(m).unlock(); } + void unlock() + { + if ( !lk ) { + throw lock_error( 0 ); + } + lk = false; + const_cast<M&>(m).unlock(); + } private: - __LockerWr( const __LockerWr& ) + basic_read_lock( const basic_read_lock& ) { } - const __MutexRW<SCOPE>& m; + basic_read_lock& operator =( const basic_read_lock& ) + { return *this; } + + const M& m; + bool lk; }; #endif // __FIT_RWLOCK -typedef __Mutex<false,false> Mutex; -typedef __Mutex<true,false> MutexRS; -typedef __Mutex<true,false> MutexSDS; // obsolete, use instead MutexRS +typedef __mutex<false,false> mutex; +typedef __mutex<true,false> recursive_mutex; #ifdef __FIT_RWLOCK -typedef __MutexRW<false> MutexRW; +typedef __rw_mutex<false> rw_mutex; #endif // __FIT_RWLOCK #ifdef __FIT_PTHREAD_SPINLOCK -typedef __Spinlock<false,false> Spinlock; -typedef __Spinlock<true,false> SpinlockRS; +typedef __spinlock<false,false> spinlock; +typedef __spinlock<true,false> recursive_spinlock; #endif // __FIT_RWLOCK -typedef __Locker<Mutex> Locker; -typedef __Locker<MutexRS> LockerRS; -typedef __Locker<MutexRS> LockerSDS; // obsolete, use instead LockerRS +typedef basic_lock<mutex> scoped_lock; +typedef basic_lock<recursive_mutex> recursive_scoped_lock; #ifdef __FIT_RWLOCK -typedef __LockerRd<false> LockerRd; -typedef __LockerWr<false> LockerWr; +typedef basic_read_lock<__rw_mutex<false> > rd_scoped_lock; +typedef basic_lock<__rw_mutex<false> > wr_scoped_lock; #endif // __FIT_RWLOCK #ifdef __FIT_PTHREAD_SPINLOCK -typedef __Locker<Spinlock> LockerSpin; -typedef __Locker<SpinlockRS> LockerSpinRS; +typedef basic_lock<spinlock> spin_scoped_lock; +typedef basic_lock<recursive_spinlock> recursive_spin_scoped_lock; #endif // __FIT_RWLOCK -class LockerExt +class native_scoped_lock { public: #ifdef _PTHREADS - explicit LockerExt( const pthread_mutex_t& m ) : + explicit native_scoped_lock( const pthread_mutex_t& m ) : #endif #ifdef __FIT_UITHREADS - explicit LockerExt( const mutex_t& m ) : + explicit native_scoped_lock( const mutex_t& m ) : #endif #ifdef __FIT_WIN32THREADS - explicit LockerExt( const CRITICAL_SECTION& m ) : + explicit native_scoped_lock( const CRITICAL_SECTION& m ) : #endif _M_lock( m ) { @@ -894,7 +939,7 @@ #endif } - ~LockerExt() + ~native_scoped_lock() { #ifdef _PTHREADS pthread_mutex_unlock( const_cast<pthread_mutex_t *>(&_M_lock) ); @@ -908,7 +953,7 @@ } private: - LockerExt( const LockerExt& m ) : + native_scoped_lock( const native_scoped_lock& m ) : _M_lock( m._M_lock ) { } #ifdef _PTHREADS @@ -923,10 +968,10 @@ }; template <bool SCOPE> -class __Condition +class __condition { public: - __Condition() : + __condition() : _val( true ) { #ifdef __FIT_WIN32THREADS @@ -948,7 +993,7 @@ #endif } - ~__Condition() + ~__condition() { #ifdef __FIT_WIN32THREADS CloseHandle( _cond ); @@ -963,7 +1008,7 @@ bool set( bool __v, bool _broadcast = false ) { - __Locker<__Mutex<false,SCOPE> > _x1( _lock ); + basic_lock<__mutex<false,SCOPE> > _x1( _lock ); bool tmp = _val; _val = __v; @@ -1000,15 +1045,11 @@ int try_wait() { -#if defined(__FIT_WIN32THREADS) - _lock.lock(); -#endif -#if defined(__FIT_UITHREADS) || defined(_PTHREADS) - __Locker<__Mutex<false,SCOPE> > _x1( _lock ); -#endif + basic_lock<__mutex<false,SCOPE> > _x1( _lock ); + if ( _val == false ) { #ifdef __FIT_WIN32THREADS - _lock.unlock(); + _x1.unlock(); if ( WaitForSingleObject( _cond, -1 ) == WAIT_FAILED ) { return -1; } @@ -1028,27 +1069,24 @@ return ret; #endif } -#if defined(__FIT_WIN32THREADS) - _lock.unlock(); -#endif + return 0; } int wait() { + basic_lock<__mutex<false,SCOPE> > lk( _lock ); + _val = false; + #ifdef __FIT_WIN32THREADS - MT_LOCK( _lock ); - _val = false; ResetEvent( _cond ); - MT_UNLOCK( _lock ); + lk.unlock(); if ( WaitForSingleObject( _cond, -1 ) == WAIT_FAILED ) { return -1; } return 0; #endif #if defined(_PTHREADS) || defined(__FIT_UITHREADS) - __Locker<__Mutex<false,SCOPE> > lk( _lock ); - _val = false; int ret; while ( !_val ) { ret = @@ -1085,7 +1123,7 @@ int signal( bool _broadcast = false ) { - __Locker<__Mutex<false,SCOPE> > _x1( _lock ); + basic_lock<__mutex<false,SCOPE> > _x1( _lock ); _val = true; #ifdef __FIT_WIN32THREADS @@ -1112,21 +1150,21 @@ #ifdef __FIT_UITHREADS cond_t _cond; #endif - __Mutex<false,SCOPE> _lock; + __mutex<false,SCOPE> _lock; bool _val; private: - __Condition( const __Condition& ) + __condition( const __condition& ) { } }; -typedef __Condition<false> Condition; +typedef __condition<false> condition; template <bool SCOPE> -class __Semaphore +class __semaphore { public: - __Semaphore( int cnt = 1 ) + __semaphore( int cnt = 1 ) { #ifdef __FIT_WIN32THREADS _sem = CreateSemaphore( NULL, cnt, INT_MAX, 0 ); // check! @@ -1140,7 +1178,7 @@ #endif } - ~__Semaphore() + ~__semaphore() { #ifdef __FIT_WIN32THREADS CloseHandle( _sem ); @@ -1232,14 +1270,14 @@ sem_t _sem; #endif private: - __Semaphore( const __Semaphore& ) + __semaphore( const __semaphore& ) { } }; -typedef __Semaphore<false> Semaphore; +typedef __semaphore<false> semaphore; template <bool SCOPE> -int __Semaphore<SCOPE>::wait_time( const ::timespec *abstime ) // wait for time t, or signal +int __semaphore<SCOPE>::wait_time( const ::timespec *abstime ) // wait for time t, or signal { #ifdef __FIT_WIN32THREADS time_t ct = time( 0 ); @@ -1265,7 +1303,7 @@ } template <bool SCOPE> -int __Semaphore<SCOPE>::wait_delay( const ::timespec *interval ) // wait, timeout is delay t, or signal +int __semaphore<SCOPE>::wait_delay( const ::timespec *interval ) // wait, timeout is delay t, or signal { #ifdef __FIT_WIN32THREADS unsigned ms = interval->tv_sec * 1000 + interval->tv_nsec / 1000000; @@ -1291,10 +1329,10 @@ } template <bool SCOPE> -class __Barrier +class __barrier { public: - __Barrier( unsigned cnt = 2 ) + __barrier( unsigned cnt = 2 ) { #ifdef _PTHREADS pthread_barrierattr_t attr; @@ -1305,7 +1343,7 @@ #endif } - ~__Barrier() + ~__barrier() { #ifdef _PTHREADS pthread_barrier_destroy( &_barr ); @@ -1325,7 +1363,7 @@ #endif }; -typedef __Barrier<false> Barrier; +typedef __barrier<false> barrier; __FIT_DECLSPEC void fork() throw( fork_in_parent, std::runtime_error ); __FIT_DECLSPEC void become_daemon() throw( fork_in_parent, std::runtime_error ); @@ -1471,7 +1509,7 @@ static alloc_type alloc; static int _idx; // user words index static int _self_idx; // user words index, that word point to self - static Mutex _idx_lock; + static mutex _idx_lock; static thread_key_type& _mt_key; size_t uw_alloc_size; @@ -1481,7 +1519,7 @@ # ifndef __hpux // sorry, POSIX threads don't have suspend/resume calls, so it should // be simulated via cond_wait - __Condition<false> _suspend; + __condition<false> _suspend; # endif #endif #ifdef __FIT_WIN32THREADS @@ -1492,7 +1530,7 @@ size_t _param_sz; unsigned _flags; size_t _stack_sz; // stack size, if not 0 - // Mutex _llock; + // mutex _llock; friend class Init; // extern "C", wrap for thread_create #ifdef __unix @@ -1504,13 +1542,13 @@ }; template <bool SCOPE> -int __Condition<SCOPE>::try_wait_time( const ::timespec *abstime ) +int __condition<SCOPE>::try_wait_time( const ::timespec *abstime ) { #if defined(__FIT_WIN32THREADS) MT_LOCK( _lock ); #endif #if defined(__FIT_UITHREADS) || defined(_PTHREADS) - MT_REENTRANT( _lock, _x1 ); + scoped_lock _x1( _lock ); #endif if ( _val == false ) { #ifdef __FIT_WIN32THREADS @@ -1560,13 +1598,13 @@ } template <bool SCOPE> -int __Condition<SCOPE>::try_wait_delay( const ::timespec *interval ) +int __condition<SCOPE>::try_wait_delay( const ::timespec *interval ) { #if defined(__FIT_WIN32THREADS) MT_LOCK( _lock ); #endif #if defined(__FIT_UITHREADS) || defined(_PTHREADS) - MT_REENTRANT( _lock, _x1 ); + scoped_lock _x1( _lock ); #endif if ( _val == false ) { #ifdef WIN32 @@ -1622,7 +1660,7 @@ } template <bool SCOPE> -int __Condition<SCOPE>::wait_time( const ::timespec *abstime ) +int __condition<SCOPE>::wait_time( const ::timespec *abstime ) { #ifdef __FIT_WIN32THREADS MT_LOCK( _lock ); @@ -1642,7 +1680,7 @@ return 0; #endif #ifdef _PTHREADS - MT_REENTRANT( _lock, _x1 ); // ?? + scoped_lock _x1( _lock ); // ?? _val = false; int ret = pthread_cond_timedwait( &_cond, &_lock._M_lock, abstime ); if ( ret == ETIMEDOUT ) { @@ -1651,7 +1689,7 @@ return ret; #endif // _PTHREADS #ifdef __FIT_UITHREADS - MT_REENTRANT( _lock, _x1 ); + scoped_lock _x1( _lock ); _val = false; int ret; while ( !_val ) { @@ -1672,7 +1710,7 @@ } template <bool SCOPE> -int __Condition<SCOPE>::wait_delay( const ::timespec *interval ) +int __condition<SCOPE>::wait_delay( const ::timespec *interval ) { #ifdef __FIT_WIN32THREADS MT_LOCK( _lock ); Modified: trunk/complement/explore/include/sockios/sockmgr.cc =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/sockios/sockmgr.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/01 19:50:14 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 21:14:42 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -29,7 +29,7 @@ template <class Connect> void sockmgr_stream_MP<Connect>::_open( sock_base::stype t ) { - MT_REENTRANT( _fd_lck, _1 ); + xmt::scoped_lock lk(_fd_lck); if ( is_open_unsafe() ) { if ( t == sock_base::sock_stream ) { _accept = &_Self_type::accept_tcp; @@ -100,7 +100,7 @@ // cerr << __FILE__ << ":" << __LINE__ << endl; // } if ( j->revents != 0 ) { - xmt::Locker _l( _c_lock ); + xmt::scoped_lock _l( _c_lock ); // We should distinguish closed socket from income message typename container_type::iterator i = find_if( _M_c.begin(), _M_c.end(), bind2nd( _M_comp, j->fd ) ); @@ -204,7 +204,7 @@ } if ( _pfd[0].revents != 0 ) { - MT_REENTRANT( _fd_lck, _1 ); + xmt::scoped_lock lk(_fd_lck); if ( !is_open_unsafe() ) { // may be already closed return false; } @@ -217,14 +217,14 @@ } try { - xmt::Locker _l( _c_lock ); + xmt::scoped_lock _l( _c_lock ); _M_c.push_back( _Connect() ); _M_c.back().open( _sd, addr.any ); _Connect *cl_new = &_M_c.back(); if ( cl_new->s.rdbuf()->in_avail() > 0 ) { // this is the case when user read from sockstream // in ctor above; push processing of this stream - MT_REENTRANT( _dlock, _1 ); + xmt::scoped_lock lk(_dlock); _conn_pool.push_back( --_M_c.end() ); _pool_cnd.set( true ); _observer_cnd.set( true ); @@ -404,7 +404,7 @@ if ( stream.is_open() && stream.good() ) { if ( stream.rdbuf()->in_avail() > 0 ) { // socket has buffered data, push it back to queue - MT_REENTRANT( me->_dlock, _1 ); + xmt::scoped_lock lk(me->_dlock); me->_conn_pool.push_back( c ); me->_observer_cnd.set( true ); me->_pool_cnd.set( true ); @@ -418,7 +418,7 @@ me->_conn_pool.erase( std::remove( me->_conn_pool.begin(), me->_conn_pool.end(), c ), me->_conn_pool.end() ); me->_dlock.unlock(); - xmt::Locker _l( me->_c_lock ); + xmt::scoped_lock _l( me->_c_lock ); me->_M_c.erase( c ); } } @@ -428,7 +428,7 @@ for ( idle_count = 0; idle_count < 2; ++idle_count ) { { - MT_REENTRANT( me->_dlock, _1 ); + xmt::scoped_lock lk(me->_dlock); if ( !me->_follow ) { break; } @@ -481,7 +481,7 @@ // std::swap( pool_size[0], pool_size[1] ); std::rotate( pool_size, pool_size, pool_size + 3 ); { - MT_REENTRANT( me->_dlock, _1 ); + xmt::scoped_lock lk(me->_dlock); pool_size[2] = static_cast<int>(me->_conn_pool.size()); tpop = me->_tpop; } @@ -535,7 +535,7 @@ template <class Connect> void sockmgr_stream_MP_SELECT<Connect>::_open( sock_base::stype t ) { - MT_REENTRANT( _fd_lck, _1 ); + xmt::scoped_lock lk(_fd_lck); if ( is_open_unsafe() ) { if ( t == sock_base::sock_stream ) { _accept = &_Self_type::accept_tcp; @@ -655,11 +655,11 @@ FD_ZERO( &_pfde ); // *** Set all listen sockets here... - MT_LOCK( _fd_lck ); + _fd_lck.lock(); FD_SET( fd_unsafe(), &_pfdr ); FD_SET( fd_unsafe(), &_pfde ); _fdmax = fd_unsafe(); - MT_UNLOCK( _fd_lck ); + _fd_lck.unlock(); for ( typename container_type::iterator i = _M_c.begin(); i != _M_c.end(); ++i ) { if ( (*i)->s->is_open() ) { FD_SET( (*i)->s->rdbuf()->fd(), &_pfdr ); @@ -677,7 +677,7 @@ return 0; // poll wait infinite, so it can't return 0 (timeout), so it return -1. } - MT_REENTRANT( _fd_lck, _1 ); + xmt::scoped_lock lk(_fd_lck); if ( !is_open_unsafe() || FD_ISSET( fd_unsafe(), &_pfde ) ) { // may be already closed return 0; } Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/02/12 14:50:57 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 20:57:31 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005-2007 @@ -85,19 +85,19 @@ public: bool is_open() const - { MT_REENTRANT( _fd_lck, _1 ); return is_open_unsafe(); } + { xmt::scoped_lock lk(_fd_lck); return is_open_unsafe(); } bool good() const { return _state == ios_base::goodbit; } sock_base::socket_type fd() const - { MT_REENTRANT( _fd_lck, _1 ); return fd_unsafe(); } + { xmt::scoped_lock lk(_fd_lck); return fd_unsafe(); } __FIT_DECLSPEC void shutdown( sock_base::shutdownflg dir ); void setoptions( sock_base::so_t optname, bool on_off = true, int __v = 0 ) { - MT_REENTRANT( _fd_lck, _1 ); + xmt::scoped_lock lk(_fd_lck); setoptions_unsafe( optname, on_off, __v ); } @@ -113,8 +113,8 @@ friend class Init; protected: - xmt::Mutex _fd_lck; - xmt::Condition _loop_cnd; + xmt::mutex _fd_lck; + xmt::condition _loop_cnd; }; class ConnectionProcessorTemplate_MP // As reference @@ -288,19 +288,19 @@ _Sequence _M_c; _Compare _M_comp; pfd_equal _pfdcomp; - xmt::Mutex _c_lock; + xmt::mutex _c_lock; _fd_sequence _pfd; int _cfd; // sock_base::socket_type _connect_pool_sequence _conn_pool; - xmt::Condition _pool_cnd; - xmt::Mutex _dlock; + xmt::condition _pool_cnd; + xmt::mutex _dlock; timespec _tpop; - xmt::Mutex _flock; + xmt::mutex _flock; bool _follow; - xmt::Condition _observer_cnd; + xmt::condition _observer_cnd; timespec _busylimit; // start new thread to process incoming // requests, if processing thread busy // more then _busylimit @@ -419,7 +419,7 @@ _Sequence _M_c; _Compare _M_comp; in_buf_avail _M_av; - xmt::Mutex _c_lock; + xmt::mutex _c_lock; fd_set _pfdr; fd_set _pfde; Modified: trunk/complement/explore/include/sockios/sockstream =================================================================== --- trunk/complement/explore/include/sockios/sockstream 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/sockios/sockstream 2007-07-11 21:01:08 UTC (rev 1606) @@ -546,8 +546,8 @@ virtual streamsize xsputn(const char_type *s, streamsize n); public: - xmt::Mutex _M_lock_w; // lock for writing - // _STL_mutex_base _M_lock; used for read lock + xmt::mutex _M_lock_w; // lock for writing + private: // Helper functions charT* _bbuf; charT* _ebuf; Modified: trunk/complement/explore/include/stem/Cron.h =================================================================== --- trunk/complement/explore/include/stem/Cron.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/stem/Cron.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,7 +1,7 @@ -// -*- C++ -*- Time-stamp: <06/12/15 03:20:55 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 21:20:12 ptr> /* - * Copyright (c) 1998, 2002, 2003, 2005 + * Copyright (c) 1998, 2002, 2003, 2005, 2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -18,9 +18,7 @@ #include <config/feature.h> #endif -#ifndef __IOSFWD__ #include <iosfwd> -#endif #ifndef __stem_EventHandler_h #include <stem/EventHandler.h> @@ -157,7 +155,7 @@ static xmt::Thread::ret_code _loop( void * ); xmt::Thread _thr; - xmt::Condition cond; + xmt::condition cond; typedef __CronEntry value_type; typedef std::priority_queue<value_type, @@ -165,7 +163,7 @@ std::greater<value_type> > container_type; container_type _M_c; - xmt::Mutex _M_l; + xmt::mutex _M_l; private: DECLARE_RESPONSE_TABLE( Cron, EventHandler ); Modified: trunk/complement/explore/include/stem/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/stem/EvManager.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 17:18:41 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 21:17:27 ptr> /* * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 @@ -123,31 +123,31 @@ bool is_avail( addr_type id ) const { - MT_REENTRANT( _lock_heap, _x1 ); + xmt::scoped_lock lk( _lock_heap ); return unsafe_is_avail(id); } const std::string who_is( addr_type id ) const { - MT_REENTRANT( _lock_iheap, _x1 ); + xmt::scoped_lock lk( _lock_iheap ); return unsafe_who_is( id ); } const std::string annotate( addr_type id ) const { - MT_REENTRANT( _lock_iheap, _x1 ); + xmt::scoped_lock lk( _lock_iheap ); return unsafe_annotate( id ); } void change_announce( addr_type id, const std::string& info ) { - MT_REENTRANT( _lock_iheap, _x1 ); + xmt::scoped_lock lk( _lock_iheap ); unsafe_change_announce( id, info ); } void change_announce( addr_type id, const char *info ) { - MT_REENTRANT( _lock_iheap, _x1 ); + xmt::scoped_lock lk( _lock_iheap ); unsafe_change_announce( id, info ); } @@ -155,7 +155,7 @@ void push( const Event& e ) { - MT_REENTRANT( _lock_queue, _x1 ); + xmt::scoped_lock lk( _lock_queue ); in_ev_queue.push_back( e ); _cnd_queue.set( true ); } @@ -246,17 +246,17 @@ bool _dispatch_stop; xmt::Thread _ev_queue_thr; - xmt::Spinlock _ev_queue_dispatch_guard; + xmt::spinlock _ev_queue_dispatch_guard; - xmt::Mutex _lock_heap; - xmt::Mutex _lock_iheap; - xmt::Mutex _lock_xheap; + xmt::mutex _lock_heap; + xmt::mutex _lock_iheap; + xmt::mutex _lock_xheap; - xmt::Mutex _lock_queue; - xmt::Condition _cnd_queue; + xmt::mutex _lock_queue; + xmt::condition _cnd_queue; static std::string inv_key_str; - xmt::Mutex _lock_tr; + xmt::mutex _lock_tr; unsigned _trflags; std::ostream *_trs; Modified: trunk/complement/explore/include/stem/EventHandler.h =================================================================== --- trunk/complement/explore/include/stem/EventHandler.h 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/include/stem/EventHandler.h 2007-07-11 21:01:08 UTC (rev 1606) @@ -542,7 +542,7 @@ // See comment near EventHandler::EventHandler() implementation // HistoryContainer& theHistory; HistoryContainer theHistory; - xmt::MutexRS _theHistory_lock; + xmt::recursive_mutex _theHistory_lock; public: @@ -705,7 +705,7 @@ { theEventsTable.Out( out ); } \ virtual bool DispatchTrace( const stem::Event& __e, std::ostream& __s )\ { \ - MT_REENTRANT_SDS( this->_theHistory_lock, _x1 ); \ + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); \ return theEventsTable.DispatchTrace( theHistory.begin(), \ theHistory.end(), __e, __s ); } \ virtual const std::type_info& classtype() const \ @@ -718,12 +718,12 @@ protected: \ virtual bool Dispatch( const stem::Event& __e ) \ { \ - MT_REENTRANT_SDS( this->_theHistory_lock, _x1 ); \ + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); \ return theEventsTable.Dispatch( this, theHistory.begin(), \ theHistory.end(), __e ); } \ virtual bool DispatchStub( const stem::Event& __e ) \ { \ - MT_REENTRANT_SDS( this->_theHistory_lock, _x1 ); \ + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); \ return theEventsTable.DispatchStub( this, theHistory.begin(), \ theHistory.end(), __e ); } \ static __FIT_DECLSPEC evtable_type theEventsTable; \ Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,3 +1,35 @@ +2007-07-12 Petr Ovtchenkov <pt...@is...> + + * libxmt: version 1.11.0 + +2007-07-11 Petr Ovtchenkov <pt...@is...> + + * xmt.h, shm.h: Condition replaced by condition; + + * xmt.h, shm.h: Barrier replaced by barrier, Semaphore by semaphore. + +2007-06-29 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc, uid.cc, thr_mgr.cc: replace Locker by scoped_lock. + + * shm.h, xmt.h, xmt.cc, thr_mgr.h, uid.cc, time.cc: all Mutex replaced by mutex; + + * xmt.h: mutexRS renamed to recursive_mutex; LockerRS renamed to + recursive_scoped_lock; obsolete LockerSDS removed; + + * xmt.h: LockerRd renamed to rd_scoped_lock, LockerWr to wr_scoped_lock, + __mutex_rw_base to __rw_mutex_base, mutexRW to rw_mutex; + + * xmt.h: Spinlock was renamed to spinlock, LockerExt to native_scoped_lock. + +2007-06-14 Petr Ovtchenkov <pt...@is...> + + * xmt.h, xmt.cc, shm.h: step to interface like boost or + http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2007/n2178.html; + Locker* changed to basic_lock or basic_read_lock, internal lock flag + added, lock/unlock methods added to basic_*_lock and exception + lock_error added too. + 2007-03-12 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc: code for Novell NetWare removed. Modified: trunk/complement/explore/lib/mt/Makefile.inc =================================================================== --- trunk/complement/explore/lib/mt/Makefile.inc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/Makefile.inc 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,8 +1,8 @@ -# -*- Makefile -*- Time-stamp: <07/03/12 20:14:01 ptr> +# -*- Makefile -*- Time-stamp: <07/07/12 00:51:47 ptr> LIBNAME = xmt MAJOR = 1 -MINOR = 10 -PATCH = 3 +MINOR = 11 +PATCH = 0 SRC_CC = xmt.cc thr_mgr.cc time.cc uid.cc shm.cc SRC_C = fl.c Modified: trunk/complement/explore/lib/mt/thr_mgr.cc =================================================================== --- trunk/complement/explore/lib/mt/thr_mgr.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/thr_mgr.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -121,7 +121,7 @@ __FIT_DECLSPEC void ThreadMgr::launch( Thread::entrance_type entrance, const void *p, size_t psz, unsigned flags, size_t stack_sz ) { - Locker lk( _lock ); + scoped_lock lk( _lock ); _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); // Thread *t = new Thread( entrance, p, psz, flags, stack_sz ); // cerr << (void *)t << " created\n"; @@ -132,13 +132,13 @@ __FIT_DECLSPEC void ThreadMgr::garbage_collector() { - Locker lk( _lock ); + scoped_lock lk( _lock ); _M_c.erase( remove_if( _M_c.begin(), _M_c.end(), rm_if_bad_thread() ), _M_c.end() ); } ThreadMgr::container_type::size_type ThreadMgr::size() const { - Locker lk( _lock ); + scoped_lock lk( _lock ); // ThreadMgr::container_type::size_type sz = count_if( _M_c.begin(), _M_c.end(), good_thread() ); // cerr << "Sz: " << sz << endl; @@ -148,7 +148,7 @@ __FIT_DECLSPEC void ThreadMgr::signal( int sig ) { // cerr << "Signal!" << endl; - Locker lk( _lock ); + scoped_lock lk( _lock ); for_each( _M_c.begin(), _M_c.end(), bind2nd( thread_signal(), sig ) ); } Modified: trunk/complement/explore/lib/mt/time.cc =================================================================== --- trunk/complement/explore/lib/mt/time.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/time.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -14,7 +14,7 @@ #include <sys/time.h> #ifdef _WIN32 -xmt::Mutex _l; +xmt::mutex _l; #endif std::string calendar_time( time_t t ) Modified: trunk/complement/explore/lib/mt/uid.cc =================================================================== --- trunk/complement/explore/lib/mt/uid.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/uid.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -36,9 +36,9 @@ __uid_init::__uid_init() { - static Mutex _lk; + static mutex _lk; - Locker lock( _lk ); + scoped_lock lock( _lk ); ifstream f( "/proc/sys/kernel/random/boot_id" ); string tmp; Modified: trunk/complement/explore/lib/mt/xmt.cc =================================================================== --- trunk/complement/explore/lib/mt/xmt.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/mt/xmt.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/12 20:14:35 ptr> +// -*- C++ -*- Time-stamp: <07/06/14 10:10:54 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -88,7 +88,7 @@ # endif #ifdef _PTHREADS -xmt::Mutex _F_lock; +xmt::mutex _F_lock; # define _F_locklock xmt::detail::_F_lock.lock(); # define _F_lockunlock xmt::detail::_F_lock.unlock(); #endif @@ -220,7 +220,7 @@ Thread::alloc_type Thread::alloc; int Thread::_idx = 0; int Thread::_self_idx = 0; -Mutex Thread::_idx_lock; +mutex Thread::_idx_lock; #ifdef __FIT_WIN32THREADS const Thread::thread_id_type Thread::bad_thread_id = INVALID_HANDLE_VALUE; @@ -926,7 +926,7 @@ int Thread::xalloc() { - Locker _l( _idx_lock ); + scoped_lock _l( _idx_lock ); return _idx++; } Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,3 +1,18 @@ +2007-07-12 Petr Ovtchenkov <pt...@is...> + + * libsockios: Version 1.12.0 + +2007-07-11 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h, sockmgr.cc: Condition replaced by condition. + +2007-06-29 Petr Ovtchenkov <pt...@is...> + + * sockmgr.cc, sockios_test.cc: replace Locker by scoped_lock. + + * sockmgr.h, sockstream, _sockmgr.cc, _sockstream.cc: all + Mutex replaced by mutex + 2007-02-12 Petr Ovtchenkov <pt...@is...> * sockmgr.h, _sockmgr.cc: use Init technique to initialize Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,8 +1,8 @@ -# -*- Makefile -*- Time-stamp: <07/02/01 19:53:51 ptr> +# -*- Makefile -*- Time-stamp: <07/07/12 00:53:38 ptr> LIBNAME = sockios MAJOR = 1 -MINOR = 11 +MINOR = 12 PATCH = 0 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ Modified: trunk/complement/explore/lib/sockios/_sockmgr.cc =================================================================== --- trunk/complement/explore/lib/sockios/_sockmgr.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/sockios/_sockmgr.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -51,7 +51,7 @@ void basic_sockmgr::Init::_guard( int direction ) { - static xmt::Mutex _init_lock; + static xmt::mutex _init_lock; static int _count = 0; if ( direction ) { Modified: trunk/complement/explore/lib/sockios/_sockstream.cc =================================================================== --- trunk/complement/explore/lib/sockios/_sockstream.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/sockios/_sockstream.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -66,7 +66,7 @@ static int __glob_init_cnt = 0; static int __glob_init_wsock2 = 0; -static xmt::Mutex _SI_lock; +static xmt::mutex _SI_lock; enum { WINDOWS_NT_4, Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-07-11 21:01:08 UTC (rev 1606) @@ -1,5 +1,22 @@ +2007-07-12 Petr Ovtchenkov <pt...@is...> + + * libstem: library version 4.6.0 + +2007-07-11 Petr Ovtchenkov <pt...@is...> + + * EvManager.h, Cron.h: Condition replaced by condition. + 2007-06-29 Petr Ovtchenkov <pt...@is...> + * NetTransport.cc, EvManager.cc: replace Locker by scoped_lock. + + * EvManager.cc, _EventHandler.cc, EventHandler.h, EvManager.h, Cron.h: + all Mutex replaced by mutex + + * EventHandler.h, _EventHandler.cc: mutexRS renamed to recursive_mutex; + LockerRS renamed to recursive_scoped_lock; obsolete LockerSDS + replaced by recursive_scoped_lock; + * _EventHandler.cc: call destructor, don't free memory here; acquire lock (missed lock). Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-07-11 19:56:54 UTC (rev 1605) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-07-11 21:01:08 UTC (rev 1606) @@ -72,7 +72,7 @@ bool EvManager::not_finished() { - xmt::LockerSpin _lk( _ev_queue_dispatch_guard ); + xmt::spin_scoped_lock _lk( _ev_queue_dispatch_guard ); return !_dispatch_stop; } @@ -81,7 +81,7 @@ EvManager& me = *reinterpret_cast<EvManager *>(p); xmt::Thread::ret_code rt; rt.iword = 0; - xmt::Mutex& lq = me._lock_queue; + xmt::mutex& lq = me._lock_queue; queue_type& in_ev_queue = me.in_ev_queue; queue_type& out_ev_queue = me.out_ev_queue; @@ -111,19 +111,19 @@ { addr_type id; { - Locker lk( _lock_heap ); + scoped_lock lk( _lock_heap ); id = create_unique(); heap[id] = object; } { - Locker lk( _lock_xheap ); + scoped_lock lk( _lock_xheap ); gaddr_type& gaddr = _ex_heap[id]; gaddr.hid = xmt::hostid(); gaddr.pid = xmt::getpid(); gaddr.addr = id; } - Locker lk( _lock_iheap ); + scoped_lock lk( _lock_iheap ); iheap[id] = info; return id; @@ -142,21 +142,21 @@ if ( (id & extbit) ) { return badaddr; } else { - Locker _x1( _lock_heap ); + scoped_lock _x1( _lock_heap ); if ( unsafe_is_avail( id ) ) { return badaddr; } heap[id] = object; } { - Locker lk( _lock_xheap ); + scoped_lock lk( _lock_xheap ); gaddr_type& gaddr = _ex_heap[id]; gaddr.hid = xmt::hostid(); gaddr.pid = xmt::getpid(); gaddr.addr = id; } - Locker _x1( _lock_iheap ); + scoped_lock _x1( _lock_iheap ); iheap[id] = info; return id; @@ -176,14 +176,14 @@ { addr_type id; { - Locker _x1( _lock_xheap ); + scoped_lock _x1( _lock_xheap ); id = create_unique_x(); _ex_heap[id] = addr; _tr_heap.insert( make_pair( addr, make_pair( id, tr ) ) ); _ch_heap.insert( make_pair( tr.link, addr ) ); } { - Locker _x1( _lock_iheap ); + scoped_lock _x1( _lock_iheap ); iheap[id] = info; } @@ -205,13 +205,13 @@ addr_type id; if ( addr.hid == xmt::hostid() && addr.pid == xmt::getpid() ) { // local if ( addr.addr & extbit ) { // may be transit object - Locker lk( _lock_xheap ); + scoped_lock lk( _lock_xheap ); pair<uuid_tr_heap_type::const_iterator,uuid_tr_heap_type::const_iterator> range = _tr_heap.equal_range( addr ); if ( range.first != range.second ) { // transport present return min_element( range.first, range.second, tr_compare )->second.first; } } else { // may be local object - Locker lk( _lock_heap ); + scoped_lock lk( _lock_heap ); local_heap_type::const_iterator i = heap.find( addr.addr ); if ( i != heap.end() ) { return i->first; @@ -219,7 +219,7 @@ } return badaddr; // don't know what I can made } else { // foreign object - Locker lk( _lock_xheap ); + scoped_lock lk( _lock_xheap ); pair<uuid_tr_heap_type::const_iterator,uuid_tr_heap_type::const_iterator> tr_range = _tr_heap.equal_range( addr ); if ( tr_range.first != tr_range.second ) { // transport present return min_element( tr_range.first, tr_range.second, tr_compare )->second.first; @@ -239,7 +239,7 @@ _ex_heap[id] = addr; } { - Locker lk( _lock_iheap ); + scoped_lock lk( _lock_iheap ); iheap[id] = info; } return id; @@ -256,7 +256,7 @@ bool EvManager::Unsubscribe( addr_type id ) { if ( (id & extbit) ) { - Locker _x1( _lock_xheap ); + scoped_lock _x1( _lock_xheap ); gaddr_type& addr = _ex_heap[id]; pair<uuid_tr_heap_type::iterator,uuid_tr_heap_type::iterator> range = _tr_heap.equal_range( addr ); @@ -277,12 +277,12 @@ } _ex_heap.erase( id ); } else { - Locker _x1( _lock_heap ); + scoped_lock _x1( _lock_heap ); heap.erase( id ); // Notify remotes? } - Locker _x1( _lock_iheap ); + scoped_lock _x1( _lock_iheap ); iheap.erase( id ); return true; @@ -294,7 +294,7 @@ if ( addr.hid == xmt::hostid() && addr.pid == xmt::getpid() ) { // this host, this process if ( (addr.addr & extbit) == 0 ) { // looks like local object - Locker _x1( _lock_heap ); + scoped_lock _x1( _lock_heap ); local_heap_type::const_iterator l = heap.find( addr.addr ); if ( l != heap.end() ) { return addr.addr; // l->first @@ -307,7 +307,7 @@ // peer don't know host ids, used as access to 'standard' services and initial // communication if ( (addr.addr & extbit) == 0 && addr.addr <= _low ) { - Locker _x1( _lock_heap ); + scoped_lock _x1( _lock_heap ); local_heap_type::const_iterator l = heap.find( addr.addr ); if ( l != heap.end() ) { return addr.addr; // l->first @@ -318,7 +318,7 @@ } #endif - Locker _x1( _lock_xheap ); + scoped_lock _x1( _lock_xheap ); pair<uuid_tr_heap_type::const_iterator,uuid_tr_heap_type::const_iterator> range = _tr_heap.equal_range( addr ); if ( range.first != range.second ) { // transport present return min_element( range.first, range.second, tr_compare )->second.first; @@ -329,7 +329,7 @@ __FIT_DECLSPEC gaddr_type EvManager::reflect( addr_type addr ) const { - Locker lk( _lock_xheap ); + scoped_lock lk( _lock_xheap ); ext_uuid_heap_type::const_iterator i = _ex_heap.find( addr ); if ( i != _ex_heap.end() ) { return i->second; @@ -340,45 +340,45 @@ __FIT_DECLSPEC void EvManager::Remove( void *channel ) { - Locker _x1( _lock_xheap ); - Locker _x2( _lock_iheap ); + scoped_lock _x1( _lock_xheap ); + scoped_lock _x2( _lock_iheap ); unsafe_Remove( channel ); } void EvManager::settrf( unsigned f ) { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); _trflags |= f; } void EvManager::unsettrf( unsigned f ) { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); _trflags &= (0xffffffff & ~f); } void EvManager::resettrf( unsigned f ) { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); _trflags = f; } void EvManager::cleantrf() { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); _trflags = 0; } unsigned EvManager::trflags() const { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); return _trflags; } void EvManager::settrs( std::ostream *s ) { - Locker _x1( _lock_tr ); + scoped_lock _x1( _lock_tr ); _trs = s; } @@ -407,7 +407,7 @@ __FIT_DECLSPEC const detail::transport& EvManager::transport( addr_type id ) const { - Locker _x1( _lock_xheap ); + scoped_lock _x1( _lock_xheap ); if ( (id & extbit) != 0 ) { ext_uuid_heap_type::const_iterator i = _ex_heap.find( id ); if ( i == _ex_heap.end() ) { @@ -470,7 +470,7 @@ if ( !reinterpret_cast<NetTransport_base *>(link)->push( e, gaddr_dst, gaddr_src) ) { #ifdef __FIT_STEM_TRACE try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracenet) ) { *_trs << "Remove net channel " << link << endl; } @@ -493,7 +493,7 @@ catch ( std::logic_error& err ) { // #ifdef __FIT_STEM_TRACE try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { *_trs << err.what() << " " << __FILE__ << ":" << __LINE__ << endl; @@ -507,7 +507,7 @@ catch ( std::runtime_error& err ) { // #ifdef __FIT_STEM_TRACE try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { *_trs << err.what() << " " << __FILE__ << ":" << __LINE__ << endl; @@ -521,7 +521,7 @@ catch ( ... ) { // #ifdef __FIT_STEM_TRACE try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { *_trs << "Unknown, uncatched exception: " << __FILE__ << ":" << __LINE__ << endl; @@ -545,7 +545,7 @@ try { #ifdef __FIT_STEM_TRACE try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { *_trs << object->classtype().name() << " (" << object << ")\n"; @@ -560,7 +560,7 @@ } catch ( std::logic_error& err ) { try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { *_trs << err.what() << "\n" << object->classtype().name() << " (" << object << ")\n"; @@ -573,7 +573,7 @@ } catch ( ... ) { try { - Locker lk(_lock_tr); + scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { *_trs << "Unknown, uncatched exception during process:\n" << object->classtype().name() << " (" << object << ")\n"; @@ -588,7 +588,7 @@ catch ( std::logic_error& err ) { //... [truncated message content] |
From: <com...@us...> - 2007-07-11 19:56:55
|
Revision: 1605 http://svn.sourceforge.net/complement/?rev=1605&view=rev Author: complement Date: 2007-07-11 12:56:54 -0700 (Wed, 11 Jul 2007) Log Message: ----------- test suite messages, initial Modified Paths: -------------- trunk/complement/explore/app/exam/suite.cc trunk/complement/explore/app/exam/suite.h trunk/complement/explore/app/exam/zero.cc Modified: trunk/complement/explore/app/exam/suite.cc =================================================================== --- trunk/complement/explore/app/exam/suite.cc 2007-07-11 18:52:43 UTC (rev 1604) +++ trunk/complement/explore/app/exam/suite.cc 2007-07-11 19:56:54 UTC (rev 1605) @@ -61,20 +61,39 @@ skip_recorder<Tag> record_skip(test_suite& ts, Tag) { return skip_recorder<Tag>(ts); } -int _root_func() +} // namespace detail + +int test_suite::_root_func() { - return 0; + return test_suite::init; } -} // namespace detail +test_suite::test_suite( const string& name ) : + root( add_vertex( white_color, g ) ), + _suite_name( name ) +{ + color = get( vertex_color, g ); + testcase = get( vertex_testcase, g ); + _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); + _test[root].state = 0; + _stat.total = 0; + _stat.passed = 0; + _stat.failed = 0; + _stat.skipped = 0; +} -test_suite::test_suite() : - root( add_vertex( white_color, g ) ) +test_suite::test_suite( const char *name ) : + root( add_vertex( white_color, g ) ), + _suite_name( name ) { color = get( vertex_color, g ); testcase = get( vertex_testcase, g ); _test[root].tc = detail::make_test_case( detail::call( _root_func ) ); _test[root].state = 0; + _stat.total = 0; + _stat.passed = 0; + _stat.failed = 0; + _stat.skipped = 0; } test_suite::~test_suite() @@ -87,41 +106,66 @@ void test_suite::girdle() { stack<vertex_t> buffer; + cerr << "== Begin test suite\n"; breadth_first_visit( g, root, buffer, make_bfs_visitor( make_pair( record_vertexes(*this,on_discover_vertex()), record_skip(*this,on_examine_edge()) ) ), color ); + cerr << "== End test suite\n"; + if ( _stat.failed != 0 ) { + cerr << "*** FAIL "; + } else { + cerr << "*** PASS "; + } + cerr << _suite_name + << " (+" << _stat.passed + << "-" << _stat.failed + << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; } void test_suite::girdle( test_suite::test_case_type start ) { stack<vertex_t> buffer; - list<vertex_t> v; + cerr << "== Begin test suite\n"; breadth_first_visit( g, start, buffer, make_bfs_visitor( make_pair( record_vertexes(*this,on_discover_vertex()), record_skip(*this,on_examine_edge()) ) ), color ); + cerr << "== End test suite\n"; + if ( _stat.failed != 0 ) { + cerr << "*** FAIL "; + } else { + cerr << "*** PASS "; + } + cerr << _suite_name + << " (+" << _stat.passed + << "-" << _stat.failed + << "~" << _stat.skipped << "/" << _stat.total << ") ***" << endl; } -test_suite::test_case_type test_suite::add( test_suite::func_type f ) +test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name ) { vertex_t v = add_vertex( white_color, g); add_edge( root, v, g ); _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; + _test[v].name = name; + ++_stat.total; return v; } -test_suite::test_case_type test_suite::add( test_suite::func_type f, test_suite::test_case_type depends ) +test_suite::test_case_type test_suite::add( test_suite::func_type f, const string& name, test_suite::test_case_type depends ) { vertex_t v = add_vertex( white_color, g); add_edge( depends, v, g ); _test[v].tc = detail::make_test_case( detail::call( f ) ); _test[v].state = 0; + _test[v].name = name; + ++_stat.total; return v; } @@ -164,13 +208,26 @@ { try { if ( _test[v].state == 0 ) { - if ( (*_test[v].tc)() != 0 ) { + int res = (*_test[v].tc)(); + if ( (res & init) != 0 ) { + // do nothing + } else if ( res == 0 ) { + ++_stat.passed; + cerr << " PASS " << _test[v].name << "\n"; + } else { _test[v].state = fail; + ++_stat.failed; + cerr << " FAIL " << _test[v].name << "\n"; } + } else { + ++_stat.skipped; + cerr << " SKIP " << _test[v].name << "\n"; } } catch ( ... ) { + ++_stat.failed; _test[v].state = fail; + cerr << " FAIL " << _test[v].name << "\n"; } } Modified: trunk/complement/explore/app/exam/suite.h =================================================================== --- trunk/complement/explore/app/exam/suite.h 2007-07-11 18:52:43 UTC (rev 1604) +++ trunk/complement/explore/app/exam/suite.h 2007-07-11 19:56:54 UTC (rev 1605) @@ -7,6 +7,7 @@ #include <sstream> #include <map> #include <boost/graph/adjacency_list.hpp> +#include <string> enum vertex_testcase_t { vertex_testcase }; @@ -141,18 +142,27 @@ typedef int (*func_type)(); typedef vertex_t test_case_type; - test_suite(); + test_suite( const std::string& name ); + test_suite( const char *name ); ~test_suite(); - test_case_type add( func_type ); - test_case_type add( func_type, test_case_type ); + test_case_type add( func_type, const std::string& name ); + test_case_type add( func_type, const std::string& name, test_case_type ); template <class TC> - test_case_type add( int (TC::*)(), TC& ); + test_case_type add( int (TC::*)(), TC&, const std::string& name ); template <class TC> - test_case_type add( int (TC::*)(), TC&, test_case_type ); + test_case_type add( int (TC::*)(), TC&, const std::string& name, test_case_type ); + struct stat + { + int total; + int passed; + int failed; + int skipped; + }; + void girdle(); void girdle( test_case_type start ); @@ -160,7 +170,8 @@ void check_test_case( vertex_t u, vertex_t v ); enum { - trace = 1 + trace = 1, + trace_suite = 2 }; static int flags(); @@ -170,7 +181,8 @@ private: enum { fail = 1, - skip = 2 + skip = 2, + init = 1024 }; graph_t g; @@ -182,33 +194,41 @@ { detail::test_case *tc; int state; + std::string name; }; typedef std::map<vertex_t,test_case_collect> test_case_map_type; test_case_map_type _test; + test_suite::stat _stat; + std::string _suite_name; static int _flags; static void (*_report)( const char *, int, bool, const char * ); + static int _root_func(); }; template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance ) +test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance, const std::string& name ) { vertex_t v = boost::add_vertex( boost::white_color, g); boost::add_edge( root, v, g ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; + _test[v].name = name; + ++_stat.total; return v; } template <class TC> -test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance, test_suite::test_case_type depends ) +test_suite::test_case_type test_suite::add( int (TC::*f)(), TC& instance, const std::string& name, test_suite::test_case_type depends ) { vertex_t v = boost::add_vertex( boost::white_color, g); boost::add_edge( depends, v, g ); _test[v].tc = detail::make_test_case( f, instance ); _test[v].state = 0; + _test[v].name = name; + ++_stat.total; return v; } Modified: trunk/complement/explore/app/exam/zero.cc =================================================================== --- trunk/complement/explore/app/exam/zero.cc 2007-07-11 18:52:43 UTC (rev 1604) +++ trunk/complement/explore/app/exam/zero.cc 2007-07-11 19:56:54 UTC (rev 1605) @@ -9,6 +9,13 @@ return 0; } +int func2() +{ + EXAM_CHECK(true); + + return 0; +} + class test_x { public: @@ -24,15 +31,19 @@ int main( int argc, char **argv ) { - exam::test_suite t; + exam::test_suite t( "exam level 0" ); test_x tx; - t.add( func ); - t.add( &test_x::f, tx ); + t.add( func, "simple function" ); + t.add( &test_x::f, tx, "member function" ); - t.girdle( 0 ); + t.add( func, "simple function, depends", + t.add( &test_x::f, tx, "member function, depends", + t.add( func2, "simple good function" ) ) ); + t.girdle(); + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-07-11 18:52:50
|
Revision: 1604 http://svn.sourceforge.net/complement/?rev=1604&view=rev Author: complement Date: 2007-07-11 11:52:43 -0700 (Wed, 11 Jul 2007) Log Message: ----------- Barrier replaced by barrier, Semaphore by semaphore Modified Paths: -------------- branches/complement-xmt/explore/include/mt/shm.h branches/complement-xmt/explore/include/mt/xmt.h branches/complement-xmt/explore/lib/mt/ChangeLog branches/complement-xmt/explore/test/mt/mt_test.cc branches/complement-xmt/explore/test/sockios/sockios_test.cc Modified: branches/complement-xmt/explore/include/mt/shm.h =================================================================== --- branches/complement-xmt/explore/include/mt/shm.h 2007-07-11 17:56:00 UTC (rev 1603) +++ branches/complement-xmt/explore/include/mt/shm.h 2007-07-11 18:52:43 UTC (rev 1604) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 20:52:38 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:38:41 ptr> /* * Copyright (c) 2006, 2007 @@ -76,13 +76,13 @@ }; template <> -struct ipc_sharable<xmt::__Semaphore<true> > +struct ipc_sharable<xmt::__semaphore<true> > { typedef std::__true_type is_ipc_sharable; }; template <> -struct ipc_sharable<xmt::__Barrier<true> > +struct ipc_sharable<xmt::__barrier<true> > { typedef std::__true_type is_ipc_sharable; }; Modified: branches/complement-xmt/explore/include/mt/xmt.h =================================================================== --- branches/complement-xmt/explore/include/mt/xmt.h 2007-07-11 17:56:00 UTC (rev 1603) +++ branches/complement-xmt/explore/include/mt/xmt.h 2007-07-11 18:52:43 UTC (rev 1604) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 20:51:27 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:37:57 ptr> /* * Copyright (c) 1997-1999, 2002-2007 @@ -1161,10 +1161,10 @@ typedef __condition<false> condition; template <bool SCOPE> -class __Semaphore +class __semaphore { public: - __Semaphore( int cnt = 1 ) + __semaphore( int cnt = 1 ) { #ifdef __FIT_WIN32THREADS _sem = CreateSemaphore( NULL, cnt, INT_MAX, 0 ); // check! @@ -1178,7 +1178,7 @@ #endif } - ~__Semaphore() + ~__semaphore() { #ifdef __FIT_WIN32THREADS CloseHandle( _sem ); @@ -1270,14 +1270,14 @@ sem_t _sem; #endif private: - __Semaphore( const __Semaphore& ) + __semaphore( const __semaphore& ) { } }; -typedef __Semaphore<false> Semaphore; +typedef __semaphore<false> semaphore; template <bool SCOPE> -int __Semaphore<SCOPE>::wait_time( const ::timespec *abstime ) // wait for time t, or signal +int __semaphore<SCOPE>::wait_time( const ::timespec *abstime ) // wait for time t, or signal { #ifdef __FIT_WIN32THREADS time_t ct = time( 0 ); @@ -1303,7 +1303,7 @@ } template <bool SCOPE> -int __Semaphore<SCOPE>::wait_delay( const ::timespec *interval ) // wait, timeout is delay t, or signal +int __semaphore<SCOPE>::wait_delay( const ::timespec *interval ) // wait, timeout is delay t, or signal { #ifdef __FIT_WIN32THREADS unsigned ms = interval->tv_sec * 1000 + interval->tv_nsec / 1000000; @@ -1329,10 +1329,10 @@ } template <bool SCOPE> -class __Barrier +class __barrier { public: - __Barrier( unsigned cnt = 2 ) + __barrier( unsigned cnt = 2 ) { #ifdef _PTHREADS pthread_barrierattr_t attr; @@ -1343,7 +1343,7 @@ #endif } - ~__Barrier() + ~__barrier() { #ifdef _PTHREADS pthread_barrier_destroy( &_barr ); @@ -1363,7 +1363,7 @@ #endif }; -typedef __Barrier<false> Barrier; +typedef __barrier<false> barrier; __FIT_DECLSPEC void fork() throw( fork_in_parent, std::runtime_error ); __FIT_DECLSPEC void become_daemon() throw( fork_in_parent, std::runtime_error ); Modified: branches/complement-xmt/explore/lib/mt/ChangeLog =================================================================== --- branches/complement-xmt/explore/lib/mt/ChangeLog 2007-07-11 17:56:00 UTC (rev 1603) +++ branches/complement-xmt/explore/lib/mt/ChangeLog 2007-07-11 18:52:43 UTC (rev 1604) @@ -1,7 +1,9 @@ 2007-07-11 Petr Ovtchenkov <pt...@is...> - * xmt.h, shm.h: Condition replaced by condition. + * xmt.h, shm.h: Condition replaced by condition; + * xmt.h, shm.h: Barrier replaced by barrier, Semaphore by semaphore. + 2007-06-29 Petr Ovtchenkov <pt...@is...> * xmt.h, xmt.cc, uid.cc, thr_mgr.cc: replace Locker by scoped_lock. Modified: branches/complement-xmt/explore/test/mt/mt_test.cc =================================================================== --- branches/complement-xmt/explore/test/mt/mt_test.cc 2007-07-11 17:56:00 UTC (rev 1603) +++ branches/complement-xmt/explore/test/mt/mt_test.cc 2007-07-11 18:52:43 UTC (rev 1604) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:25:32 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:08:56 ptr> /* * Copyright (c) 2006, 2007 @@ -37,7 +37,7 @@ */ void mt_test::barrier() { - xmt::Barrier b( 1 ); + xmt::barrier b( 1 ); b.wait(); } @@ -78,7 +78,7 @@ xmt::Thread::ret_code rt; rt.iword = 0; - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); return rt; @@ -86,7 +86,7 @@ void mt_test::barrier2() { - xmt::Barrier b; + xmt::barrier b; xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread2_entry_call, &b ); @@ -105,7 +105,7 @@ xmt::Thread::ret_code rt; rt.iword = 0; - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); BOOST_CHECK( xmt::Thread::yield() == 0 ); @@ -114,7 +114,7 @@ void mt_test::yield() { - xmt::Barrier b; + xmt::barrier b; xmt::Thread t1( thread2_entry_call, &b ); xmt::Thread t2( thread3_entry_call, &b ); @@ -135,7 +135,7 @@ xmt::Thread::ret_code thr1( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); m1.lock(); @@ -156,7 +156,7 @@ xmt::Thread::ret_code thr2( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); for ( int i = 0; i < 128; ++i ) { xmt::Thread::yield(); @@ -176,7 +176,7 @@ void mt_test::mutex_test() { x = 0; - xmt::Barrier b; + xmt::barrier b; xmt::Thread t1( thr1, &b ); xmt::Thread t2( thr2, &b ); @@ -202,7 +202,7 @@ xmt::Thread::ret_code thr1s( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); sl1.lock(); @@ -223,7 +223,7 @@ xmt::Thread::ret_code thr2s( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); for ( int i = 0; i < 128; ++i ) { xmt::Thread::yield(); @@ -246,7 +246,7 @@ { #ifdef __FIT_PTHREAD_SPINLOCK x = 0; - xmt::Barrier b; + xmt::barrier b; xmt::Thread t1( thr1s, &b ); xmt::Thread t2( thr2s, &b ); @@ -302,7 +302,7 @@ xmt::Thread::ret_code thr1r( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); m2.lock(); @@ -326,7 +326,7 @@ xmt::Thread::ret_code thr2r( void *p ) { - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); for ( int i = 0; i < 128; ++i ) { @@ -352,7 +352,7 @@ void mt_test::recursive_mutex_test() { x = 0; - xmt::Barrier b; + xmt::barrier b; xmt::Thread t1( thr1r, &b ); xmt::Thread t2( thr2r, &b ); @@ -849,8 +849,8 @@ } nm.release<xmt::__condition<true> >( ObjName ); // fcnd should be destroyed here - xmt::allocator_shm<xmt::__Barrier<true>,1> shm_b; - xmt::__Barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__Barrier<true>(); + xmt::allocator_shm<xmt::__barrier<true>,1> shm_b; + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); nm.named( b, ObjName ); // ObjName should be free here @@ -859,10 +859,10 @@ try { xmt::shm_name_mgr<1>& nm_ch = seg1.name_mgr(); - xmt::allocator_shm<xmt::__Barrier<true>,1> shm_ch; - xmt::__Barrier<true>& b_ch = nm_ch.named<xmt::__Barrier<true> >( ObjName ); + xmt::allocator_shm<xmt::__barrier<true>,1> shm_ch; + xmt::__barrier<true>& b_ch = nm_ch.named<xmt::__barrier<true> >( ObjName ); b_ch.wait(); - nm_ch.release<xmt::__Barrier<true> >( ObjName ); + nm_ch.release<xmt::__barrier<true> >( ObjName ); } catch ( const std::invalid_argument& err ) { BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); @@ -875,7 +875,7 @@ int stat; BOOST_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); } - nm.release<xmt::__Barrier<true> >( ObjName ); // barrier should be destroyed here + nm.release<xmt::__barrier<true> >( ObjName ); // barrier should be destroyed here } catch ( xmt::shm_bad_alloc& err ) { BOOST_CHECK_MESSAGE( false, "error report: " << err.what() ); Modified: branches/complement-xmt/explore/test/sockios/sockios_test.cc =================================================================== --- branches/complement-xmt/explore/test/sockios/sockios_test.cc 2007-07-11 17:56:00 UTC (rev 1603) +++ branches/complement-xmt/explore/test/sockios/sockios_test.cc 2007-07-11 18:52:43 UTC (rev 1604) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/07/11 21:40:23 ptr> +// -*- C++ -*- Time-stamp: <07/07/11 22:33:49 ptr> /* * @@ -27,7 +27,7 @@ const char fname[] = "/tmp/sockios_test.shm"; xmt::shm_alloc<0> seg; xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; -xmt::allocator_shm<xmt::__Barrier<true>,0> shm_b; +xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; sockios_test::sockios_test() { @@ -200,7 +200,7 @@ fill( buf, buf + 1024, 0 ); - xmt::Barrier& b = *reinterpret_cast<xmt::Barrier *>(p); + xmt::barrier& b = *reinterpret_cast<xmt::barrier *>(p); b.wait(); while( true ) { @@ -245,7 +245,7 @@ * so I don't care about safe termination. */ const int b_count = 10; - xmt::Barrier b( b_count ); + xmt::barrier b( b_count ); xmt::Thread *th1 = new xmt::Thread( client_thr, &b ); for ( int i = 0; i < (b_count - 1); ++i ) { @@ -432,11 +432,11 @@ void connect( std::sockstream& ); void close(); - static xmt::__Barrier<true> *b; + static xmt::__barrier<true> *b; }; -xmt::__Barrier<true> *ConnectionProcessor5::b = 0; +xmt::__barrier<true> *ConnectionProcessor5::b = 0; ConnectionProcessor5::ConnectionProcessor5( std::sockstream& s ) { @@ -490,7 +490,7 @@ { try { xmt::__condition<true>& fcnd = *new ( shm_cnd.allocate( 1 ) ) xmt::__condition<true>(); - xmt::__Barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__Barrier<true>(); + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); ConnectionProcessor5::b = &b; // nm.named( fcnd, 1 ); fcnd.set( false ); @@ -530,7 +530,7 @@ srv.wait(); } - (&b)->~__Barrier<true>(); + (&b)->~__barrier<true>(); shm_b.deallocate( &b, 1 ); (&fcnd)->~__condition<true>(); shm_cnd.deallocate( &fcnd, 1 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |