Made the Unit test stuff a bit more mwcc/mwld friendly. It still doesn't build right out of the box with our build system, but with a few changes to the build system it can be done (I'm not going to do that, though).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
/*! This class is used to serialize access to a TestResult object. You should
|
||||
not need to explicitly use it anywhere in your testing code.
|
||||
*/
|
||||
class LockerSyncObject : public CppUnit::SynchronizedObject::SynchronizationObject {
|
||||
class CPPUNIT_API LockerSyncObject : public CppUnit::SynchronizedObject::SynchronizationObject {
|
||||
public:
|
||||
LockerSyncObject() {}
|
||||
virtual ~LockerSyncObject() {}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/*! This class is used to serialize access to a TestResult object. You should
|
||||
not need to explicitly use it anywhere in your testing code.
|
||||
*/
|
||||
class SemaphoreSyncObject : public CppUnit::SynchronizedObject::SynchronizationObject {
|
||||
class CPPUNIT_API SemaphoreSyncObject : public CppUnit::SynchronizedObject::SynchronizationObject {
|
||||
public:
|
||||
SemaphoreSyncObject();
|
||||
virtual ~SemaphoreSyncObject();
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <List.h>
|
||||
#include <MessageQueue.h>
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
// TestHandler
|
||||
|
||||
class BTestHandler : public BHandler {
|
||||
@@ -21,7 +23,7 @@ private:
|
||||
|
||||
// TestApp
|
||||
|
||||
class BTestApp : public BApplication {
|
||||
class CPPUNIT_API BTestApp : public BApplication {
|
||||
public:
|
||||
BTestApp(const char *signature);
|
||||
virtual ~BTestApp();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <SupportDefs.h>
|
||||
|
||||
//! Base class for single threaded unit tests
|
||||
class BTestCase : public CppUnit::TestCase {
|
||||
class CPPUNIT_API BTestCase : public CppUnit::TestCase {
|
||||
public:
|
||||
BTestCase(string Name = "");
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class CppUnit::Exception;
|
||||
You should not need to explicitly use this class in any
|
||||
of your tests.
|
||||
*/
|
||||
class BTestListener : public CppUnit::TestListener {
|
||||
class CPPUNIT_API BTestListener : public CppUnit::TestListener {
|
||||
public:
|
||||
virtual void startTest( CppUnit::Test *test );
|
||||
virtual void addFailure( const CppUnit::TestFailure &failure );
|
||||
|
||||
@@ -46,7 +46,7 @@ typedef CppUnit::SynchronizedObject::SynchronizationObject SyncObject;
|
||||
user can get a list of each test installed via AddSuite(), and optionally
|
||||
can opt to run only a specified set of them.
|
||||
*/
|
||||
class BTestShell {
|
||||
class CPPUNIT_API BTestShell {
|
||||
public:
|
||||
BTestShell(const string &description = "", SyncObject *syncObject = 0);
|
||||
virtual ~BTestShell();
|
||||
@@ -120,13 +120,14 @@ protected:
|
||||
static const char indent[];
|
||||
bool fListTestsAndExit;
|
||||
BPath *fTestDir;
|
||||
BLocker *fPatchGroupLocker;
|
||||
int32 fTLSDebuggerCall;
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
BLocker *fPatchGroupLocker;
|
||||
ElfSymbolPatchGroup *fPatchGroup;
|
||||
void (*fOldDebuggerHook)(const char*);
|
||||
image_id (*fOldLoadAddOnHook)(const char*);
|
||||
status_t (*fOldUnloadAddOnHook)(image_id);
|
||||
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
|
||||
//! Prints a brief description of the program.
|
||||
virtual void PrintDescription(int argc, char *argv[]);
|
||||
@@ -177,6 +178,7 @@ private:
|
||||
//! Prevents the use of the copy operator.
|
||||
void operator =( const BTestShell © );
|
||||
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
void _Debugger(const char* message);
|
||||
image_id _LoadAddOn(const char* path);
|
||||
status_t _UnloadAddOn(image_id image);
|
||||
@@ -184,6 +186,7 @@ private:
|
||||
static void _DebuggerHook(const char* message);
|
||||
static image_id _LoadAddOnHook(const char* path);
|
||||
static status_t _UnloadAddOnHook(image_id image);
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
|
||||
}; // class BTestShell
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
class CppUnit::TestResult;
|
||||
|
||||
//! Groups together a set of tests for a given kit.
|
||||
class BTestSuite : public CppUnit::Test {
|
||||
class CPPUNIT_API BTestSuite : public CppUnit::Test {
|
||||
public:
|
||||
BTestSuite( string name = "" );
|
||||
virtual ~BTestSuite();
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
class BTestSuite;
|
||||
|
||||
extern "C" {
|
||||
BTestSuite* getTestSuite();
|
||||
}
|
||||
extern "C" CPPUNIT_API BTestSuite* getTestSuite();
|
||||
|
||||
#endif // _beos_test_suite_addon_h_
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <string>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
|
||||
// Handy defines :-)
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
#define RES DecodeResult
|
||||
@@ -13,7 +15,7 @@
|
||||
// out just what the R5 libraries are returning.
|
||||
// Returns the same value passed in, so you can
|
||||
// use it inline in tests if necessary.
|
||||
status_t DecodeResult(status_t result);
|
||||
extern CPPUNIT_API status_t DecodeResult(status_t result);
|
||||
|
||||
// First parameter is equal to the second or third
|
||||
template<typename A, typename B, typename C>
|
||||
@@ -26,17 +28,17 @@ Equals(const A &a, const B &b, const C &c)
|
||||
}
|
||||
|
||||
// Returns a string version of the given integer
|
||||
string IntToStr(int i);
|
||||
extern CPPUNIT_API string IntToStr(int i);
|
||||
|
||||
// Calls system() with the concatenated string of command and parameter.
|
||||
void ExecCommand(const char *command, const char *parameter);
|
||||
extern CPPUNIT_API void ExecCommand(const char *command, const char *parameter);
|
||||
|
||||
// Calls system() with the concatenated string of command, parameter1,
|
||||
// " " and parameter2.
|
||||
void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2);
|
||||
extern CPPUNIT_API void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2);
|
||||
|
||||
// Calls system() with the given command (kind of silly, but it's consistent :-)
|
||||
void ExecCommand(const char *command);
|
||||
extern CPPUNIT_API void ExecCommand(const char *command);
|
||||
|
||||
#endif // __beos_test_utils_h__
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
// Helper class to handle thread management
|
||||
template <class TestClass, class ExpectedException>
|
||||
class BThreadManager {
|
||||
class CPPUNIT_API BThreadManager {
|
||||
public:
|
||||
typedef void (TestClass::*ThreadMethod)();
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
class TestResult;
|
||||
|
||||
template <class TestClass, class ExpectedException = CppUnit::NoExceptionExpected>
|
||||
class BThreadedTestCaller : public CppUnit::TestCase {
|
||||
class CPPUNIT_API BThreadedTestCaller : public CppUnit::TestCase {
|
||||
public:
|
||||
/*! \brief Pointer to a test function in the given class.
|
||||
Each ThreadMethod added with addThread() is run in its own thread.
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
//! Base class for single threaded unit tests
|
||||
class BThreadedTestCase : public BTestCase {
|
||||
class CPPUNIT_API BThreadedTestCase : public BTestCase {
|
||||
public:
|
||||
BThreadedTestCase(string Name = "", string progressSeparator = ".");
|
||||
virtual ~BThreadedTestCase();
|
||||
|
||||
@@ -41,7 +41,11 @@
|
||||
|
||||
// CPPUNIT_API is defined in <config_msvc6.h> if required (building or using as dll)
|
||||
#ifndef CPPUNIT_API
|
||||
#define CPPUNIT_API
|
||||
# ifdef BUILDING_CPPUNIT
|
||||
# define CPPUNIT_API _EXPORT
|
||||
# else
|
||||
# define CPPUNIT_API _IMPORT
|
||||
# endif
|
||||
#undef CPPUNIT_NEED_DLL_DECL
|
||||
#define CPPUNIT_NEED_DLL_DECL 0
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "UnitTesterHelper.h"
|
||||
#include <SemaphoreSyncObject.h>
|
||||
#include <Directory.h>
|
||||
@@ -23,16 +25,16 @@ int main(int argc, char *argv[]) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//const std::string UnitTesterShell::defaultLibDir = "./lib";
|
||||
//const string UnitTesterShell::defaultLibDir = "./lib";
|
||||
|
||||
UnitTesterShell::UnitTesterShell(const std::string &description, SyncObject *syncObject)
|
||||
UnitTesterShell::UnitTesterShell(const string &description, SyncObject *syncObject)
|
||||
: BTestShell(description, syncObject)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
UnitTesterShell::PrintDescription(int argc, char *argv[]) {
|
||||
std::string AppName = argv[0];
|
||||
string AppName = argv[0];
|
||||
cout << endl;
|
||||
cout << "This program is the central testing framework for the purpose" << endl;
|
||||
cout << "of testing and verifying the various kits, classes, functions," << endl;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class UnitTesterShell : public BTestShell {
|
||||
public:
|
||||
UnitTesterShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||
UnitTesterShell(const string &description = "", SyncObject *syncObject = 0);
|
||||
protected:
|
||||
virtual void PrintDescription(int argc, char *argv[]);
|
||||
virtual void PrintValidArguments();
|
||||
|
||||
@@ -6,13 +6,20 @@ rule CppUnitLibrary
|
||||
{
|
||||
# CppUnitLibrary <sources> ;
|
||||
local _lib = libcppunit.so ;
|
||||
|
||||
|
||||
UseCppUnitHeaders ;
|
||||
SetupObjectsDir ;
|
||||
MakeLocateObjects [ FGristFiles $(<) ] ;
|
||||
BuildPlatformMain $(_lib) : $(<) ;
|
||||
MakeLocateObjects [ FGristFiles $(1) ] ;
|
||||
BuildPlatformMain $(_lib) : $(1) ;
|
||||
MakeLocate $(_lib) : /boot/home/config/lib ;
|
||||
LINKFLAGS on $(_lib) = $(LINKFLAGS) -nostart -Xlinker -soname=\"$(_lib)\" ;
|
||||
|
||||
local defines = BUILDING_CPPUNIT ;
|
||||
|
||||
if $(OS) = BEOS && $(OSPLAT) = PPC {
|
||||
defines += NO_ELF_SYMBOL_PATCHING ;
|
||||
}
|
||||
ObjectsDefines $(1) : $(defines) ;
|
||||
}
|
||||
|
||||
CppUnitLibrary
|
||||
@@ -49,7 +56,10 @@ CppUnitLibrary
|
||||
;
|
||||
|
||||
LinkSharedOSLibs libcppunit.so :
|
||||
stdc++.r4
|
||||
/boot/develop/lib/x86/libbe.so
|
||||
libelfsymbolpatcher.a
|
||||
stdc++.r4 # is called `mslcpp_4_0' on PPC -- just create a symlink
|
||||
be
|
||||
;
|
||||
|
||||
if $(OS) != BEOS || $(OSPLAT) != PPC {
|
||||
LinkSharedOSLibs libcppunit.so : libelfsymbolpatcher.a ;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <SemaphoreSyncObject.h>
|
||||
#include <cppunit/Exception.h>
|
||||
|
||||
_EXPORT
|
||||
SemaphoreSyncObject::SemaphoreSyncObject()
|
||||
: fSemId(create_sem(1, "CppUnitSync"))
|
||||
{
|
||||
@@ -8,16 +9,19 @@ SemaphoreSyncObject::SemaphoreSyncObject()
|
||||
throw CppUnit::Exception("SemaphoreSyncObject::SemaphoreSyncObject() -- Error creating semaphore");
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
SemaphoreSyncObject::~SemaphoreSyncObject() {
|
||||
delete_sem(fSemId);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
SemaphoreSyncObject::lock() {
|
||||
if (acquire_sem(fSemId) < B_OK)
|
||||
throw CppUnit::Exception("SemaphoreSyncObject::lock() -- Error acquiring semaphore");
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
SemaphoreSyncObject::unlock() {
|
||||
if (release_sem(fSemId) < B_OK)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// TestHandler
|
||||
|
||||
// MessageReceived
|
||||
_EXPORT
|
||||
void
|
||||
BTestHandler::MessageReceived(BMessage *message)
|
||||
{
|
||||
@@ -18,6 +19,7 @@ BTestHandler::MessageReceived(BMessage *message)
|
||||
}
|
||||
|
||||
// Queue
|
||||
_EXPORT
|
||||
BMessageQueue &
|
||||
BTestHandler::Queue()
|
||||
{
|
||||
@@ -28,6 +30,7 @@ BTestHandler::Queue()
|
||||
// TestApp
|
||||
|
||||
// constructor
|
||||
_EXPORT
|
||||
BTestApp::BTestApp(const char *signature)
|
||||
: BApplication(signature),
|
||||
fAppThread(B_ERROR),
|
||||
@@ -38,6 +41,7 @@ BTestApp::BTestApp(const char *signature)
|
||||
}
|
||||
|
||||
// destructor
|
||||
_EXPORT
|
||||
BTestApp::~BTestApp()
|
||||
{
|
||||
int32 count = fHandlers.CountItems();
|
||||
@@ -46,6 +50,7 @@ BTestApp::~BTestApp()
|
||||
}
|
||||
|
||||
// Init
|
||||
_EXPORT
|
||||
status_t
|
||||
BTestApp::Init()
|
||||
{
|
||||
@@ -65,6 +70,7 @@ BTestApp::Init()
|
||||
}
|
||||
|
||||
// Terminate
|
||||
_EXPORT
|
||||
void
|
||||
BTestApp::Terminate()
|
||||
{
|
||||
@@ -74,12 +80,14 @@ BTestApp::Terminate()
|
||||
}
|
||||
|
||||
// ReadyToRun
|
||||
_EXPORT
|
||||
void
|
||||
BTestApp::ReadyToRun()
|
||||
{
|
||||
}
|
||||
|
||||
// CreateTestHandler
|
||||
_EXPORT
|
||||
BTestHandler *
|
||||
BTestApp::CreateTestHandler()
|
||||
{
|
||||
@@ -92,6 +100,7 @@ BTestApp::CreateTestHandler()
|
||||
}
|
||||
|
||||
// DeleteTestHandler
|
||||
_EXPORT
|
||||
bool
|
||||
BTestApp::DeleteTestHandler(BTestHandler *handler)
|
||||
{
|
||||
@@ -107,6 +116,7 @@ BTestApp::DeleteTestHandler(BTestHandler *handler)
|
||||
}
|
||||
|
||||
// Handler
|
||||
_EXPORT
|
||||
BTestHandler &
|
||||
BTestApp::Handler()
|
||||
{
|
||||
@@ -116,6 +126,7 @@ BTestApp::Handler()
|
||||
}
|
||||
|
||||
// TestHandlerAt
|
||||
_EXPORT
|
||||
BTestHandler *
|
||||
BTestApp::TestHandlerAt(int32 index)
|
||||
{
|
||||
@@ -124,6 +135,7 @@ BTestApp::TestHandlerAt(int32 index)
|
||||
}
|
||||
|
||||
// _AppThreadStart
|
||||
_EXPORT
|
||||
int32
|
||||
BTestApp::_AppThreadStart(void *data)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
_EXPORT
|
||||
BTestCase::BTestCase(string name)
|
||||
: CppUnit::TestCase(name)
|
||||
, fValidCWD(false)
|
||||
@@ -11,12 +12,14 @@ BTestCase::BTestCase(string name)
|
||||
{
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::tearDown() {
|
||||
if (fSubTestNum != 0)
|
||||
NextSubTestBlock();
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::NextSubTest() {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
@@ -25,12 +28,14 @@ BTestCase::NextSubTest() {
|
||||
}
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::NextSubTestBlock() {
|
||||
if (BTestShell::GlobalBeVerbose())
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::Outputf(const char *str, ...) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
@@ -43,6 +48,7 @@ BTestCase::Outputf(const char *str, ...) {
|
||||
}
|
||||
|
||||
/*! To return to the last saved working directory, call RestoreCWD(). */
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::SaveCWD() {
|
||||
fValidCWD = getcwd(fCurrentWorkingDir, B_PATH_NAME_LENGTH);
|
||||
@@ -53,6 +59,7 @@ BTestCase::SaveCWD() {
|
||||
changed to alternate. If alternate is null, the current working directory
|
||||
is not modified.
|
||||
*/
|
||||
_EXPORT
|
||||
void
|
||||
BTestCase::RestoreCWD(const char *alternate) {
|
||||
if (fValidCWD)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <stdio.h>
|
||||
#include <OS.h>
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestListener::startTest( CppUnit::Test *test ) {
|
||||
fOkay = true;
|
||||
@@ -14,6 +15,7 @@ BTestListener::startTest( CppUnit::Test *test ) {
|
||||
startTime = real_time_clock_usecs();
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestListener::addFailure( const CppUnit::TestFailure &failure ) {
|
||||
fOkay = false;
|
||||
@@ -26,6 +28,7 @@ BTestListener::addFailure( const CppUnit::TestFailure &failure ) {
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestListener::endTest( CppUnit::Test *test ) {
|
||||
bigtime_t length = real_time_clock_usecs() - startTime;
|
||||
@@ -37,6 +40,7 @@ BTestListener::endTest( CppUnit::Test *test ) {
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestListener::printTime(bigtime_t time) {
|
||||
// Print out the elapsed time all pretty and stuff:
|
||||
|
||||
@@ -21,32 +21,42 @@
|
||||
|
||||
#include <TestShell.h>
|
||||
#include <TestListener.h>
|
||||
#include <ElfSymbolPatcher.h>
|
||||
|
||||
BTestShell *BTestShell::fGlobalShell = NULL;
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
# include <ElfSymbolPatcher.h>
|
||||
#endif
|
||||
|
||||
_EXPORT BTestShell *BTestShell::fGlobalShell = NULL;
|
||||
const char BTestShell::indent[] = " ";
|
||||
|
||||
_EXPORT
|
||||
BTestShell::BTestShell(const string &description, SyncObject *syncObject)
|
||||
: fVerbosityLevel(v2)
|
||||
, fTestResults(syncObject)
|
||||
, fDescription(description)
|
||||
, fListTestsAndExit(false)
|
||||
, fTestDir(NULL)
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
, fPatchGroupLocker(new(nothrow) BLocker)
|
||||
, fPatchGroup(NULL)
|
||||
, fOldDebuggerHook(NULL)
|
||||
, fOldLoadAddOnHook(NULL)
|
||||
, fOldUnloadAddOnHook(NULL)
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
{
|
||||
fTLSDebuggerCall = tls_allocate();
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
BTestShell::~BTestShell() {
|
||||
delete fTestDir;
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
delete fPatchGroupLocker;
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
}
|
||||
|
||||
|
||||
_EXPORT
|
||||
status_t
|
||||
BTestShell::AddSuite(BTestSuite *suite) {
|
||||
if (suite) {
|
||||
@@ -71,6 +81,7 @@ BTestShell::AddSuite(BTestSuite *suite) {
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::AddTest(const string &name, CppUnit::Test *test) {
|
||||
if (test != NULL)
|
||||
@@ -79,6 +90,7 @@ BTestShell::AddTest(const string &name, CppUnit::Test *test) {
|
||||
fTests.erase(name);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
int32
|
||||
BTestShell::LoadSuitesFrom(BDirectory *libDir) {
|
||||
if (!libDir || libDir->InitCheck() != B_OK)
|
||||
@@ -117,6 +129,7 @@ BTestShell::LoadSuitesFrom(BDirectory *libDir) {
|
||||
return count;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
int
|
||||
BTestShell::Run(int argc, char *argv[]) {
|
||||
// Make note of which directory we started in
|
||||
@@ -206,11 +219,13 @@ BTestShell::Run(int argc, char *argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
BTestShell::VerbosityLevel
|
||||
BTestShell::Verbosity() const {
|
||||
return fVerbosityLevel;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
const char*
|
||||
BTestShell::TestDir() const {
|
||||
return (fTestDir ? fTestDir->Path() : NULL);
|
||||
@@ -222,6 +237,7 @@ BTestShell::TestDir() const {
|
||||
A subsequent call of debugger() will be intercepted and a respective
|
||||
flag will be set. WasDebuggerCalled() will then return \c true.
|
||||
*/
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::ExpectDebuggerCall()
|
||||
{
|
||||
@@ -238,6 +254,7 @@ BTestShell::ExpectDebuggerCall()
|
||||
\return \c true, if debugger() has been called by the current thread since
|
||||
the last invocation of ExpectDebuggerCall(), \c false otherwise.
|
||||
*/
|
||||
_EXPORT
|
||||
bool
|
||||
BTestShell::WasDebuggerCalled()
|
||||
{
|
||||
@@ -246,11 +263,13 @@ BTestShell::WasDebuggerCalled()
|
||||
return ((int)var > 1);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::PrintDescription(int argc, char *argv[]) {
|
||||
cout << endl << fDescription;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::PrintHelp() {
|
||||
cout << endl;
|
||||
@@ -260,6 +279,7 @@ BTestShell::PrintHelp() {
|
||||
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::PrintValidArguments() {
|
||||
cout << indent << "--help Displays this help text plus some other garbage" << endl;
|
||||
@@ -281,6 +301,7 @@ BTestShell::PrintValidArguments() {
|
||||
cout << indent << " libraries" << endl;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::PrintInstalledTests() {
|
||||
// Print out the list of installed suites
|
||||
@@ -302,6 +323,7 @@ BTestShell::PrintInstalledTests() {
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
bool
|
||||
BTestShell::ProcessArguments(int argc, char *argv[]) {
|
||||
// If we're given no parameters, the default settings
|
||||
@@ -321,6 +343,7 @@ BTestShell::ProcessArguments(int argc, char *argv[]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
bool
|
||||
BTestShell::ProcessArgument(string arg, int argc, char *argv[]) {
|
||||
if (arg == "--help") {
|
||||
@@ -347,6 +370,7 @@ BTestShell::ProcessArgument(string arg, int argc, char *argv[]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::InitOutput() {
|
||||
// For vebosity level 2, we output info about each test
|
||||
@@ -361,6 +385,7 @@ BTestShell::InitOutput() {
|
||||
fTestResults.addListener(&fResultsCollector);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::PrintResults() {
|
||||
|
||||
@@ -411,6 +436,7 @@ BTestShell::PrintResults() {
|
||||
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::LoadDynamicSuites() {
|
||||
if (Verbosity() >= v3) {
|
||||
@@ -447,6 +473,7 @@ BTestShell::LoadDynamicSuites() {
|
||||
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::UpdateTestDir(char *argv[]) {
|
||||
BPath path(argv[0]);
|
||||
@@ -465,9 +492,11 @@ BTestShell::UpdateTestDir(char *argv[]) {
|
||||
load_add_on() and unload_add_on() are patches as well, to keep the
|
||||
patch group up to date, when images are loaded/unloaded.
|
||||
*/
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::InstallPatches()
|
||||
{
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
if (fPatchGroup) {
|
||||
cerr << "BTestShell::InstallPatches(): Patch group already exist!"
|
||||
<< endl;
|
||||
@@ -503,14 +532,17 @@ BTestShell::InstallPatches()
|
||||
<< endl;
|
||||
UninstallPatches();
|
||||
}
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
}
|
||||
|
||||
// UninstallPatches
|
||||
/*! \brief Undoes the patches applied by InstallPatches().
|
||||
*/
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::UninstallPatches()
|
||||
{
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
BAutolock locker(fPatchGroupLocker);
|
||||
if (!locker.IsLocked()) {
|
||||
cerr << "BTestShell::UninstallPatches(): "
|
||||
@@ -522,9 +554,13 @@ BTestShell::UninstallPatches()
|
||||
delete fPatchGroup;
|
||||
fPatchGroup = NULL;
|
||||
}
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
}
|
||||
|
||||
#ifndef NO_ELF_SYMBOL_PATCHING
|
||||
|
||||
// _Debugger
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::_Debugger(const char *message)
|
||||
{
|
||||
@@ -546,6 +582,7 @@ cout << "debugger() called: " << message << endl;
|
||||
}
|
||||
|
||||
// _LoadAddOn
|
||||
_EXPORT
|
||||
image_id
|
||||
BTestShell::_LoadAddOn(const char *path)
|
||||
{
|
||||
@@ -560,6 +597,7 @@ BTestShell::_LoadAddOn(const char *path)
|
||||
}
|
||||
|
||||
// _UnloadAddOn
|
||||
_EXPORT
|
||||
status_t
|
||||
BTestShell::_UnloadAddOn(image_id image)
|
||||
{
|
||||
@@ -577,6 +615,7 @@ BTestShell::_UnloadAddOn(image_id image)
|
||||
}
|
||||
|
||||
// _DebuggerHook
|
||||
_EXPORT
|
||||
void
|
||||
BTestShell::_DebuggerHook(const char *message)
|
||||
{
|
||||
@@ -584,6 +623,7 @@ BTestShell::_DebuggerHook(const char *message)
|
||||
}
|
||||
|
||||
// _LoadAddOnHook
|
||||
_EXPORT
|
||||
image_id
|
||||
BTestShell::_LoadAddOnHook(const char *path)
|
||||
{
|
||||
@@ -591,9 +631,11 @@ BTestShell::_LoadAddOnHook(const char *path)
|
||||
}
|
||||
|
||||
// _UnloadAddOnHook
|
||||
_EXPORT
|
||||
status_t
|
||||
BTestShell::_UnloadAddOnHook(image_id image)
|
||||
{
|
||||
return fGlobalShell->_UnloadAddOn(image);
|
||||
}
|
||||
|
||||
#endif // ! NO_ELF_SYMBOL_PATCHING
|
||||
|
||||
@@ -3,18 +3,21 @@
|
||||
#include <cppunit/TestResult.h>
|
||||
|
||||
// Default constructor
|
||||
_EXPORT
|
||||
BTestSuite::BTestSuite( string name )
|
||||
: fName(name)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
_EXPORT
|
||||
BTestSuite::~BTestSuite() {
|
||||
deleteContents();
|
||||
}
|
||||
|
||||
|
||||
// Deletes all tests in the suite.
|
||||
_EXPORT
|
||||
void
|
||||
BTestSuite::deleteContents() {
|
||||
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
||||
@@ -26,6 +29,7 @@ BTestSuite::deleteContents() {
|
||||
|
||||
|
||||
/// Runs the tests and collects their result in a TestResult.
|
||||
_EXPORT
|
||||
void
|
||||
BTestSuite::run( CppUnit::TestResult *result ) {
|
||||
for ( map<string, CppUnit::Test*>::iterator it = fTests.begin();
|
||||
@@ -42,6 +46,7 @@ BTestSuite::run( CppUnit::TestResult *result ) {
|
||||
|
||||
|
||||
// Counts the number of test cases that will be run by this test.
|
||||
_EXPORT
|
||||
int
|
||||
BTestSuite::countTestCases() const {
|
||||
int count = 0;
|
||||
@@ -56,6 +61,7 @@ BTestSuite::countTestCases() const {
|
||||
|
||||
|
||||
// Adds a test to the suite.
|
||||
_EXPORT
|
||||
void
|
||||
BTestSuite::addTest(string name, CppUnit::Test *test) {
|
||||
fTests[name] = test;
|
||||
@@ -63,6 +69,7 @@ BTestSuite::addTest(string name, CppUnit::Test *test) {
|
||||
|
||||
|
||||
// Returns a string representation of the test suite.
|
||||
_EXPORT
|
||||
string
|
||||
BTestSuite::toString() const {
|
||||
return "suite " + getName();
|
||||
@@ -70,12 +77,14 @@ BTestSuite::toString() const {
|
||||
|
||||
|
||||
// Returns the name of the test suite.
|
||||
_EXPORT
|
||||
string
|
||||
BTestSuite::getName() const {
|
||||
return fName;
|
||||
}
|
||||
|
||||
|
||||
_EXPORT
|
||||
const map<string, CppUnit::Test*> &
|
||||
BTestSuite::getTests() const {
|
||||
return fTests;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
_EXPORT
|
||||
status_t DecodeResult(status_t result) {
|
||||
if (!BTestShell::GlobalBeVerbose())
|
||||
return result;
|
||||
@@ -178,17 +179,20 @@ status_t DecodeResult(status_t result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
string IntToStr(int i) {
|
||||
char num[32];
|
||||
sprintf(num, "%d", i);
|
||||
return string(num);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void ExecCommand(const char *command) {
|
||||
if (command)
|
||||
system(command);
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void ExecCommand(const char *command, const char *parameter) {
|
||||
if (command && parameter) {
|
||||
char *cmdLine = new char[strlen(command) + strlen(parameter) + 1];
|
||||
@@ -199,6 +203,7 @@ void ExecCommand(const char *command, const char *parameter) {
|
||||
}
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2) {
|
||||
if (command && parameter1 && parameter2) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include <TestShell.h>
|
||||
#include <ThreadedTestCase.h>
|
||||
#include <Autolock.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
_EXPORT
|
||||
BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
|
||||
: BTestCase(name)
|
||||
, fProgressSeparator(progressSeparator)
|
||||
@@ -10,6 +12,7 @@ BThreadedTestCase::BThreadedTestCase(string name, string progressSeparator)
|
||||
{
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
BThreadedTestCase::~BThreadedTestCase() {
|
||||
// Kill our locker
|
||||
delete fUpdateLock;
|
||||
@@ -23,6 +26,7 @@ BThreadedTestCase::~BThreadedTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BThreadedTestCase::NextSubTest() {
|
||||
// Find out what thread we're in
|
||||
@@ -47,6 +51,7 @@ BThreadedTestCase::NextSubTest() {
|
||||
BTestCase::NextSubTest();
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BThreadedTestCase::Outputf(const char *str, ...) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
@@ -78,6 +83,7 @@ BThreadedTestCase::Outputf(const char *str, ...) {
|
||||
}
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BThreadedTestCase::InitThreadInfo(thread_id id, string threadName) {
|
||||
BAutolock lock(fUpdateLock); // Lock the number map
|
||||
@@ -94,6 +100,7 @@ BThreadedTestCase::InitThreadInfo(thread_id id, string threadName) {
|
||||
}
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
bool
|
||||
BThreadedTestCase::RegisterForUse() {
|
||||
if (!fInUse) {
|
||||
@@ -103,17 +110,20 @@ BThreadedTestCase::RegisterForUse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BThreadedTestCase::UnregisterForUse() {
|
||||
fInUse = false;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
vector<string>&
|
||||
BThreadedTestCase::AcquireUpdateList() {
|
||||
fUpdateLock->Lock();
|
||||
return fUpdateList;
|
||||
}
|
||||
|
||||
_EXPORT
|
||||
void
|
||||
BThreadedTestCase::ReleaseUpdateList() {
|
||||
fUpdateLock->Unlock();
|
||||
|
||||
Reference in New Issue
Block a user