release version

This commit is contained in:
Eddy Pronk
2011-10-29 15:07:08 +10:00
commit d1d604fc2e
551 changed files with 112020 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
// //////////////////////////////////////////////////////////////////////////
// Implementation file ClockerListener.cpp for class ClockerListener
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#include <cppunit/Test.h>
#include <cppunit/portability/Stream.h>
#include "ClockerListener.h"
#include "ClockerModel.h"
#include <stdio.h>
ClockerListener::ClockerListener( ClockerModel *model,
bool text )
: m_model( model )
, m_text( text )
{
}
ClockerListener::~ClockerListener()
{
}
void
ClockerListener::startTestRun( CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestResult *eventManager )
{
m_model->setExpectedTestCount( test->countTestCases() *2 );
}
void
ClockerListener::endTestRun( CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestResult *eventManager )
{
if ( m_text )
printStatistics();
}
void
ClockerListener::startTest( CPPUNIT_NS::Test *test )
{
m_model->enterTest( test, false );
}
void
ClockerListener::endTest( CPPUNIT_NS::Test *test )
{
m_model->exitTest( test, false );
}
void
ClockerListener::startSuite( CPPUNIT_NS::Test *suite )
{
m_model->enterTest( suite, true );
}
void
ClockerListener::endSuite( CPPUNIT_NS::Test *suite )
{
m_model->exitTest( suite, true );
}
void
ClockerListener::printStatistics() const
{
printTest( 0, "" );
CPPUNIT_NS::stdCOut() << "\n";
CPPUNIT_NS::stdCOut() << "Total elapsed time: ";
printTime( m_model->totalElapsedTime() );
CPPUNIT_NS::stdCOut() << ", average test case time: ";
printTime( m_model->averageTestCaseTime() );
}
void
ClockerListener::printTest( int testIndex,
const std::string &indentString ) const
{
std::string indent = indentString;
const int indentLength = 3;
printTestIndent( indentString, indentLength );
printTime( m_model->testTimeFor( testIndex ) );
CPPUNIT_NS::stdCOut() << m_model->testPathFor( testIndex ).getChildTest()->getName();
CPPUNIT_NS::stdCOut() << "\n";
if ( m_model->childCountFor( testIndex ) == 0 )
indent+= std::string( indentLength, ' ' );
else
indent+= "|" + std::string( indentLength -1, ' ' );
for ( int index =0; index < m_model->childCountFor( testIndex ); ++index )
printTest( m_model->childAtFor( testIndex, index ), indent );
}
void
ClockerListener::printTestIndent( const std::string &indent,
const int indentLength ) const
{
if ( indent.empty() )
return;
CPPUNIT_NS::stdCOut() << " ";
CPPUNIT_NS::stdCOut() << indent.substr( 0, indent.length() - indentLength ) ;
CPPUNIT_NS::stdCOut() << "+" << std::string( indentLength -1, '-' );
}
void
ClockerListener::printTime( double time ) const
{
CPPUNIT_NS::stdCOut() << '(' << ClockerModel::timeStringFor( time ) << "s) ";
}

View File

@@ -0,0 +1,66 @@
// //////////////////////////////////////////////////////////////////////////
// Header file ClockerListener.h for class ClockerListener
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#ifndef CLOCKERLISTENER_H
#define CLOCKERLISTENER_H
#include <cppunit/TestListener.h>
class ClockerModel;
/// TestListener that prints a flatten or hierarchical view of the test tree.
class ClockerListener : public CPPUNIT_NS::TestListener
{
public:
ClockerListener( ClockerModel *model,
bool text );
virtual ~ClockerListener();
void startTestRun( CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestResult *eventManager );
void endTestRun( CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestResult *eventManager );
void startTest( CPPUNIT_NS::Test *test );
void endTest( CPPUNIT_NS::Test *test );
void startSuite( CPPUNIT_NS::Test *suite );
void endSuite( CPPUNIT_NS::Test *suite );
private:
void printStatistics() const;
void printTest( int testIndex,
const std::string &indentString ) const;
void printTestIndent( const std::string &indent,
const int indentLength ) const;
void printTime( double time ) const;
/// Prevents the use of the copy constructor.
ClockerListener( const ClockerListener &other );
/// Prevents the use of the copy operator.
void operator =( const ClockerListener &other );
private:
ClockerModel *m_model;
bool m_text;
};
// Inlines methods for ClockerListener:
// -----------------------------------
#endif // CLOCKERLISTENER_H

View File

@@ -0,0 +1,146 @@
// //////////////////////////////////////////////////////////////////////////
// Implementation file ClockerModel.cpp for class ClockerModel
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/06/14
// //////////////////////////////////////////////////////////////////////////
#include "ClockerModel.h"
#include <cppunit/config/SourcePrefix.h>
ClockerModel::ClockerModel()
: m_testCaseCount( 0 )
, m_totalTestCaseTime( 0 )
{
}
ClockerModel::~ClockerModel()
{
}
void
ClockerModel::setExpectedTestCount( int count )
{
m_tests.reserve( count );
}
void
ClockerModel::enterTest( CPPUNIT_NS::Test *test,
bool isSuite )
{
m_currentPath.add( test );
int testIndex = m_tests.size();
if ( !m_testIndexes.empty() )
m_tests[ m_testIndexes.top() ].m_childIndexes.push_back( testIndex );
m_testIndexes.push( testIndex );
m_testToIndexes.insert( TestToIndexes::value_type( test, testIndex ) );
TestInfo info;
info.m_timer.start();
info.m_path = m_currentPath;
info.m_isSuite = isSuite;
m_tests.push_back( info );
if ( !isSuite )
++m_testCaseCount;
}
void
ClockerModel::exitTest( CPPUNIT_NS::Test *test,
bool isSuite )
{
m_tests[ m_testIndexes.top() ].m_timer.finish();
if ( !isSuite )
m_totalTestCaseTime += m_tests.back().m_timer.elapsedTime();
m_currentPath.up();
m_testIndexes.pop();
}
double
ClockerModel::totalElapsedTime() const
{
return m_tests[0].m_timer.elapsedTime();
}
double
ClockerModel::averageTestCaseTime() const
{
double average = 0;
if ( m_testCaseCount > 0 )
average = m_totalTestCaseTime / m_testCaseCount;
return average;
}
double
ClockerModel::testTimeFor( int testIndex ) const
{
return m_tests[ testIndex ].m_timer.elapsedTime();
}
std::string
ClockerModel::timeStringFor( double time )
{
char buffer[320];
const char *format;
if ( time < 1 )
format = "%2.3f";
else if ( time < 10 )
format = "%3.2f";
else if (time < 100 )
format = "%4.1f";
else
format = "%6f";
::sprintf( buffer, format, time );
return buffer;
}
bool
ClockerModel::isSuite( int testIndex ) const
{
return m_tests[ testIndex ].m_isSuite;
}
const CPPUNIT_NS::TestPath &
ClockerModel::testPathFor( int testIndex ) const
{
return m_tests[ testIndex ].m_path;
}
int
ClockerModel::indexOf( CPPUNIT_NS::Test *test ) const
{
TestToIndexes::const_iterator itFound = m_testToIndexes.find( test );
if ( itFound != m_testToIndexes.end() )
return itFound->second;
return -1;
}
int
ClockerModel::childCountFor( int testIndex ) const
{
return m_tests[ testIndex ].m_childIndexes.size();
}
int
ClockerModel::childAtFor( int testIndex,
int chidIndex ) const
{
return m_tests[ testIndex ].m_childIndexes[ chidIndex ];
}

View File

@@ -0,0 +1,95 @@
// //////////////////////////////////////////////////////////////////////////
// Header file ClockerModel.h for class ClockerModel
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/06/14
// //////////////////////////////////////////////////////////////////////////
#ifndef CLOCKERMODEL_H
#define CLOCKERMODEL_H
#include <cppunit/TestPath.h>
#include <cppunit/portability/CppUnitVector.h>
#include <cppunit/portability/CppUnitMap.h>
#include <cppunit/portability/CppUnitStack.h>
#include <string>
#ifdef CLOCKER_USE_WINNTTIMER
#include "WinNtTimer.h"
typedef WinNtTimer Timer;
#else
#include "Timer.h"
#endif
/// Model that represents test timing.
class ClockerModel
{
public:
/*! Constructs a ClockerModel object.
*/
ClockerModel();
/// Destructor.
virtual ~ClockerModel();
void setExpectedTestCount( int count );
void enterTest( CPPUNIT_NS::Test *test,
bool isSuite );
void exitTest( CPPUNIT_NS::Test *test,
bool isSuite );
double totalElapsedTime() const;
double averageTestCaseTime() const;
double testTimeFor( CPPUNIT_NS::Test *test ) const;
double testTimeFor( int testIndex ) const;
static std::string timeStringFor( double time );
bool isSuite( int testIndex ) const;
const CPPUNIT_NS::TestPath &testPathFor( int testIndex ) const;
// -1 is none
int indexOf( CPPUNIT_NS::Test *test ) const;
int childCountFor( int testIndex ) const;
int childAtFor( int testIndex,
int chidIndex ) const;
private:
struct TestInfo
{
CPPUNIT_NS::TestPath m_path;
Timer m_timer;
bool m_isSuite;
CppUnitVector<int> m_childIndexes;
};
/// Prevents the use of the copy constructor.
ClockerModel( const ClockerModel &other );
/// Prevents the use of the copy operator.
void operator =( const ClockerModel &other );
private:
CPPUNIT_NS::TestPath m_currentPath;
int m_testCaseCount;
double m_totalTestCaseTime;
typedef CppUnitMap<CPPUNIT_NS::Test *, int> TestToIndexes;
TestToIndexes m_testToIndexes;
CppUnitStack<int> m_testIndexes;
CppUnitVector<TestInfo> m_tests;
};
#endif // CLOCKERMODEL_H

View File

@@ -0,0 +1,78 @@
#include <cppunit/config/SourcePrefix.h> // disabled unwanted warning on vc++ 6.0
#include <cppunit/TestResult.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/plugin/TestPlugIn.h>
#include "ClockerXmlHook.h"
#include "ClockerListener.h"
#include "ClockerModel.h"
class ClockerPlugIn : public CppUnitTestPlugIn
{
public:
ClockerPlugIn()
: m_dumper( NULL )
, m_model( NULL )
, m_xmlHook( NULL )
{
}
~ClockerPlugIn()
{
delete m_dumper;
delete m_model;
delete m_xmlHook;
}
void initialize( CPPUNIT_NS::TestFactoryRegistry *registry,
const CPPUNIT_NS::PlugInParameters &parameters )
{
bool text = false;
if ( parameters.getCommandLine() == "text" )
text = true;
m_model = new ClockerModel();
m_dumper = new ClockerListener( m_model, text );
m_xmlHook = new ClockerXmlHook( m_model );
}
void addListener( CPPUNIT_NS::TestResult *eventManager )
{
eventManager->addListener( m_dumper );
}
void removeListener( CPPUNIT_NS::TestResult *eventManager )
{
eventManager->removeListener( m_dumper );
}
void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter )
{
outputter->addHook( m_xmlHook );
}
void removeXmlOutputterHooks()
{
}
void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry )
{
}
private:
ClockerListener *m_dumper;
ClockerModel *m_model;
ClockerXmlHook *m_xmlHook;
};
CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( ClockerPlugIn );
CPPUNIT_PLUGIN_IMPLEMENT_MAIN();

View File

@@ -0,0 +1,229 @@
# Microsoft Developer Studio Project File - Name="ClockerPlugIn" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=ClockerPlugIn - Win32 Debug NtTimer
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "ClockerPlugIn.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "ClockerPlugIn.mak" CFG="ClockerPlugIn - Win32 Debug NtTimer"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "ClockerPlugIn - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "ClockerPlugIn - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "ClockerPlugIn - Win32 Debug NtTimer" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CLOCKERPLUGIN_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GR /GX /Zd /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunit_dll.lib /nologo /dll /machine:I386 /out:"../../lib/ClockerPlugIn.dll" /libpath:"../../lib/"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CLOCKERPLUGIN_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInd.dll" /pdbtype:sept /libpath:"../../lib/"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug NtTimer"
# PROP BASE Intermediate_Dir "Debug NtTimer"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "DebugNtTimer"
# PROP Intermediate_Dir "DebugNtTimer"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /FD /GZ /c
# SUBTRACT BASE CPP /YX
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /Zi /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "CPPUNIT_DLL" /D "CLOCKER_USE_WINNTTIMER" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInd.dll" /pdbtype:sept /libpath:"../../lib/"
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"../../lib/ClockerPlugInNtd.dll" /pdbtype:sept /libpath:"../../lib/"
!ENDIF
# Begin Target
# Name "ClockerPlugIn - Win32 Release"
# Name "ClockerPlugIn - Win32 Debug"
# Name "ClockerPlugIn - Win32 Debug NtTimer"
# Begin Source File
SOURCE=.\ClockerListener.cpp
# End Source File
# Begin Source File
SOURCE=.\ClockerListener.h
# End Source File
# Begin Source File
SOURCE=.\ClockerModel.cpp
# End Source File
# Begin Source File
SOURCE=.\ClockerModel.h
# End Source File
# Begin Source File
SOURCE=.\ClockerPlugIn.cpp
# End Source File
# Begin Source File
SOURCE=.\ClockerXmlHook.cpp
# End Source File
# Begin Source File
SOURCE=.\ClockerXmlHook.h
# End Source File
# Begin Source File
SOURCE=.\Makefile.am
# End Source File
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# Begin Source File
SOURCE=.\Timer.cpp
!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Timer.h
!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\WinNtTimer.cpp
!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
# PROP BASE Exclude_From_Build 1
# PROP Intermediate_Dir "DebugNtTimer"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\WinNtTimer.h
!IF "$(CFG)" == "ClockerPlugIn - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ClockerPlugIn - Win32 Debug NtTimer"
# PROP BASE Exclude_From_Build 1
!ENDIF
# End Source File
# End Target
# End Project

View File

@@ -0,0 +1,94 @@
// //////////////////////////////////////////////////////////////////////////
// Implementation file ClockerXmlHook.cpp for class ClockerXmlHook
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/06/14
// //////////////////////////////////////////////////////////////////////////
#include <cppunit/Test.h>
#include <cppunit/tools/XmlDocument.h>
#include <cppunit/tools/XmlElement.h>
#include "ClockerModel.h"
#include "ClockerXmlHook.h"
ClockerXmlHook::ClockerXmlHook( ClockerModel *model )
: m_model( model )
{
}
ClockerXmlHook::~ClockerXmlHook()
{
}
void
ClockerXmlHook::endDocument( CPPUNIT_NS::XmlDocument *document )
{
CPPUNIT_NS::XmlElement *testTreeElement = new CPPUNIT_NS::XmlElement( "TimedTestTree" );
document->rootElement().addElement( testTreeElement );
addTimedTest( testTreeElement, 0 );
}
void
ClockerXmlHook::addTimedTest( CPPUNIT_NS::XmlElement *parentElement,
int testIndex )
{
std::string elementName = m_model->isSuite( testIndex ) ? "TimedSuite" : "TimedTest";
CPPUNIT_NS::XmlElement *testElement = new CPPUNIT_NS::XmlElement( elementName );
parentElement->addElement( testElement );
testElement->addAttribute( "id", testIndex );
const CPPUNIT_NS::TestPath &path = m_model->testPathFor( testIndex );
testElement->addElement( new CPPUNIT_NS::XmlElement( "Name",
path.getChildTest()->getName() ) );
testElement->addElement( new CPPUNIT_NS::XmlElement( "TestPath", path.toString() ) );
testElement->addElement( new CPPUNIT_NS::XmlElement( "Time",
ClockerModel::timeStringFor(
m_model->testTimeFor( testIndex ) ) ) );
if ( m_model->isSuite( testIndex ) )
{
for ( int childIndex =0; childIndex < m_model->childCountFor( testIndex ); ++childIndex )
addTimedTest( testElement, m_model->childAtFor( testIndex, childIndex ) );
}
}
void
ClockerXmlHook::failTestAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *testElement,
CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestFailure *failure )
{
successfulTestAdded( document, testElement, test );
}
void
ClockerXmlHook::successfulTestAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *testElement,
CPPUNIT_NS::Test *test )
{
int testIndex = m_model->indexOf( test );
double time = (testIndex >= 0) ? m_model->testTimeFor( testIndex ) : 0.0;
const CPPUNIT_NS::TestPath &path = m_model->testPathFor( testIndex );
testElement->addElement( new CPPUNIT_NS::XmlElement( "TestPath", path.toString() ) );
testElement->addElement( new CPPUNIT_NS::XmlElement( "Time",
ClockerModel::timeStringFor( time ) ) );
}
void
ClockerXmlHook::statisticsAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *statisticsElement )
{
statisticsElement->addElement(
new CPPUNIT_NS::XmlElement( "TotalElapsedTime",
ClockerModel::timeStringFor( m_model->totalElapsedTime() ) ) );
statisticsElement->addElement(
new CPPUNIT_NS::XmlElement( "AverageTestCaseTime",
ClockerModel::timeStringFor( m_model->averageTestCaseTime() ) ) );
}

View File

@@ -0,0 +1,61 @@
// //////////////////////////////////////////////////////////////////////////
// Header file ClockerXmlHook.h for class ClockerXmlHook
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/06/14
// //////////////////////////////////////////////////////////////////////////
#ifndef CLOCKERXMLHOOK_H
#define CLOCKERXMLHOOK_H
#include <cppunit/XmlOutputterHook.h>
class ClockerModel;
/// XML output hook to add test timing and test hierarchy timing.
class ClockerXmlHook : public CPPUNIT_NS::XmlOutputterHook
{
public:
/*! Constructs a ClockerXmlHook object.
*/
ClockerXmlHook( ClockerModel *model );
/// Destructor.
virtual ~ClockerXmlHook();
void endDocument( CPPUNIT_NS::XmlDocument *document );
void failTestAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *testElement,
CPPUNIT_NS::Test *test,
CPPUNIT_NS::TestFailure *failure );
void successfulTestAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *testElement,
CPPUNIT_NS::Test *test );
void statisticsAdded( CPPUNIT_NS::XmlDocument *document,
CPPUNIT_NS::XmlElement *statisticsElement );
private:
/// Prevents the use of the copy constructor.
ClockerXmlHook( const ClockerXmlHook &other );
/// Prevents the use of the copy operator.
void operator =( const ClockerXmlHook &other );
void addTimedTest( CPPUNIT_NS::XmlElement *parentElement,
int testIndex );
private:
ClockerModel *m_model;
};
// Inlines methods for ClockerXmlHook:
// -----------------------------------
#endif // CLOCKERXMLHOOK_H

View File

@@ -0,0 +1,6 @@
EXTRA_DIST = WinNtTimer.h WinNtTimer.cpp ClockerPlugIn.dsp \
Timer.h ClockerListener.h \
Timer.cpp ClockerListener.cpp \
ClockerPlugIn.cpp ClockerModel.h \
ClockerModel.cpp ReadMe.txt \
ClockerXmlHook.h ClockerXmlHook.cpp

View File

@@ -0,0 +1,359 @@
# Makefile.in generated by automake 1.10.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = examples/ClockerPlugIn
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = \
$(top_srcdir)/config/ac_create_prefix_config_h.m4 \
$(top_srcdir)/config/ac_cxx_have_sstream.m4 \
$(top_srcdir)/config/ac_cxx_have_strstream.m4 \
$(top_srcdir)/config/ac_cxx_namespaces.m4 \
$(top_srcdir)/config/ac_cxx_rtti.m4 \
$(top_srcdir)/config/ac_cxx_string_compare_string_first.m4 \
$(top_srcdir)/config/ac_dll.m4 \
$(top_srcdir)/config/ax_cxx_gcc_abi_demangle.m4 \
$(top_srcdir)/config/ax_cxx_have_isfinite.m4 \
$(top_srcdir)/config/bb_enable_doxygen.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_BINARY_AGE = @CPPUNIT_BINARY_AGE@
CPPUNIT_INTERFACE_AGE = @CPPUNIT_INTERFACE_AGE@
CPPUNIT_MAJOR_VERSION = @CPPUNIT_MAJOR_VERSION@
CPPUNIT_MICRO_VERSION = @CPPUNIT_MICRO_VERSION@
CPPUNIT_MINOR_VERSION = @CPPUNIT_MINOR_VERSION@
CPPUNIT_VERSION = @CPPUNIT_VERSION@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOT = @DOT@
DOXYGEN = @DOXYGEN@
DSYMUTIL = @DSYMUTIL@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
enable_dot = @enable_dot@
enable_html_docs = @enable_html_docs@
enable_latex_docs = @enable_latex_docs@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = WinNtTimer.h WinNtTimer.cpp ClockerPlugIn.dsp \
Timer.h ClockerListener.h \
Timer.cpp ClockerListener.cpp \
ClockerPlugIn.cpp ClockerModel.h \
ClockerModel.cpp ReadMe.txt \
ClockerXmlHook.h ClockerXmlHook.cpp
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/ClockerPlugIn/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu examples/ClockerPlugIn/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-exec-am:
install-html: install-html-am
install-info: install-info-am
install-man:
install-pdf: install-pdf-am
install-ps: install-ps-am
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,44 @@
A test plug-ins that track tests and test suites running time. It demonstrates
TestListener, TestPlugIn, and XmlOutputterHook.
Both suite and test case times are tracked. The plug-in include in the XML
output the TestPath of each test cases and its tracked time.
The timed test hierarchy is also included in the XML output. This way it is
possible to see the time each suite takes to run.
* Usage:
Just add this plug-in to DllPlugInTester command line. It will add a test
listener to track test time, and add a hook to the XmlOutputter to include
test time to the XmlOutput.
If the option "text" is passed to the plug-in, the timed test tree will be
printed to stdout.
DllPlugInRunnerd.exe ClockerPlugInd.dll
or
DllPlugInRunnerd.exe ClockerPlugInd.dll=text
* Example:
DllPlugInTesterd_dll.exe -x timed.xml ClockerPlugInd.dll CppUnitTestPlugInd.dll
Will track time of all tests contains in CppUnitTestPlugInd.dll and save the
result in timed.xml.
* Notes:
The id of the <TimedTestTree> are different than those of the
<SuccessfulTests> and <FailedTests> trees. You can use the <TestPath> to
cross-reference the datas.
* Remarks:
You may want to review ClockerModel before using this plug-in for serious
purpose, add timing based on the process cpu time.
A version is provided for NT that use the main thread cpu time. This is an issue
if the test cases are multithreaded.

View File

@@ -0,0 +1,28 @@
// //////////////////////////////////////////////////////////////////////////
// Implementation file Timer.cpp for class Timer
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#include "Timer.h"
void
Timer::start()
{
m_beginTime = clock();
}
void
Timer::finish()
{
m_elapsedTime = double(clock() - m_beginTime) / CLOCKS_PER_SEC;
}
double
Timer::elapsedTime() const
{
return m_elapsedTime;
}

View File

@@ -0,0 +1,32 @@
// //////////////////////////////////////////////////////////////////////////
// Header file Timer.h for class Timer
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#ifndef TIMER_H
#define TIMER_H
#include <time.h>
/// A Timer.
class Timer
{
public:
void start();
void finish();
double elapsedTime() const;
private:
clock_t m_beginTime;
double m_elapsedTime;
};
// Inlines methods for Timer:
// --------------------------
#endif // TIMER_H

View File

@@ -0,0 +1,77 @@
// //////////////////////////////////////////////////////////////////////////
// Implementation file WinNtTimer.cpp for class WinNtTimer
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#include "WinNtTimer.h"
/*! Returns time spent in the thread.
* @param rquadTime Receive the time spent in the thread (user+kernel time)
* in unit of 100 nano-seconds.
* In pratice, the effective resolution is 10ms !!!
*
* @return \c true if sucess, \c false otherwise.
*/
static bool
GetThreadSpentTime( LONGLONG &rquadTime )
{
FILETIME timeCreation;
FILETIME timeExit;
FILETIME timeKernel;
FILETIME timeUser;
if ( !::GetThreadTimes( ::GetCurrentThread(),
&timeCreation,
&timeExit,
&timeKernel,
&timeUser) )
{
rquadTime = 0;
return false;
}
LARGE_INTEGER lintKernel;
lintKernel.LowPart = timeKernel.dwLowDateTime;
lintKernel.HighPart = timeKernel.dwHighDateTime;
LARGE_INTEGER lintUser;
lintUser.LowPart = timeUser.dwLowDateTime;
lintUser.HighPart = timeUser.dwHighDateTime;
rquadTime = lintKernel.QuadPart + lintUser.QuadPart;
return true;
}
void
WinNtTimer::start()
{
m_isValid = GetThreadSpentTime( m_beginTime );
}
void
WinNtTimer::finish()
{
LONGLONG quadTimeEnd;
LONGLONG quadProcessedElapse;
m_isValid = m_isValid && GetThreadSpentTime( quadTimeEnd );
if ( m_isValid )
{
quadProcessedElapse = quadTimeEnd - m_beginTime;
m_elapsedTime = double(quadProcessedElapse) / 10000000;
}
else
m_elapsedTime = -1;
}
double
WinNtTimer::elapsedTime() const
{
return m_elapsedTime;
}

View File

@@ -0,0 +1,36 @@
// //////////////////////////////////////////////////////////////////////////
// Header file WinNtTimer.h for class WinNtTimer
// (c)Copyright 2000, Baptiste Lepilleur.
// Created: 2002/04/19
// //////////////////////////////////////////////////////////////////////////
#ifndef WINNTTIMER_H
#define WINNTTIMER_H
#include <windows.h>
#include <winnt.h>
#include <winbase.h>
/// A Timer.
class WinNtTimer
{
public:
void start();
void finish();
double elapsedTime() const;
private:
LONGLONG m_beginTime;
double m_elapsedTime;
bool m_isValid;
};
// Inlines methods for Timer:
// --------------------------
#endif // WINNTTIMER_H