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