cppunit-cvs Mailing List for CppUnit - C++ port of JUnit (Page 9)
Brought to you by:
blep
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(94) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(114) |
Mar
(80) |
Apr
|
May
|
Jun
(36) |
Jul
(67) |
Aug
(37) |
Sep
(33) |
Oct
(28) |
Nov
(91) |
Dec
(16) |
2006 |
Jan
(1) |
Feb
(7) |
Mar
(45) |
Apr
|
May
|
Jun
(36) |
Jul
(7) |
Aug
|
Sep
(32) |
Oct
(3) |
Nov
|
Dec
|
2007 |
Jan
(29) |
Feb
(11) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(35) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(13) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(15) |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:46
|
Update of /cvsroot/cppunit/cppunit2/src/jsontestrunner In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26100/src/jsontestrunner Added Files: SConscript main.cpp Log Message: - synchronized with lastest jsoncpp. --- NEW FILE: main.cpp --- #include <json/json.h> //#include <stdexcept> #include <stdio.h> #if defined(_MSC_VER) && _MSC_VER >= 1310 # pragma warning( disable: 4996 ) // disable fopen deprecation warning #endif static std::string readInputTestFile( const char *path ) { FILE *file = fopen( path, "rb" ); if ( !file ) return std::string(""); fseek( file, 0, SEEK_END ); int size = ftell( file ); fseek( file, 0, SEEK_SET ); std::string text; char *buffer = new char[size+1]; buffer[size] = 0; if ( fread( buffer, 1, size, file ) == size ) text = buffer; fclose( file ); delete[] buffer; return text; } static void printValueTree( FILE *fout, Json::Value &value, const std::string &path = "." ) { switch ( value.type() ) { case Json::nullValue: fprintf( fout, "%s=null\n", path.c_str() ); break; case Json::intValue: fprintf( fout, "%s=%d\n", path.c_str(), value.asInt() ); break; case Json::uintValue: fprintf( fout, "%s=%u\n", path.c_str(), value.asUInt() ); break; case Json::realValue: fprintf( fout, "%s=%.16g\n", path.c_str(), value.asDouble() ); break; case Json::stringValue: fprintf( fout, "%s=\"%s\"\n", path.c_str(), value.asString().c_str() ); break; case Json::booleanValue: fprintf( fout, "%s=%s\n", path.c_str(), value.asBool() ? "true" : "false" ); break; case Json::arrayValue: { fprintf( fout, "%s=[]\n", path.c_str() ); int size = value.size(); for ( int index =0; index < size; ++index ) { static char buffer[16]; sprintf( buffer, "[%d]", index ); printValueTree( fout, value[index], path + buffer ); } } break; case Json::objectValue: { fprintf( fout, "%s={}\n", path.c_str() ); Json::Value::Members members( value.getMemberNames() ); std::string suffix = *(path.end()-1) == '.' ? "" : "."; for ( Json::Value::Members::iterator it = members.begin(); it != members.end(); ++it ) { const std::string &name = *it; printValueTree( fout, value[name], path + suffix + name ); } } break; default: break; } } static int parseAndSaveValueTree( const std::string &input, const std::string &actual, const std::string &kind, Json::Value &root ) { Json::Reader reader; bool parsingSuccessful = reader.parse( input, root ); if ( !parsingSuccessful ) { printf( "Failed to parse %s file: \n%s\n", kind.c_str(), reader.getFormatedErrorMessages().c_str() ); return 1; } FILE *factual = fopen( actual.c_str(), "wt" ); if ( !factual ) { printf( "Failed to create %s actual file.\n", kind.c_str() ); return 2; } printValueTree( factual, root ); fclose( factual ); return 0; } static int rewriteValueTree( const std::string &rewritePath, const Json::Value &root, std::string &rewrite ) { // Json::FastWriter writer; Json::StyledWriter writer; rewrite = writer.write( root ); FILE *fout = fopen( rewritePath.c_str(), "wt" ); if ( !fout ) { printf( "Failed to create rewrite file: %s\n", rewritePath.c_str() ); return 2; } fprintf( fout, "%s\n", rewrite.c_str() ); fclose( fout ); return 0; } static std::string removeSuffix( const std::string &path, const std::string &extension ) { if ( extension.length() >= path.length() ) return std::string(""); std::string suffix = path.substr( path.length() - extension.length() ); if ( suffix != extension ) return std::string(""); return path.substr( 0, path.length() - extension.length() ); } int main( int argc, const char *argv[] ) { if ( argc != 2 ) { printf( "Usage: %s input-json-file", argv[0] ); return 3; } std::string input = readInputTestFile( argv[1] ); if ( input.empty() ) { printf( "Failed to read input or empty input: %s\n", argv[1] ); return 3; } std::string basePath = removeSuffix( argv[1], ".json" ); if ( basePath.empty() ) { printf( "Bad input path. Path does not end with '.expected':\n%s\n", argv[1] ); return 3; } std::string actualPath = basePath + ".actual"; std::string rewritePath = basePath + ".rewrite"; std::string rewriteActualPath = basePath + ".actual-rewrite"; Json::Value root; int exitCode = parseAndSaveValueTree( input, actualPath, "input", root ); if ( exitCode == 0 ) { std::string rewrite; exitCode = rewriteValueTree( rewritePath, root, rewrite ); if ( exitCode == 0 ) { Json::Value rewriteRoot; exitCode = parseAndSaveValueTree( rewrite, rewriteActualPath, "rewrite", rewriteRoot ); } } return exitCode; } --- NEW FILE: SConscript --- Import( 'env_testing buildJSONTests' ) buildJSONTests( env_testing, Split( """ main.cpp """ ), 'jsontestrunner' ) |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:45
|
Update of /cvsroot/cppunit/cppunit2/devtools In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv26100/devtools Added Files: syncwithjsoncpp.py Log Message: - synchronized with lastest jsoncpp. --- NEW FILE: syncwithjsoncpp.py --- # synchronize cppunit2 directory with jsoncpp directory. # should be executed from script directory. import os import os.path import glob import shutil import sys source_dirs = { "src/lib_json" : "src/cpptl", "src/jsontestrunner" : "src/jsontestrunner", "src/jsontestrunner/sconscript" : "src/jsontestrunner/SConscript", "include/json" : "include/json", "scons-tools" : "scons-tools" } jsoncpp_dir = '../../jsoncpp' cppunit2_dir = '..' if not os.path.exists( os.path.join( cppunit2_dir, 'devtools', 'syncwithjsoncpp.py' ) ): print 'You must executed this script from the cppunit2/devtools directory.' sys.Exit(1) else: for source_dir, target_dir in source_dirs.items(): source_dir = os.path.join( jsoncpp_dir, source_dir ) target_dir = os.path.join( cppunit2_dir, target_dir ) if os.path.isdir( source_dir ): print 'Analysing', source_dir for ext in 'cpp h py'.split(): ext = '*.' + ext source_files = glob.glob(os.path.join(source_dir, ext)) for source in source_files: dest_path = os.path.join( target_dir, os.path.split(source)[1] ) print ' => Copying %s to %s' % (source,dest_path) os.unlink( dest_path ) shutil.copyfile( source, dest_path ) else: print 'Direct file copy %s to %s' % (source_dir,target_dir) os.unlink( target_dir ) shutil.copyfile( source_dir, target_dir ) |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:34
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv24064/src/cpputtest Added Files: smallmaptest.cpp smallmaptest.h Log Message: * added CppTL:SmallMap, a std::map like container that use a sorted vector to hold item. --- NEW FILE: smallmaptest.h --- #ifndef CPPTLTEST_SMALLMAPTEST_H_INCLUDED # define CPPTLTEST_SMALLMAPTEST_H_INCLUDED # include <cpptl/smallmap.h> # include <cpput/testfixture.h> class SmallMapTest : public CppUT::TestFixture { CPPUT_TESTSUITE_BEGIN( SmallMapTest ); CPPUT_TEST( testDefaultConstructor ); CPPUT_TEST( testOneInsert ); CPPUT_TEST( testOrderedInserts ); CPPUT_TEST( testUnorderedInserts ); CPPUT_TEST( testDuplicateInserts ); CPPUT_TEST( testErase ); CPPUT_TEST( testInsertWithHint ); CPPUT_TESTSUITE_END(); public: typedef CppTL::SmallMap<int,int> SmallMapIntInt; typedef SmallMapIntInt::value_type IntInt; static int keyset1[10]; static int keyset2[10]; static int keyset3[4]; void testDefaultConstructor(); void testOneInsert(); void testOrderedInserts(); void testUnorderedInserts(); void testDuplicateInserts(); void testInsertWithHint(); void testErase(); private: void checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange); void checkEraseIterator( int minSeed, int maxSeed, int value ); }; #endif // CPPTLTEST_SMALLMAPTEST_H_INCLUDED --- NEW FILE: smallmaptest.cpp --- #include "smallmaptest.h" #include <cpput/assertcommon.h> int SmallMapTest::keyset1[10] = { 0, 1, 3, 7, 8, 12, 18, 20, 21, 23 }; int SmallMapTest::keyset2[10] = { 16, 2, 15, 1, 0, 18, 97, 5, 6, 7 }; int SmallMapTest::keyset3[4] = { 15, 1, 18, 7 }; #define LOCAL_CHECK_ERASE_RANGE \ CPPUT_BEGIN_CHECKING_MACRO() checkEraseRange #define LOCAL_CHECK_ERASE_ITERATOR \ CPPUT_BEGIN_CHECKING_MACRO() checkEraseIterator void SmallMapTest::checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange) { CppUT::checkTrue( beginRange >= minSeed && beginRange <= maxSeed ); CppUT::checkTrue( endRange >= minSeed && endRange <= maxSeed ); CppUT::checkTrue( beginRange <= endRange ); CppUT::checkTrue( minSeed <= maxSeed ); SmallMapIntInt sm; for ( int generator = minSeed; generator < maxSeed; ++generator ) sm.insert( IntInt( generator, generator * 101 ) ); sm.erase( sm.begin() + beginRange - minSeed, sm.begin() + endRange - minSeed); for ( int checker = minSeed; checker < maxSeed; ++checker ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker >= beginRange && checker < endRange) ? 0 : 1; CppUT::checkEquals( expected, sm.count(checker), msg ); } CppUT::checkEquals( maxSeed-minSeed - (endRange-beginRange), sm.size() ); } void SmallMapTest::checkEraseIterator( int minSeed, int maxSeed, int value ) { CppUT::checkTrue( minSeed <= maxSeed && value >= minSeed && value < maxSeed ); SmallMapIntInt sm; for ( int generator = minSeed; generator < maxSeed; ++generator ) sm.insert( IntInt( generator, generator * 101 ) ); sm.erase( sm.begin() + value - minSeed ); for ( int checker = minSeed; checker < maxSeed; ++checker ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker == value) ? 0 : 1; CppUT::checkEquals( expected, sm.count(checker), msg ); } CppUT::checkEquals( maxSeed-minSeed - 1, sm.size() ); } void SmallMapTest::testDefaultConstructor() { SmallMapIntInt sm; CPPUT_CHECK_EXPR( sm.empty() ); CPPUT_CHECK_EQUAL( 0, sm.size() ); CPPUT_CHECK_EQUAL( 0, sm.count(1234) ); } void SmallMapTest::testOneInsert() { SmallMapIntInt sm; CppTL::Pair<SmallMapIntInt::iterator,bool> result = sm.insert( IntInt( 3,33 ) ); CPPUT_CHECK_EXPR( result.second ); CPPUT_CHECK_EXPR( result.first == sm.begin() ); CPPUT_CHECK_EXPR_FALSE( sm.empty() ); CPPUT_CHECK_EQUAL( 1, sm.size() ); CPPUT_CHECK_EQUAL( 1, sm.count(3) ); CPPUT_ASSERT_EXPR( sm.begin() == sm.find(3) ); CPPUT_CHECK_EQUAL( 33, sm.find(3)->second ); } void SmallMapTest::testOrderedInserts() { SmallMapIntInt sm; // Checks multiple inserts in order const int factor = 11; for ( int index1 =0; index1 < CPPTL_ARRAY_SIZE(keyset1); ++index1 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset1[index1] ); CppTL::Pair<SmallMapIntInt::iterator,bool> result = sm.insert( IntInt( keyset1[index1], keyset1[index1] * factor ) ); CPPUT_CHECK_EXPR( result.second ); CPPUT_CHECK( result.first == sm.begin() + index1, msg ); } CPPUT_CHECK_EXPR_FALSE( sm.empty() ); CPPUT_CHECK_EQUAL( CPPTL_ARRAY_SIZE(keyset1), sm.size() ); // Checks look-up of inserted values, and the 'ordered' property of the map for ( int index2 =0; index2 < CPPTL_ARRAY_SIZE(keyset1); ++index2 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset1[index2] ); CPPUT_CHECK_EQUAL( 1, sm.count(keyset1[index2]), msg ); CPPUT_CHECK( sm.find(keyset1[index2]) != sm.end(), msg ); CPPUT_CHECK_EQUAL( keyset1[index2], sm.find(keyset1[index2])->first, msg ); // unlike std::map, operator[] preserve existing value. CPPUT_CHECK_EQUAL( keyset1[index2]*11, sm[keyset1[index2]], msg ); CPPUT_CHECK_EQUAL( keyset1[index2], sm.begin()[index2].first ); } } void SmallMapTest::testUnorderedInserts() { SmallMapIntInt sm; // Checks multiple inserts in order const int factor = 11; for ( int index1 =0; index1 < CPPTL_ARRAY_SIZE(keyset2); ++index1 ) sm.insert( IntInt( keyset2[index1], keyset2[index1] * factor ) ); CPPUT_CHECK_EXPR_FALSE( sm.empty() ); CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset2), sm.size() ); // Checks look-up of inserted values, and the 'ordered' property of the map for ( int index2 =0; index2 < CPPTL_ARRAY_SIZE(keyset2); ++index2 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset2[index2] ); CPPUT_CHECK_EQUAL( 1, sm.count(keyset2[index2]), msg ); CPPUT_CHECK( sm.find(keyset2[index2]) != sm.end(), msg ); CPPUT_CHECK_EQUAL( keyset2[index2], sm.find(keyset2[index2])->first, msg ); CPPUT_CHECK_EQUAL( keyset2[index2]*11, sm[keyset2[index2]], msg ); } // Checks that the map is ordered SmallMapIntInt::iterator it = sm.begin(); SmallMapIntInt::iterator itEnd = sm.end() - 1; for ( ; it != itEnd; ++it ) CPPUT_CHECK( it->first < it[1].first ); } void SmallMapTest::testDuplicateInserts() { SmallMapIntInt sm; CppTL::Pair<SmallMapIntInt::iterator,bool> result; result = sm.insert( IntInt(1,11) ); CPPUT_ASSERT( result.second == true ); CPPUT_ASSERT( result.first == sm.begin() ); result = sm.insert( IntInt(3,33) ); CPPUT_ASSERT( result.second == true ); CPPUT_ASSERT( result.first == sm.begin()+1 ); result = sm.insert( IntInt(2,22) ); CPPUT_ASSERT( result.second == true ); CPPUT_ASSERT( result.first == sm.begin()+1 ); result = sm.insert( IntInt(1,777) ); CPPUT_CHECK( result.second == false ); CPPUT_CHECK( result.first == sm.begin() ); CPPUT_CHECK_EQUAL( 1, result.first->first ); CPPUT_CHECK_EQUAL( 11, result.first->second ); result = sm.insert( IntInt(2,777) ); CPPUT_CHECK( result.second == false ); CPPUT_CHECK( result.first == sm.begin()+1 ); CPPUT_CHECK_EQUAL( 2, result.first->first ); CPPUT_CHECK_EQUAL( 22, result.first->second ); result = sm.insert( IntInt(3,777) ); CPPUT_CHECK( result.second == false ); CPPUT_CHECK( result.first == sm.begin()+2 ); CPPUT_CHECK_EQUAL( 3, result.first->first ); CPPUT_CHECK_EQUAL( 33, result.first->second ); } void SmallMapTest::testInsertWithHint() { SmallMapIntInt smBegin; SmallMapIntInt smMid; SmallMapIntInt smLast; SmallMapIntInt smEnd; // Checks multiple inserts in order const int factor = 11; for ( int index1 =0; index1 < CPPTL_ARRAY_SIZE(keyset1); ++index1 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset1[index1] ); IntInt item( keyset1[index1], keyset1[index1] * factor ); SmallMapIntInt::iterator itBegin = smBegin.begin(); SmallMapIntInt::iterator resultItBegin = smBegin.insert( itBegin, item ); CPPUT_CHECK( resultItBegin == smBegin.begin() + index1, msg ); CPPUT_CHECK_EQUAL( item.first, resultItBegin->first, msg ); SmallMapIntInt::iterator itMid = smMid.begin() + (index1 / 2); SmallMapIntInt::iterator resultItMid = smMid.insert( itMid, item ); SmallMapIntInt::iterator itLast = smLast.begin() + CPPTL_MAX(0, index1-1); SmallMapIntInt::iterator resultItLast = smLast.insert( itLast, item ); SmallMapIntInt::iterator itEnd = smEnd.end(); SmallMapIntInt::iterator resultItEnd = smEnd.insert( itEnd, item ); } CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset1), smBegin.size() ); CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset1), smMid.size() ); CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset1), smLast.size() ); CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset1), smEnd.size() ); // Checks look-up of inserted values, and the 'ordered' property of the map for ( int index2 =0; index2 < CPPTL_ARRAY_SIZE(keyset1); ++index2 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset1[index2] ); CPPUT_CHECK_EQUAL( keyset1[index2], smBegin.begin()[index2].first ); CPPUT_CHECK_EQUAL( keyset1[index2], smMid.begin()[index2].first ); CPPUT_CHECK_EQUAL( keyset1[index2], smLast.begin()[index2].first ); CPPUT_CHECK_EQUAL( keyset1[index2], smEnd.begin()[index2].first ); } } void SmallMapTest::testErase() { SmallMapIntInt sm; // Checks multiple inserts in order const int factor = 11; for ( int index1 =0; index1 < CPPTL_ARRAY_SIZE(keyset2); ++index1 ) sm.insert( IntInt( keyset2[index1], keyset2[index1] * factor ) ); CPPUT_CHECK_EXPR_FALSE( sm.empty() ); CPPUT_ASSERT_EQUAL( CPPTL_ARRAY_SIZE(keyset2), sm.size() ); // erase some items [single: begin, last, middle]; range[middle, middle] sm.erase( 97 ); sm.erase( 0 ); CPPUT_ASSERT( sm.find(16) != sm.end() ); sm.erase( sm.find(16) ); sm.erase( sm.find(5), sm.find(5) + 1 ); sm.erase( sm.begin() + 1, sm.begin() + 3 ); // Checks look-up of inserted values, and the 'ordered' property of the map for ( int index2 =0; index2 < CPPTL_ARRAY_SIZE(keyset3); ++index2 ) { CppTL::ConstString msg = "Checking key: " + CppTL::toString( keyset3[index2] ); CPPUT_CHECK_EQUAL( 1, sm.count(keyset3[index2]), msg ); CPPUT_CHECK( sm.find(keyset3[index2]) != sm.end(), msg ); CPPUT_CHECK_EQUAL( keyset3[index2], sm.find(keyset3[index2])->first, msg ); CPPUT_CHECK_EQUAL( keyset3[index2]*11, sm[keyset3[index2]], msg ); } // Checks that the map is ordered SmallMapIntInt::iterator it = sm.begin(); SmallMapIntInt::iterator itEnd = sm.end() - 1; for ( ; it != itEnd; ++it ) CPPUT_CHECK( it->first < it[1].first ); // Most case involving range erase LOCAL_CHECK_ERASE_RANGE( 1,10, 1, 1 ); // empty range at beginning LOCAL_CHECK_ERASE_RANGE( 1,10, 5, 5 ); // empty range in the middle LOCAL_CHECK_ERASE_RANGE( 1,10, 10, 10 ); // empty range at end LOCAL_CHECK_ERASE_ITERATOR( 1, 7, 1 ); // erase first item using iterator LOCAL_CHECK_ERASE_ITERATOR( 1, 7, 3 ); // erase middle item using iterator LOCAL_CHECK_ERASE_ITERATOR( 1, 7, 6 ); // erase last item using iterator } |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:33
|
Update of /cvsroot/cppunit/cppunit2/test/shmem_test In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22211/test/shmem_test Modified Files: main.cpp Log Message: * a bit of clean-up Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/test/shmem_test/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 10 Mar 2006 08:30:33 -0000 1.4 --- main.cpp 5 Jun 2006 12:05:58 -0000 1.5 *************** *** 14,18 **** { char buffer[16384]; ! int prefixLength = strlen(prefix); assert( prefixLength < sizeof(buffer)-1 ); strcpy( buffer, prefix ); --- 14,18 ---- { char buffer[16384]; ! int prefixLength = int( strlen(prefix) ); assert( prefixLength < sizeof(buffer)-1 ); strcpy( buffer, prefix ); *************** *** 89,93 **** void log( const char *event ) const { ! printf( "[%s] => message %s (e:%d, r:%d)\n", id_, event, sent_, received_ ); } --- 89,93 ---- void log( const char *event ) const { ! printf( "==========> [%s] message %s (e:%d, r:%d)\n", id_, event, sent_, received_ ); } |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:31
|
Update of /cvsroot/cppunit/cppunit2/makefiles/vs71 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20596/makefiles/vs71 Modified Files: cpptl_lib.vcproj cpput_lib.vcproj cpput_test.vcproj Log Message: * added CppTL:SmallMap, a std::map like container that use a sorted vector to hold item. Index: cpput_test.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/cpput_test.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cpput_test.vcproj 11 Nov 2005 20:54:15 -0000 1.3 --- cpput_test.vcproj 5 Jun 2006 12:02:56 -0000 1.4 *************** *** 221,224 **** --- 221,230 ---- </File> <File + RelativePath="..\..\src\cpputtest\smallmaptest.cpp"> + </File> + <File + RelativePath="..\..\src\cpputtest\smallmaptest.h"> + </File> + <File RelativePath="..\..\src\cpputtest\testbasicassertion.cpp"> </File> Index: cpput_lib.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/cpput_lib.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cpput_lib.vcproj 13 Nov 2005 23:02:17 -0000 1.3 --- cpput_lib.vcproj 5 Jun 2006 12:02:56 -0000 1.4 *************** *** 107,110 **** --- 107,116 ---- Filter=""> <File + RelativePath="..\..\src\cpput\parametrizedsource.cpp"> + </File> + <File + RelativePath="..\..\include\cpput\parametrizedsource.h"> + </File> + <File RelativePath="..\..\src\cpput\tablefixture.cpp"> <FileConfiguration *************** *** 208,217 **** </File> <File - RelativePath="..\..\src\cpput\parametrizedsource.cpp"> - </File> - <File - RelativePath="..\..\include\cpput\parametrizedsource.h"> - </File> - <File RelativePath="..\..\src\cpput\registry.cpp"> </File> --- 214,217 ---- Index: cpptl_lib.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/cpptl_lib.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cpptl_lib.vcproj 7 Nov 2005 22:43:07 -0000 1.2 --- cpptl_lib.vcproj 5 Jun 2006 12:02:56 -0000 1.3 *************** *** 147,150 **** --- 147,153 ---- </File> <File + RelativePath="..\..\include\cpptl\autolink.h"> + </File> + <File RelativePath="..\..\include\cpptl\config.h"> </File> *************** *** 198,201 **** --- 201,228 ---- </File> </Filter> + <File + RelativePath="..\..\include\cpptl\_stlimpl.h"> + </File> + <File + RelativePath="..\..\src\cpptl\deque.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath="..\..\include\cpptl\deque.h"> + </File> + <File + RelativePath="..\..\include\cpptl\smallmap.h"> + </File> </Files> <Globals> |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:31
|
Update of /cvsroot/cppunit/cppunit2/src/opentesttest In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22211/src/opentesttest Modified Files: packetstest.cpp Log Message: * a bit of clean-up Index: packetstest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/packetstest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** packetstest.cpp 10 Mar 2006 21:28:38 -0000 1.7 --- packetstest.cpp 5 Jun 2006 12:05:57 -0000 1.8 *************** *** 118,125 **** packets_->endWriteMessage(); - packets_->beginWriteMessage(); - packets_->write( testData, testDataLength3 ); - packets_->endWriteMessage(); - char buffer1[testDataLength1+1]; buffer1[testDataLength1] = 0; --- 118,121 ---- *************** *** 133,136 **** --- 129,136 ---- packets_->discardFirstMessage(); + packets_->beginWriteMessage(); + packets_->write( testData, testDataLength3 ); + packets_->endWriteMessage(); + char buffer2[testDataLength2+1]; buffer2[testDataLength2] = 0; |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:29
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20596 Modified Files: sconstruct Log Message: * added CppTL:SmallMap, a std::map like container that use a sorted vector to hold item. Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** sconstruct 7 Mar 2006 23:02:56 -0000 1.25 --- sconstruct 5 Jun 2006 12:02:56 -0000 1.26 *************** *** 3,11 **** options = Options() ! options.Add( 'platform', 'platform used to build cppunit 2: suncc, vacpp, mingw, msvc6, msvc7, msvc71, msvc80, linux-gcc', 'mingw' ) ! platform = ARGUMENTS.get( 'platform' ) ! ##print ARGUMENTS ! ##print "PLATFORM=", platform build_dir = os.path.join( '#buildscons', platform ) --- 3,20 ---- options = Options() ! ##options.Add( 'platform', 'platform used to build cppunit 2: suncc, vacpp, mingw, msvc6, msvc7, msvc71, msvc80, linux-gcc', 'mingw' ) ! options.Add( EnumOption('platform', ! 'Platform (compiler/stl) used to build the project', ! 'msvc71', ! allowed_values='suncc vacpp mingw msvc6 msvc7 msvc71 msvc80 linux-gcc'.split(), ! ignorecase=2) ) ! try: ! platform = ARGUMENTS['platform'] ! except KeyError: ! print 'You must specify a "platform"' ! sys.exit(2) ! ! print "Building using PLATFORM =", platform build_dir = os.path.join( '#buildscons', platform ) *************** *** 70,78 **** env.Append( CPPPATH = ['#include'], LIBPATH = lib_dir ) env_testing = env.Copy( ) env_testing.Append( LIBS = ['cpput','opentest','cpptl'] ) ! def buildCppUnitExample( env, target_sources, target_name ): env = env.Copy() env.Append( CPPPATH = ['#'] ) --- 79,91 ---- env.Append( CPPPATH = ['#include'], LIBPATH = lib_dir ) + env.Append( CPPDEFINES = [ "CPPTL_NO_AUTOLINK" ] ) # naming convention are not respected env_testing = env.Copy( ) env_testing.Append( LIBS = ['cpput','opentest','cpptl'] ) ! env_cpptl = env.Copy() ! env_cpptl.Append( LIBS = ['cpptl'] ) ! ! def buildExample( env, target_sources, target_name ): env = env.Copy() env.Append( CPPPATH = ['#'] ) *************** *** 81,85 **** global bin_dir return env.Install( bin_dir, exe ) ! def buildLibary( env, target_sources, target_name ): --- 94,99 ---- global bin_dir return env.Install( bin_dir, exe ) ! ! buildCppUnitExample = buildExample def buildLibary( env, target_sources, target_name ): *************** *** 113,117 **** env.Install( bin_dir, exe ) ! Export( 'env env_testing buildCppUnitExample buildLibary buildLibraryUnitTest buildQTApplication' ) def buildProjectInDirectory( target_directory ): --- 127,131 ---- env.Install( bin_dir, exe ) ! Export( 'env env_testing env_cpptl buildExample buildCppUnitExample buildLibary buildLibraryUnitTest buildQTApplication' ) def buildProjectInDirectory( target_directory ): *************** *** 128,131 **** --- 142,146 ---- buildProjectInDirectory( 'src/cpputtest' ) buildProjectInDirectory( 'src/opentesttest' ) + buildProjectInDirectory( 'src/jsontestrunner' ) #buildProjectInDirectory( 'examples/input_based_test' ) buildProjectInDirectory( 'examples/parametrized_test' ) |
From: Baptiste L. <bl...@us...> - 2006-06-06 03:05:27
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20596/include/cpput Modified Files: testsuite.h Log Message: * added CppTL:SmallMap, a std::map like container that use a sorted vector to hold item. Index: testsuite.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testsuite.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** testsuite.h 12 Nov 2005 20:55:46 -0000 1.8 --- testsuite.h 5 Jun 2006 12:02:56 -0000 1.9 *************** *** 48,52 **** private: ! typedef std::deque<TestPtr> Tests; Tests tests_; }; --- 48,52 ---- private: ! typedef std::deque<TestPtr> Tests; Tests tests_; }; |
From: Baptiste L. <bl...@us...> - 2006-03-11 11:46:29
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv720/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * fixed more sharedmemorytransport bugs (named event switched to manual reset, incorrect read/write buffer in slave thread, bad buffer indexing in read/write loop) Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** sharedmemorytransport.cpp 10 Mar 2006 22:05:46 -0000 1.10 --- sharedmemorytransport.cpp 11 Mar 2006 11:46:25 -0000 1.11 *************** *** 158,168 **** { public: ! HANDLE create( const TCHAR *name ) { SECURITY_ATTRIBUTES sa; hEvent_.reset( ::CreateEvent( setChildProcessCanInheritSecurity(sa), ! FALSE, ! FALSE, ! name ) ); return get(); } --- 158,168 ---- { public: ! HANDLE create( const TCHAR *name, bool manualReset = false ) { SECURITY_ATTRIBUTES sa; hEvent_.reset( ::CreateEvent( setChildProcessCanInheritSecurity(sa), ! manualReset ? TRUE : FALSE, ! FALSE, ! name ) ); return get(); } *************** *** 423,428 **** setSharedMemoryRegion(); - // Initialize shared memory region shared_->structSize_ = sizeof(SharedData); shared_->mutex_ = autoManage( ::CreateMutex( &saAttr, FALSE, 0 ) ); --- 423,428 ---- setSharedMemoryRegion(); // Initialize shared memory region + memset( shared_, 0xba, fileMappingSize ); // fill shared memory region with garbage for easier debugging shared_->structSize_ = sizeof(SharedData); shared_->mutex_ = autoManage( ::CreateMutex( &saAttr, FALSE, 0 ) ); *************** *** 506,515 **** nameBuffer_[nameLength_] = suffixes[index]; nameBuffer_[nameLength_+1] = 0; ! if ( buffer.event_.create( nameBuffer_ ) == 0 ) throw SharedMemoryError( "Failed to create named event." ); buffer.state_ = bsSize; ! buffer.circular_ = &shared_->circularBuffers_[ orientedIndex ]; buffer.data_ = reinterpret_cast<Byte *>( shared_ ) + sizeof(SharedData); ! if ( orientedIndex > 0 ) buffer.data_ += shared_->circularBuffers_[ 0 ].size_; buffer.processedLength_ = 0; --- 506,515 ---- nameBuffer_[nameLength_] = suffixes[index]; nameBuffer_[nameLength_+1] = 0; ! if ( buffer.event_.create( nameBuffer_, true ) == 0 ) throw SharedMemoryError( "Failed to create named event." ); buffer.state_ = bsSize; ! buffer.circular_ = &shared_->circularBuffers_[ index ]; buffer.data_ = reinterpret_cast<Byte *>( shared_ ) + sizeof(SharedData); ! if ( index > 0 ) buffer.data_ += shared_->circularBuffers_[ 0 ].size_; buffer.processedLength_ = 0; *************** *** 702,712 **** || getWriteBuffer().stream_.packets().hasPendingMessage() ) { ! OPENTEST_SHMEM_LOG( "Acquiring shared_->mutex_" ); ScopedMutexLock guard( shared_->mutex_ ); ! OPENTEST_SHMEM_LOG( "Acquired shared_->mutex_" ); readPendingData(); writePendingData(); } - OPENTEST_SHMEM_LOG( "Released shared_->mutex_" ); } --- 702,712 ---- || getWriteBuffer().stream_.packets().hasPendingMessage() ) { ! OPENTEST_SHMEM_LOG( "Trying to acquire mutex: shared_->mutex_ [%p]", shared_->mutex_ ); ScopedMutexLock guard( shared_->mutex_ ); ! OPENTEST_SHMEM_LOG( "Acquired mutex: shared_->mutex_ [%p]", shared_->mutex_ ); readPendingData(); writePendingData(); + OPENTEST_SHMEM_LOG( "Releasing mutex: shared_->mutex_ [%p]", shared_->mutex_ ); } } *************** *** 717,720 **** --- 717,721 ---- BufferInfo &buffer = getReadBuffer(); buffer.event_.reset(); + OPENTEST_SHMEM_LOG( "Resetting buffers_[0].buffer.event_" ); Pos oldReadPos = buffer.circular_->readPos_; while ( true ) *************** *** 729,734 **** Pos toRead = CPPTL_MIN( available, sizeof(buffer.messageLength_) - buffer.processedLength_ ); memcpy( reinterpret_cast<Byte *>(&buffer.messageLength_) + buffer.processedLength_, ! buffer.data_ + buffer.processedLength_, toRead ); buffer.read( "Message size", toRead ); --- 730,736 ---- Pos toRead = CPPTL_MIN( available, sizeof(buffer.messageLength_) - buffer.processedLength_ ); + Byte *target = buffer.data_ + buffer.processedLength_+ buffer.circular_->readPos_; memcpy( reinterpret_cast<Byte *>(&buffer.messageLength_) + buffer.processedLength_, ! target, toRead ); buffer.read( "Message size", toRead ); *************** *** 745,749 **** { Pos toRead = CPPTL_MIN( available, buffer.messageLength_ ); ! buffer.stream_.packets().write( buffer.data_ + buffer.circular_->readPos_, toRead ); buffer.read( "Message content", toRead ); --- 747,752 ---- { Pos toRead = CPPTL_MIN( available, buffer.messageLength_ ); ! Byte *target = buffer.data_ + buffer.processedLength_+ buffer.circular_->readPos_; ! buffer.stream_.packets().write( target, toRead ); buffer.read( "Message content", toRead ); *************** *** 764,768 **** --- 767,774 ---- if ( oldReadPos != buffer.circular_->readPos_ ) + { + OPENTEST_SHMEM_LOG( "Signaling buffers_[0].buffer.event_" ); buffer.event_.signal(); + } } *************** *** 771,774 **** --- 777,781 ---- { BufferInfo &buffer = getWriteBuffer(); + OPENTEST_SHMEM_LOG( "Resetting buffers_[1].buffer.event_" ); buffer.event_.reset(); Pos oldWritePos = buffer.circular_->writePos_; *************** *** 786,790 **** Pos toWrite = CPPTL_MIN( available, sizeof(buffer.messageLength_) - buffer.processedLength_ ); ! memcpy( buffer.data_ + buffer.processedLength_, reinterpret_cast<Byte *>(&buffer.messageLength_) + buffer.processedLength_, toWrite ); --- 793,798 ---- Pos toWrite = CPPTL_MIN( available, sizeof(buffer.messageLength_) - buffer.processedLength_ ); ! Byte *target = buffer.data_ + buffer.circular_->normalizeWritePos() + buffer.processedLength_; ! memcpy( target, reinterpret_cast<Byte *>(&buffer.messageLength_) + buffer.processedLength_, toWrite ); *************** *** 801,805 **** { Pos toWrite = CPPTL_MIN( available, buffer.messageLength_ ); ! Byte *target = buffer.data_ + buffer.circular_->normalizeWritePos(); Pos written = buffer.stream_.packets().read( target, toWrite ); buffer.write( "Message content", written ); --- 809,813 ---- { Pos toWrite = CPPTL_MIN( available, buffer.messageLength_ ); ! Byte *target = buffer.data_ + buffer.circular_->normalizeWritePos() + buffer.processedLength_; Pos written = buffer.stream_.packets().read( target, toWrite ); buffer.write( "Message content", written ); *************** *** 819,823 **** --- 827,834 ---- } if ( oldWritePos != buffer.circular_->writePos_ ) + { + OPENTEST_SHMEM_LOG( "signaling buffers_[1].buffer.event_" ); buffer.event_.signal(); + } } |
From: Baptiste L. <bl...@us...> - 2006-03-10 22:05:55
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24218/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * better event logging * fixed bug (incorrect message length when sending second message) * fixed bug: event not reseted after flushing messageToSent queue. Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** sharedmemorytransport.cpp 10 Mar 2006 08:30:33 -0000 1.9 --- sharedmemorytransport.cpp 10 Mar 2006 22:05:46 -0000 1.10 *************** *** 316,319 **** --- 316,320 ---- void threadMain(); void prepareWaitObjects(); + const char *getWaitObjectName( DWORD index ); void prepareMessageToSend(); void readAndSendPendingData(); *************** *** 608,612 **** INFINITE ); event -= WAIT_OBJECT_0; - OPENTEST_SHMEM_LOG( "Event signaled: %d", event ); if ( event <0 || event > waitObjects_.size() ) { --- 609,612 ---- *************** *** 621,624 **** --- 621,627 ---- break; // timeout or abandonned event => child process died. } + + OPENTEST_SHMEM_LOG( "Event signaled: %s (event#%d)", getWaitObjectName(event), event ); + if ( waitObjects_[event] == stopEvent_.get() ) { *************** *** 656,659 **** --- 659,672 ---- + const char * + SharedMemoryTransportImpl::getWaitObjectName( DWORD index ) + { + CPPTL_ASSERT_MESSAGE( index < 4, "Bad event index" ); + static const char *names[] = { "stopEvent_", "sendMessageEvent_", + "buffers_[0].event_", "buffers_[1].event_" }; + return names[index]; + } + + void SharedMemoryTransportImpl::prepareMessageToSend() *************** *** 667,670 **** --- 680,684 ---- CppTL::Mutex::ScopedLockGuard guard( messagesToSendLock_ ); messagesToSend_.swap( messages ); + sendMessageEvent_.reset(); } OPENTEST_SHMEM_LOG( "Messaging thread released messagesToSendLock_" ); *************** *** 690,693 **** --- 704,708 ---- OPENTEST_SHMEM_LOG( "Acquiring shared_->mutex_" ); ScopedMutexLock guard( shared_->mutex_ ); + OPENTEST_SHMEM_LOG( "Acquired shared_->mutex_" ); readPendingData(); writePendingData(); *************** *** 767,772 **** case bsSize: { ! if ( buffer.messageLength_ == 0 ) ! buffer.messageLength_ = buffer.stream_.packets().getFirstMessageLength(); Pos toWrite = CPPTL_MIN( available, --- 782,786 ---- case bsSize: { ! buffer.messageLength_ = buffer.stream_.packets().getFirstMessageLength(); Pos toWrite = CPPTL_MIN( available, |
From: Baptiste L. <bl...@us...> - 2006-03-10 21:28:46
|
Update of /cvsroot/cppunit/cppunit2/src/opentesttest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1336/src/opentesttest Modified Files: packetstest.cpp packetstest.h Log Message: * added unit test for Packets::discardFirstMessage() and fixed bug in Packets. Index: packetstest.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/packetstest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** packetstest.h 4 Jul 2005 08:12:34 -0000 1.1 --- packetstest.h 10 Mar 2006 21:28:38 -0000 1.2 *************** *** 11,14 **** --- 11,15 ---- CPPUT_TEST( testDefaultConstructor ); CPPUT_TEST( testSerializeMessage ); + CPPUT_TEST( testDiscardFirstMessage ); CPPUT_TESTSUITE_END(); *************** *** 23,26 **** --- 24,28 ---- void testDefaultConstructor(); void testSerializeMessage(); + void testDiscardFirstMessage(); private: Index: packetstest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/packetstest.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** packetstest.cpp 13 Nov 2005 10:12:01 -0000 1.6 --- packetstest.cpp 10 Mar 2006 21:28:38 -0000 1.7 *************** *** 100,101 **** --- 100,156 ---- } } + + + void + PacketsTest::testDiscardFirstMessage() + { + // Notes: could have use a loop but loop unrolling makes thing easier for debugging. + static const char *testData = "12345"; + const int testDataLength1 = 3; + const int testDataLength2 = 4; + const int testDataLength3 = 5; + packets_->beginWriteMessage(); + packets_->write( testData, testDataLength1 ); + packets_->endWriteMessage(); + + packets_->beginWriteMessage(); + packets_->write( testData, testDataLength2 ); + packets_->endWriteMessage(); + + packets_->beginWriteMessage(); + packets_->write( testData, testDataLength3 ); + packets_->endWriteMessage(); + + char buffer1[testDataLength1+1]; + buffer1[testDataLength1] = 0; + CppUT::log( "Reading message 123" ); + CPPUT_ASSERT_EXPR( packets_->hasPendingMessage() ); + CPPUT_ASSERT_EQUAL( testDataLength1, packets_->getFirstMessageLength() ); + CPPUT_ASSERT_EQUAL( testDataLength1, + packets_->read( buffer1, testDataLength1 ) ); + CPPUT_ASSERT_EQUAL( BinaryData( testData, testDataLength1 ), + BinaryData( buffer1, testDataLength1 ) ); + packets_->discardFirstMessage(); + + char buffer2[testDataLength2+1]; + buffer2[testDataLength2] = 0; + CppUT::log( "Reading message 1234" ); + CPPUT_ASSERT_EXPR( packets_->hasPendingMessage() ); + CPPUT_ASSERT_EQUAL( testDataLength2, packets_->getFirstMessageLength() ); + CPPUT_ASSERT_EQUAL( testDataLength2, + packets_->read( buffer2, testDataLength2 ) ); + CPPUT_ASSERT_EQUAL( BinaryData( testData, testDataLength2 ), + BinaryData( buffer2, testDataLength2 ) ); + packets_->discardFirstMessage(); + + char buffer3[testDataLength3+1]; + buffer3[testDataLength3] = 0; + CppUT::log( "Reading message 123" ); + CPPUT_ASSERT_EXPR( packets_->hasPendingMessage() ); + CPPUT_ASSERT_EQUAL( testDataLength3, packets_->getFirstMessageLength() ); + CPPUT_ASSERT_EQUAL( testDataLength3, + packets_->read( buffer3, testDataLength3 ) ); + CPPUT_ASSERT_EQUAL( BinaryData( testData, testDataLength3 ), + BinaryData( buffer3, testDataLength3 ) ); + packets_->discardFirstMessage(); + } |
From: Baptiste L. <bl...@us...> - 2006-03-10 21:28:42
|
Update of /cvsroot/cppunit/cppunit2/include/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1336/include/opentest Modified Files: serializer.h Log Message: * added unit test for Packets::discardFirstMessage() and fixed bug in Packets. Index: serializer.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/serializer.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** serializer.h 6 Mar 2006 21:07:30 -0000 1.13 --- serializer.h 10 Mar 2006 21:28:38 -0000 1.14 *************** *** 124,127 **** --- 124,135 ---- } + Pos availableUntilEnd() const + { + CPPTL_ASSERT_MESSAGE( packet_ != 0, "No packet available" ); + CPPTL_ASSERT_MESSAGE( endInitialized_ == end_, + "availableUntilEnd() can only be called on full packet" ); + return packet_->end_ - currentData_; + } + Pos availableForReading() const { |
From: Baptiste L. <bl...@us...> - 2006-03-10 21:28:42
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1336/src/opentest Modified Files: serializer.cpp Log Message: * added unit test for Packets::discardFirstMessage() and fixed bug in Packets. Index: serializer.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/serializer.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** serializer.cpp 1 Feb 2006 18:26:17 -0000 1.13 --- serializer.cpp 10 Mar 2006 21:28:38 -0000 1.14 *************** *** 4,7 **** --- 4,8 ---- // @todo Packets : should assumes packets end at the end of the current message when reading... + // @todo Packets::discardFirstMessage(), needs to actually free some memory... *************** *** 110,113 **** --- 111,116 ---- Packets::discardFirstMessage() { + messages_.pop_front(); + //Packet *current = packetsHead_; //while ( current != writePos_.packet_ ) *************** *** 196,209 **** const PacketPos &end ) const { Pos dist = 0; - for ( Packet *current = begin.packet_; current != end.packet_; current = current->next_ ) - dist += current->length(); if ( begin.packet_ != end.packet_ ) { ! dist += begin.packet_->end_ - begin.currentData_; dist += end.offset(); } else dist += end.currentData_ - begin.currentData_; return dist; } --- 199,216 ---- const PacketPos &end ) const { + CPPTL_ASSERT_MESSAGE( begin && end, "can only compute distance() of valid PacketPos" ); + Pos dist = 0; if ( begin.packet_ != end.packet_ ) { ! dist += begin.availableUntilEnd(); ! for ( Packet *current = begin.packet_->next_; current != end.packet_; current = current->next_ ) ! dist += current->length(); dist += end.offset(); } else + { dist += end.currentData_ - begin.currentData_; + } return dist; } |
From: Baptiste L. <bl...@us...> - 2006-03-10 08:30:38
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12663/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * fixed bad 'Byte' typedef causing bad memory access. Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** sharedmemorytransport.cpp 8 Mar 2006 22:01:20 -0000 1.8 --- sharedmemorytransport.cpp 10 Mar 2006 08:30:33 -0000 1.9 *************** *** 200,205 **** { public: typedef DWORD Pos; - typedef unsigned char *Byte; SharedMemoryTransportImpl( const SharedMemoryConfig &config ); --- 200,205 ---- { public: + typedef unsigned char Byte; typedef DWORD Pos; SharedMemoryTransportImpl( const SharedMemoryConfig &config ); *************** *** 358,362 **** CPPTL_ASSERT_MESSAGE( nameLength_ < sizeof(nameBuffer_)-1, "buffer overflow" ); ! transportName_ = nameLength_; createSharedMemoryRegion(); --- 358,362 ---- CPPTL_ASSERT_MESSAGE( nameLength_ < sizeof(nameBuffer_)-1, "buffer overflow" ); ! transportName_ = nameBuffer_; createSharedMemoryRegion(); *************** *** 445,455 **** SharedMemoryTransportImpl::openSharedMemoryRegion() { ! hSharedMemory_.reset( ::OpenFileMapping( FILE_MAP_ALL_ACCESS, ! TRUE, ! nameBuffer_ ) ); ! if ( hSharedMemory_ == 0 ) ! throw SharedMemoryError( "Failed to open specified shared memory region." ); ! setSharedMemoryRegion(); } --- 445,462 ---- SharedMemoryTransportImpl::openSharedMemoryRegion() { ! if ( config_.singleProcessMasterTransport_ ) ! { ! shared_ = config_.singleProcessMasterTransport_->impl_->shared_; ! } ! else ! { ! hSharedMemory_.reset( ::OpenFileMapping( FILE_MAP_ALL_ACCESS, ! TRUE, ! nameBuffer_ ) ); ! if ( hSharedMemory_ == 0 ) ! throw SharedMemoryError( "Failed to open specified shared memory region." ); ! setSharedMemoryRegion(); ! } } *************** *** 506,509 **** --- 513,517 ---- buffer.data_ += shared_->circularBuffers_[ 0 ].size_; buffer.processedLength_ = 0; + buffer.messageLength_ = 0; } nameBuffer_[nameLength_] = 0; |
From: Baptiste L. <bl...@us...> - 2006-03-10 08:30:38
|
Update of /cvsroot/cppunit/cppunit2/test/shmem_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12663/test/shmem_test Modified Files: main.cpp Log Message: * fixed bad 'Byte' typedef causing bad memory access. Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/test/shmem_test/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.cpp 8 Mar 2006 22:01:21 -0000 1.3 --- main.cpp 10 Mar 2006 08:30:33 -0000 1.4 *************** *** 116,120 **** { master_.handleLoop(); ! // slave_.handleLoop(); } } --- 116,120 ---- { master_.handleLoop(); ! slave_.handleLoop(); } } *************** *** 216,222 **** --- 216,224 ---- OpenTest::SharedMemoryConfig configSlave; configSlave.log_ = logSlave; + configSlave.singleProcessMasterTransport_ = &masterTransport; OpenTest::SharedMemoryTransport slaveTransport( masterTransport.transportName(), configSlave ); DualTransportMessageTransmitionTester tester( masterTransport, slaveTransport ); + //DualTransportMessageTransmitionTester tester( masterTransport, masterTransport ); tester.loopUntilDone(); return 0; |
From: Baptiste L. <bl...@us...> - 2006-03-10 08:30:37
|
Update of /cvsroot/cppunit/cppunit2/include/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12663/include/opentest Modified Files: forwards.h sharedmemorytransport.h Log Message: * fixed bad 'Byte' typedef causing bad memory access. Index: sharedmemorytransport.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/sharedmemorytransport.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sharedmemorytransport.h 7 Mar 2006 23:02:55 -0000 1.4 --- sharedmemorytransport.h 10 Mar 2006 08:30:32 -0000 1.5 *************** *** 32,38 **** --- 32,40 ---- : bufferSize_( 512 * 1024 ) // 512k , log_( 0 ) + , singleProcessMasterTransport_( 0 ) { } + SharedMemoryTransport *singleProcessMasterTransport_; unsigned int bufferSize_; LogFn log_; *************** *** 60,63 **** --- 62,66 ---- private: + friend class SharedMemoryTransportImpl; SharedMemoryTransportImpl *impl_; }; Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/forwards.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** forwards.h 6 Mar 2006 08:40:48 -0000 1.10 --- forwards.h 10 Mar 2006 08:30:32 -0000 1.11 *************** *** 49,52 **** --- 49,56 ---- class Stream; + // sharedmemorytransport.h + class SharedMemoryConfig; + class SharedMemoryTransport; + // forwards.h |
From: Baptiste L. <bl...@us...> - 2006-03-08 22:01:26
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10881/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * took out the DuplicateHandle used for reference couting (a different handle was returned, and the previous handle became invalid). Explicit life cycle management is used instead. Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** sharedmemorytransport.cpp 7 Mar 2006 23:02:56 -0000 1.7 --- sharedmemorytransport.cpp 8 Mar 2006 22:01:20 -0000 1.8 *************** *** 62,80 **** } - AutoHandle( const AutoHandle &other ) - : handle_( 0 ) - { - if ( other.handle_ ) - { - ::DuplicateHandle( GetCurrentProcess(), - other.handle_, - GetCurrentProcess(), - &handle_, - 0, - TRUE, // handle may be inherited by child process - DUPLICATE_SAME_ACCESS ); - } - } - ~AutoHandle() { --- 62,65 ---- *************** *** 88,92 **** } ! AutoHandle &operator =( HANDLE handle ) { if ( handle != handle_ ) --- 73,77 ---- } ! AutoHandle &reset( HANDLE handle ) { if ( handle != handle_ ) *************** *** 99,108 **** } - AutoHandle &operator =( const AutoHandle &other ) - { - return *this = other.handle_; - } - private: HANDLE handle_; }; --- 84,91 ---- } private: + AutoHandle( const AutoHandle &other ); + AutoHandle &operator =( const AutoHandle &other ); + HANDLE handle_; }; *************** *** 178,185 **** { SECURITY_ATTRIBUTES sa; ! hEvent_ = ::CreateEvent( setChildProcessCanInheritSecurity(sa), FALSE, FALSE, ! name ); return get(); } --- 161,168 ---- { SECURITY_ATTRIBUTES sa; ! hEvent_.reset( ::CreateEvent( setChildProcessCanInheritSecurity(sa), FALSE, FALSE, ! name ) ); return get(); } *************** *** 199,206 **** { SECURITY_ATTRIBUTES sa; ! hEvent_ = ::CreateEvent( setChildProcessCanInheritSecurity(sa), TRUE, FALSE, ! 0 ); } }; --- 182,189 ---- { SECURITY_ATTRIBUTES sa; ! hEvent_.reset( ::CreateEvent( setChildProcessCanInheritSecurity(sa), TRUE, FALSE, ! 0 ) ); } }; *************** *** 347,351 **** CppTL::Mutex messagesToSendLock_; CppTL::Mutex messagesToDispatchLock_; ! std::vector<AutoHandle> handles_; std::vector<HANDLE> waitObjects_; SharedMemoryConfig config_; --- 330,334 ---- CppTL::Mutex messagesToSendLock_; CppTL::Mutex messagesToDispatchLock_; ! std::vector<HANDLE> handles_; std::vector<HANDLE> waitObjects_; SharedMemoryConfig config_; *************** *** 356,359 **** --- 339,343 ---- AutoHandle thread_; SharedData *shared_; + CppTL::ConstString transportName_; unsigned int id_; TCHAR nameBuffer_[32]; *************** *** 374,377 **** --- 358,362 ---- CPPTL_ASSERT_MESSAGE( nameLength_ < sizeof(nameBuffer_)-1, "buffer overflow" ); + transportName_ = nameLength_; createSharedMemoryRegion(); *************** *** 411,414 **** --- 396,405 ---- { stopThread(); + while ( !handles_.empty() ) + { + ::CloseHandle( handles_.back() ); + handles_.pop_back(); + } + handles_.clear(); } *************** *** 421,430 **** DWORD fileMappingSize = sizeof(SharedData) + 2*config_.bufferSize_; ! hSharedMemory_ = ::CreateFileMapping( INVALID_HANDLE_VALUE, &saAttr, // inherits handle PAGE_READWRITE, 0, // max size (hi-order) fileMappingSize, // max size (low-order) ! nameBuffer_ ); // name if ( hSharedMemory_ == 0 ) throw SharedMemoryError( "Failed to create shared memory region." ); --- 412,421 ---- DWORD fileMappingSize = sizeof(SharedData) + 2*config_.bufferSize_; ! hSharedMemory_.reset( ::CreateFileMapping( INVALID_HANDLE_VALUE, &saAttr, // inherits handle PAGE_READWRITE, 0, // max size (hi-order) fileMappingSize, // max size (low-order) ! nameBuffer_ ) ); // name if ( hSharedMemory_ == 0 ) throw SharedMemoryError( "Failed to create shared memory region." ); *************** *** 447,451 **** SharedMemoryTransportImpl::transportName() const { ! return nameBuffer_; // @todo change this to work if TCHAR = wchar_t } --- 438,442 ---- SharedMemoryTransportImpl::transportName() const { ! return transportName_.c_str(); } *************** *** 454,460 **** SharedMemoryTransportImpl::openSharedMemoryRegion() { ! hSharedMemory_ = ::OpenFileMapping( FILE_MAP_ALL_ACCESS, TRUE, ! nameBuffer_ ); if ( hSharedMemory_ == 0 ) throw SharedMemoryError( "Failed to open specified shared memory region." ); --- 445,451 ---- SharedMemoryTransportImpl::openSharedMemoryRegion() { ! hSharedMemory_.reset( ::OpenFileMapping( FILE_MAP_ALL_ACCESS, TRUE, ! nameBuffer_ ) ); if ( hSharedMemory_ == 0 ) throw SharedMemoryError( "Failed to open specified shared memory region." ); *************** *** 490,495 **** SharedMemoryTransportImpl::autoManage( HANDLE handle ) { ! AutoHandle autoHandle( handle ); ! handles_.push_back( autoHandle ); return handle; } --- 481,485 ---- SharedMemoryTransportImpl::autoManage( HANDLE handle ) { ! handles_.push_back( handle ); return handle; } *************** *** 572,578 **** { DWORD threadId; ! thread_ = ::CreateThread( 0, 0, &SharedMemoryTransportImpl::threadBootstrap, ! this, 0, &threadId ); if ( thread_ == 0 ) throw SharedMemoryError( "Failed to create thread." ); --- 562,568 ---- { DWORD threadId; ! thread_.reset( ::CreateThread( 0, 0, &SharedMemoryTransportImpl::threadBootstrap, ! this, 0, &threadId ) ); if ( thread_ == 0 ) throw SharedMemoryError( "Failed to create thread." ); *************** *** 642,645 **** --- 632,636 ---- { OPENTEST_SHMEM_LOG( "thread aborted with an unspecified exception." ); + throw; } } *************** *** 665,671 **** --- 656,664 ---- RemoteMessages messages; { + OPENTEST_SHMEM_LOG( "Messaging thread acquiring messagesToSendLock_" ); CppTL::Mutex::ScopedLockGuard guard( messagesToSendLock_ ); messagesToSend_.swap( messages ); } + OPENTEST_SHMEM_LOG( "Messaging thread released messagesToSendLock_" ); BufferInfo &buffer = getWriteBuffer(); *************** *** 687,694 **** --- 680,689 ---- || getWriteBuffer().stream_.packets().hasPendingMessage() ) { + OPENTEST_SHMEM_LOG( "Acquiring shared_->mutex_" ); ScopedMutexLock guard( shared_->mutex_ ); readPendingData(); writePendingData(); } + OPENTEST_SHMEM_LOG( "Released shared_->mutex_" ); } |
From: Baptiste L. <bl...@us...> - 2006-03-08 22:01:26
|
Update of /cvsroot/cppunit/cppunit2/test/shmem_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10881/test/shmem_test Modified Files: main.cpp Log Message: * took out the DuplicateHandle used for reference couting (a different handle was returned, and the previous handle became invalid). Explicit life cycle management is used instead. Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/test/shmem_test/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.cpp 8 Mar 2006 08:18:42 -0000 1.2 --- main.cpp 8 Mar 2006 22:01:21 -0000 1.3 *************** *** 9,18 **** # define BLENDFUNCTION void // for mingw & gcc # include <windows.h> static void log( const char *prefix, const char *format, va_list args ) { ! printf( "%s", prefix ); ! vprintf( format, args ); ! printf( "\n" ); } --- 9,25 ---- # define BLENDFUNCTION void // for mingw & gcc # include <windows.h> + # include <assert.h> static void log( const char *prefix, const char *format, va_list args ) { ! char buffer[16384]; ! int prefixLength = strlen(prefix); ! assert( prefixLength < sizeof(buffer)-1 ); ! strcpy( buffer, prefix ); ! _vsnprintf( buffer + prefixLength, sizeof(buffer) - prefixLength -2, format, args ); ! size_t offset = strlen(buffer); ! buffer[ offset ] = '\n'; ! buffer[offset + 1] = 0; ! printf( "%s", buffer ); } *************** *** 109,113 **** { master_.handleLoop(); ! slave_.handleLoop(); } } --- 116,120 ---- { master_.handleLoop(); ! // slave_.handleLoop(); } } |
From: Baptiste L. <bl...@us...> - 2006-03-08 08:18:48
|
Update of /cvsroot/cppunit/cppunit2/test/shmem_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9479/test/shmem_test Modified Files: main.cpp Log Message: * master and slave can now run in the same process, allowing for easier debugging. Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/test/shmem_test/main.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.cpp 7 Mar 2006 23:02:58 -0000 1.1 --- main.cpp 8 Mar 2006 08:18:42 -0000 1.2 *************** *** 10,22 **** # include <windows.h> ! static const char *logPrefix = ""; ! static void log( const char *format, ... ) { va_list args; va_start( args, format ); ! printf( "%s", logPrefix ); ! vprintf( format, args ); ! printf( "\n" ); va_end( args ); } --- 10,33 ---- # include <windows.h> ! static void log( const char *prefix, const char *format, va_list args ) ! { ! printf( "%s", prefix ); ! vprintf( format, args ); ! printf( "\n" ); ! } ! static void logSlave( const char *format, ... ) { va_list args; va_start( args, format ); ! log( "{slave} ", format, args ); ! va_end( args ); ! } ! ! static void logMaster( const char *format, ... ) ! { ! va_list args; ! va_start( args, format ); ! log( "{master} ", format, args ); va_end( args ); } *************** *** 29,49 **** , sent_( 0 ) , id_( id) { ! const int maxCount = 3; ! while ( sent_ < maxCount || received_ < maxCount ) ! { ! if ( sent_ < maxCount ) ! { ! ++sent_; ! log("sent"); ! OpenTest::RemoteMessagePtr message( new OpenTest::RemoteMessage( OpenTest::runnerMessageStopTest ) ); ! transport.sendMessage( message ); ! } ! if ( received_ < maxCount ) ! { ! transport.dispatchReceivedMessages( *this ); ! } } } --- 40,72 ---- , sent_( 0 ) , id_( id) + , maxCount_( 3 ) + , transport_( transport ) { ! } ! void loopUntilDone() ! { ! while ( !done() ) ! handleLoop(); ! } + bool done() const + { + return sent_ >= maxCount_ && received_ >= maxCount_; + } + + void handleLoop() + { + if ( sent_ < maxCount_ ) + { + ++sent_; + log("sent"); + OpenTest::RemoteMessagePtr message( new OpenTest::RemoteMessage( OpenTest::runnerMessageStopTest ) ); + transport_.sendMessage( message ); + } + + if ( received_ < maxCount_ ) + { + transport_.dispatchReceivedMessages( *this ); } } *************** *** 65,68 **** --- 88,119 ---- int sent_; const char *id_; + const int maxCount_; + OpenTest::MessageTransport &transport_; + }; + + + + class DualTransportMessageTransmitionTester + { + public: + DualTransportMessageTransmitionTester( OpenTest::MessageTransport &masterTransport, + OpenTest::MessageTransport &slaveTransport ) + : master_( masterTransport, "master" ) + , slave_( slaveTransport, "slave" ) + { + } + + void loopUntilDone() + { + while ( !master_.done() && !slave_.done() ) + { + master_.handleLoop(); + slave_.handleLoop(); + } + } + + private: + MessageTransmitionTester master_; + MessageTransmitionTester slave_; }; *************** *** 71,84 **** { DebugBreak(); - logPrefix = "{slave} "; OpenTest::SharedMemoryConfig config; ! config.log_ = log; OpenTest::SharedMemoryTransport transport( argv[2], config ); ! MessageTransmitionTester dummy( transport, "slave" ); return 0; } ! int main( int argc, const char *argv[] ) { printf( "Command argv[0]: %s\n", argv[0] ); --- 122,137 ---- { DebugBreak(); OpenTest::SharedMemoryConfig config; ! config.log_ = logSlave; OpenTest::SharedMemoryTransport transport( argv[2], config ); ! MessageTransmitionTester tester( transport, "slave" ); ! tester.loopUntilDone(); return 0; } ! // Spawn a child process and establish a shared memory connection by specifying the ! // shared memory region name on the command-line ! int runAsMasterOrSlave( int argc, const char *argv[] ) { printf( "Command argv[0]: %s\n", argv[0] ); *************** *** 91,97 **** return runAsSlave( argc, argv ); - logPrefix = "{master} "; OpenTest::SharedMemoryConfig config; ! config.log_ = log; OpenTest::SharedMemoryTransport transport( config ); --- 144,149 ---- return runAsSlave( argc, argv ); OpenTest::SharedMemoryConfig config; ! config.log_ = logMaster; OpenTest::SharedMemoryTransport transport( config ); *************** *** 132,136 **** } ! MessageTransmitionTester dummy( transport, "master" ); // Wait until child process exits. --- 184,189 ---- } ! MessageTransmitionTester tester( transport, "master" ); ! tester.loopUntilDone(); // Wait until child process exits. *************** *** 144,147 **** --- 197,219 ---- } + + int main( int argc, const char *argv[] ) + { + //runAsMasterOrSlave( argc, argv ); + + // Run both master and slave in the same process for easier debugging. + OpenTest::SharedMemoryConfig configMaster; + configMaster.log_ = logMaster; + OpenTest::SharedMemoryTransport masterTransport( configMaster ); + + OpenTest::SharedMemoryConfig configSlave; + configSlave.log_ = logSlave; + OpenTest::SharedMemoryTransport slaveTransport( masterTransport.transportName(), configSlave ); + + DualTransportMessageTransmitionTester tester( masterTransport, slaveTransport ); + tester.loopUntilDone(); + return 0; + } + #else int main( int argc, const char *argv[] ) |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:03:30
|
Update of /cvsroot/cppunit/cppunit2/include/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621/include/opentest Modified Files: sharedmemorytransport.h Added Files: serializedtesttransport.h Log Message: * added end to end test for shared memory transport. Index: sharedmemorytransport.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/opentest/sharedmemorytransport.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sharedmemorytransport.h 6 Sep 2005 07:31:42 -0000 1.3 --- sharedmemorytransport.h 7 Mar 2006 23:02:55 -0000 1.4 *************** *** 24,35 **** class SharedMemoryTransportImpl; ! struct SharedMemoryConfig { SharedMemoryConfig() : bufferSize_( 512 * 1024 ) // 512k { } unsigned int bufferSize_; }; --- 24,40 ---- class SharedMemoryTransportImpl; ! class SharedMemoryConfig { + public: + typedef void (*LogFn)( const char *format, ... ); + SharedMemoryConfig() : bufferSize_( 512 * 1024 ) // 512k + , log_( 0 ) { } unsigned int bufferSize_; + LogFn log_; }; *************** *** 46,49 **** --- 51,56 ---- virtual ~SharedMemoryTransport(); + std::string transportName() const; + public: // overriden from MessageTransport --- NEW FILE: serializedtesttransport.h --- #ifndef OPENTEST_SERIALIZEDTESTTRANSPORT_H_INCLUDED # define OPENTEST_SERIALIZEDTESTTRANSPORT_H_INCLUDED // for unit testing. # include <opentest/forwards.h> # include <opentest/remoteinterfaces.h> # include <deque> namespace OpenTest { class SerializedTestTransport : public MessageTransport { public: // overriden from MessageTransport void sendMessage( const RemoteMessagePtr &message ); void dispatchReceivedMessages( RemoteMessageServer &server ); private: typedef std::deque<RemoteMessagePtr> Messages; Messages messages_; }; inline void SerializedTestTransport::sendMessage( const RemoteMessagePtr &message ) { messages_.push_back( message ); } inline void SerializedTestTransport::dispatchReceivedMessages( RemoteMessageServer &server ) { Messages toDispatch; toDispatch.swap( messages_ ); while ( !toDispatch.empty() ) { server.dispatchMessage( toDispatch.front() ); toDispatch.pop_front(); } } } // namespace OpenTest #endif // OPENTEST_SERIALIZEDTESTTRANSPORT_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:03:08
|
Update of /cvsroot/cppunit/cppunit2/makefiles/vs71 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621/makefiles/vs71 Modified Files: examples_opentest_demo.vcproj Log Message: * added end to end test for shared memory transport. Index: examples_opentest_demo.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/examples_opentest_demo.vcproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** examples_opentest_demo.vcproj 11 Dec 2005 17:16:08 -0000 1.1 --- examples_opentest_demo.vcproj 7 Mar 2006 23:02:55 -0000 1.2 *************** *** 121,125 **** <Files> <File ! RelativePath="..\..\examples\opentest_demo\main.cpp"> </File> </Files> --- 121,125 ---- <Files> <File ! RelativePath="..\..\test\shmem_test\main.cpp"> </File> </Files> |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:03:04
|
Update of /cvsroot/cppunit/cppunit2/src/opentesttest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621/src/opentesttest Modified Files: SConscript Log Message: * added end to end test for shared memory transport. Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentesttest/SConscript,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SConscript 10 Nov 2005 09:05:41 -0000 1.3 --- SConscript 7 Mar 2006 23:02:56 -0000 1.4 *************** *** 3,6 **** --- 3,7 ---- buildLibraryUnitTest( env_testing, Split( """ packetstest.cpp + remoteinterfacestest.cpp serializertest.cpp main.cpp |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:03:04
|
Update of /cvsroot/cppunit/cppunit2/test/shmem_test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621/test/shmem_test Added Files: SConscript main.cpp Log Message: * added end to end test for shared memory transport. --- NEW FILE: main.cpp --- #include <opentest/sharedmemorytransport.h> #ifndef OPENTEST_NO_SHAREDMEMORYTRANSPORT # define WIN32_LEAN_AND_MEAN # define NOGDI # define NOUSER # define NOKERNEL # define NOSOUND # define NOMINMAX # define BLENDFUNCTION void // for mingw & gcc # include <windows.h> static const char *logPrefix = ""; static void log( const char *format, ... ) { va_list args; va_start( args, format ); printf( "%s", logPrefix ); vprintf( format, args ); printf( "\n" ); va_end( args ); } class MessageTransmitionTester : private OpenTest::RemoteMessageServer { public: MessageTransmitionTester( OpenTest::MessageTransport &transport, const char *id ) : received_( 0 ) , sent_( 0 ) , id_( id) { const int maxCount = 3; while ( sent_ < maxCount || received_ < maxCount ) { if ( sent_ < maxCount ) { ++sent_; log("sent"); OpenTest::RemoteMessagePtr message( new OpenTest::RemoteMessage( OpenTest::runnerMessageStopTest ) ); transport.sendMessage( message ); } if ( received_ < maxCount ) { transport.dispatchReceivedMessages( *this ); } } } public: // overridden from RemoteMessageServer void dispatchMessage( const OpenTest::RemoteMessagePtr &message ) { ++received_; log("received"); } private: void log( const char *event ) const { printf( "[%s] => message %s (e:%d, r:%d)\n", id_, event, sent_, received_ ); } int received_; int sent_; const char *id_; }; static int runAsSlave( int argc, const char *argv[] ) { DebugBreak(); logPrefix = "{slave} "; OpenTest::SharedMemoryConfig config; config.log_ = log; OpenTest::SharedMemoryTransport transport( argv[2], config ); MessageTransmitionTester dummy( transport, "slave" ); return 0; } int main( int argc, const char *argv[] ) { printf( "Command argv[0]: %s\n", argv[0] ); if ( argc > 1 ) printf( "Command argv[1]: %s\n", argv[1] ); printf( "Command line:%s\n", GetCommandLine() ); for ( int index =1; index < argc; ++index ) if ( std::string("--slave") == argv[index] ) return runAsSlave( argc, argv ); logPrefix = "{master} "; OpenTest::SharedMemoryConfig config; config.log_ = log; OpenTest::SharedMemoryTransport transport( config ); std::string childCommandLine( GetCommandLine() ); childCommandLine += " --slave "; childCommandLine += transport.transportName(); // Create a child process and pass the anymous shared memory file handle // in StdIn. SECURITY_ATTRIBUTES saAttr; saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; // inherit handle saAttr.lpSecurityDescriptor = NULL; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); // Start the child process. if( !CreateProcess( NULL, // No module name (use command line). (LPTSTR)childCommandLine.c_str(), // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ) // Pointer to PROCESS_INFORMATION structure. ) { printf( "CreateProcess failed." ); return 1; } MessageTransmitionTester dummy( transport, "master" ); // Wait until child process exits. WaitForSingleObject( pi.hProcess, INFINITE ); // Close process and thread handles. CloseHandle( pi.hProcess ); CloseHandle( pi.hThread ); return 0; } #else int main( int argc, const char *argv[] ) { return 0; // shared memory transport not supported } #endif --- NEW FILE: SConscript --- Import( 'env_testing buildCppUnitExample' ) buildCppUnitExample( env_testing, Split( """ main.cpp """ ), 'w32shmem_test' ) |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:02:59
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621 Modified Files: sconstruct Log Message: * added end to end test for shared memory transport. Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** sconstruct 6 Mar 2006 21:43:07 -0000 1.24 --- sconstruct 7 Mar 2006 23:02:56 -0000 1.25 *************** *** 136,137 **** --- 136,138 ---- buildProjectInDirectory( 'examples/opentest_demo' ) #buildProjectInDirectory( 'src/qttestdriver' ) + buildProjectInDirectory( 'test/shmem_test' ) |
From: Baptiste L. <bl...@us...> - 2006-03-07 23:02:59
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4621/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * added end to end test for shared memory transport. Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** sharedmemorytransport.cpp 1 Feb 2006 18:26:17 -0000 1.6 --- sharedmemorytransport.cpp 7 Mar 2006 23:02:56 -0000 1.7 *************** *** 23,26 **** --- 23,32 ---- + // Log macro (will probably be replace with a mini logging framework as such thing are required + // to debug distributed app). + #define OPENTEST_SHMEM_LOG \ + if ( config_.log_ ) config_.log_ + + static const DWORD magicKey = 0x43555431; *************** *** 219,222 **** --- 225,230 ---- virtual ~SharedMemoryTransportImpl(); + std::string transportName() const; + // Called from 'main' thread void send( const RemoteMessagePtr &message ); *************** *** 292,296 **** void read( const char *hint, Pos readLength ) { ! // log( "read: %s, read %d bytes at offset %d", hint, readLength, circular_->readPos_ ); circular_->read( readLength ); processedLength_ += readLength; --- 300,304 ---- void read( const char *hint, Pos readLength ) { ! // OPENTEST_SHMEM_LOG( "read: %s, read %d bytes at offset %d", hint, readLength, circular_->readPos_ ); circular_->read( readLength ); processedLength_ += readLength; *************** *** 299,303 **** void write( const char *hint, Pos writeLength ) { ! // log( "write: %s, wrote %d bytes at offset %d", hint, writeLength, circular_->normalizedWritePos() ); circular_->wrote( writeLength ); processedLength_ += writeLength; --- 307,311 ---- void write( const char *hint, Pos writeLength ) { ! // OPENTEST_SHMEM_LOG( "write: %s, wrote %d bytes at offset %d", hint, writeLength, circular_->normalizedWritePos() ); circular_->wrote( writeLength ); processedLength_ += writeLength; *************** *** 320,324 **** void setUpReadWriteBuffers(); void checkManualEvents(); - void log( const char *format, ... ) {} static DWORD WINAPI threadBootstrap( void *p ); void startThread(); --- 328,331 ---- *************** *** 364,368 **** } unsigned int pid = ::GetCurrentProcessId(); ! nameLength_ = _tprintf( nameBuffer_, _T("cpput_%08x_%08x"), pid, id_ ); CPPTL_ASSERT_MESSAGE( nameLength_ < sizeof(nameBuffer_)-1, "buffer overflow" ); --- 371,375 ---- } unsigned int pid = ::GetCurrentProcessId(); ! nameLength_ = _stprintf( nameBuffer_, _T("cpput_%08x_%08x"), pid, id_ ); CPPTL_ASSERT_MESSAGE( nameLength_ < sizeof(nameBuffer_)-1, "buffer overflow" ); *************** *** 371,374 **** --- 378,382 ---- setUpReadWriteBuffers(); checkManualEvents(); + startThread(); } *************** *** 397,404 **** --- 405,414 ---- setUpReadWriteBuffers(); checkManualEvents(); + startThread(); } SharedMemoryTransportImpl::~SharedMemoryTransportImpl() { + stopThread(); } *************** *** 434,437 **** --- 444,454 ---- + std::string + SharedMemoryTransportImpl::transportName() const + { + return nameBuffer_; // @todo change this to work if TCHAR = wchar_t + } + + void SharedMemoryTransportImpl::openSharedMemoryRegion() *************** *** 516,521 **** --- 533,541 ---- SharedMemoryTransportImpl::send( const RemoteMessagePtr &message ) { + OPENTEST_SHMEM_LOG( "send(), acquiring messagesToSendLock_" ); CppTL::Mutex::ScopedLockGuard guard( messagesToSendLock_ ); messagesToSend_.push_back( message ); + sendMessageEvent_.signal(); + OPENTEST_SHMEM_LOG( "send(), message pushed in messagesToSend_; sendMessageEvent_ signaled." ); } *************** *** 565,573 **** if ( thread_ ) { ! log( "Stopping thread..." ); stopEvent_.signal(); WaitForSingleObject( thread_, INFINITE ); // join thread stopEvent_.reset(); ! log( "Thread stopped." ); } } --- 585,593 ---- if ( thread_ ) { ! OPENTEST_SHMEM_LOG( "Stopping thread..." ); stopEvent_.signal(); WaitForSingleObject( thread_, INFINITE ); // join thread stopEvent_.reset(); ! OPENTEST_SHMEM_LOG( "Thread stopped." ); } } *************** *** 579,588 **** try { ! log( "Thread started." ); prepareWaitObjects(); while ( true ) { ! log( "Waiting event"); DWORD event = WaitForMultipleObjects( waitObjects_.size(), &waitObjects_[0], --- 599,608 ---- try { ! OPENTEST_SHMEM_LOG( "Thread started." ); prepareWaitObjects(); while ( true ) { ! OPENTEST_SHMEM_LOG( "Waiting event"); DWORD event = WaitForMultipleObjects( waitObjects_.size(), &waitObjects_[0], *************** *** 590,609 **** INFINITE ); event -= WAIT_OBJECT_0; ! log( "Event signaled: %d", event ); if ( event <0 || event > waitObjects_.size() ) { if ( event + WAIT_OBJECT_0 == WAIT_TIMEOUT ) ! log( "timeout event !" ); else if ( event + WAIT_OBJECT_0 == WAIT_FAILED ) { ! log( "event wait failed" ); } else ! log ("abandonned event: %d!", event ); break; // timeout or abandonned event => child process died. } if ( waitObjects_[event] == stopEvent_.get() ) { ! log( "Stop event signaled !" ); break; } --- 610,629 ---- INFINITE ); event -= WAIT_OBJECT_0; ! OPENTEST_SHMEM_LOG( "Event signaled: %d", event ); if ( event <0 || event > waitObjects_.size() ) { if ( event + WAIT_OBJECT_0 == WAIT_TIMEOUT ) ! OPENTEST_SHMEM_LOG( "timeout event !" ); else if ( event + WAIT_OBJECT_0 == WAIT_FAILED ) { ! OPENTEST_SHMEM_LOG( "event wait failed" ); } else ! OPENTEST_SHMEM_LOG("abandonned event: %d!", event ); break; // timeout or abandonned event => child process died. } if ( waitObjects_[event] == stopEvent_.get() ) { ! OPENTEST_SHMEM_LOG( "Stop event signaled !" ); break; } *************** *** 613,625 **** pushReceivedMessages(); } ! log( "Thread stopped." ); } catch ( const std::exception &e ) { ! log( "thread aborted: %s", e.what() ); } catch ( ... ) { ! log( "thread aborted with an unspecified exception." ); } } --- 633,645 ---- pushReceivedMessages(); } ! OPENTEST_SHMEM_LOG( "Thread stopped." ); } catch ( const std::exception &e ) { ! OPENTEST_SHMEM_LOG( "thread aborted: %s", e.what() ); } catch ( ... ) { ! OPENTEST_SHMEM_LOG( "thread aborted with an unspecified exception." ); } } *************** *** 699,703 **** buffer.state_ = bsMessage; buffer.processedLength_ = 0; ! log( "read: message size is %d", buffer.messageLength_ ); buffer.stream_.packets().beginWriteMessage(); } --- 719,723 ---- buffer.state_ = bsMessage; buffer.processedLength_ = 0; ! OPENTEST_SHMEM_LOG( "read: message size is %d", buffer.messageLength_ ); buffer.stream_.packets().beginWriteMessage(); } *************** *** 712,716 **** if ( buffer.processedLength_ == buffer.messageLength_ ) { ! log( "read: message completly received" ); buffer.stream_.packets().endWriteMessage(); buffer.state_ = bsSize; --- 732,736 ---- if ( buffer.processedLength_ == buffer.messageLength_ ) { ! OPENTEST_SHMEM_LOG( "read: message completly received" ); buffer.stream_.packets().endWriteMessage(); buffer.state_ = bsSize; *************** *** 757,761 **** buffer.state_ = bsMessage; buffer.processedLength_ = 0; ! log( "write: message size is %d", buffer.messageLength_ ); } } --- 777,781 ---- buffer.state_ = bsMessage; buffer.processedLength_ = 0; ! OPENTEST_SHMEM_LOG( "write: message size is %d", buffer.messageLength_ ); } } *************** *** 769,773 **** if ( buffer.processedLength_ == buffer.messageLength_ ) { ! log( "write: message completly sent" ); buffer.state_ = bsSize; buffer.processedLength_ = 0; --- 789,793 ---- if ( buffer.processedLength_ == buffer.messageLength_ ) { ! OPENTEST_SHMEM_LOG( "write: message completly sent" ); buffer.state_ = bsSize; buffer.processedLength_ = 0; *************** *** 845,848 **** --- 865,875 ---- } + + std::string + SharedMemoryTransport::transportName() const + { + return impl_->transportName(); + } + void SharedMemoryTransport::sendMessage( const RemoteMessagePtr &message ) |