diff --git a/headers/tools/cppunit/LockerSyncObject.h b/headers/tools/cppunit/LockerSyncObject.h index 8b1e8208b6..24e58f8dc8 100644 --- a/headers/tools/cppunit/LockerSyncObject.h +++ b/headers/tools/cppunit/LockerSyncObject.h @@ -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() {} diff --git a/headers/tools/cppunit/SemaphoreSyncObject.h b/headers/tools/cppunit/SemaphoreSyncObject.h index dd09658e04..619a4dd18d 100644 --- a/headers/tools/cppunit/SemaphoreSyncObject.h +++ b/headers/tools/cppunit/SemaphoreSyncObject.h @@ -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(); diff --git a/headers/tools/cppunit/TestApp.h b/headers/tools/cppunit/TestApp.h index d43640545d..40f95f6e95 100644 --- a/headers/tools/cppunit/TestApp.h +++ b/headers/tools/cppunit/TestApp.h @@ -7,6 +7,8 @@ #include #include +#include + // 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(); diff --git a/headers/tools/cppunit/TestCase.h b/headers/tools/cppunit/TestCase.h index 14aa89164e..ba69063fdf 100644 --- a/headers/tools/cppunit/TestCase.h +++ b/headers/tools/cppunit/TestCase.h @@ -6,7 +6,7 @@ #include //! Base class for single threaded unit tests -class BTestCase : public CppUnit::TestCase { +class CPPUNIT_API BTestCase : public CppUnit::TestCase { public: BTestCase(string Name = ""); diff --git a/headers/tools/cppunit/TestListener.h b/headers/tools/cppunit/TestListener.h index 8128c79324..c271c597e6 100644 --- a/headers/tools/cppunit/TestListener.h +++ b/headers/tools/cppunit/TestListener.h @@ -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 ); diff --git a/headers/tools/cppunit/TestShell.h b/headers/tools/cppunit/TestShell.h index b989c9a78f..3e86b79073 100644 --- a/headers/tools/cppunit/TestShell.h +++ b/headers/tools/cppunit/TestShell.h @@ -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 diff --git a/headers/tools/cppunit/TestSuite.h b/headers/tools/cppunit/TestSuite.h index c32ad7c20b..9113f0a7ba 100644 --- a/headers/tools/cppunit/TestSuite.h +++ b/headers/tools/cppunit/TestSuite.h @@ -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(); diff --git a/headers/tools/cppunit/TestSuiteAddon.h b/headers/tools/cppunit/TestSuiteAddon.h index 2ef6f0dc03..b5e8d94783 100644 --- a/headers/tools/cppunit/TestSuiteAddon.h +++ b/headers/tools/cppunit/TestSuiteAddon.h @@ -3,8 +3,6 @@ class BTestSuite; -extern "C" { - BTestSuite* getTestSuite(); -} +extern "C" CPPUNIT_API BTestSuite* getTestSuite(); #endif // _beos_test_suite_addon_h_ diff --git a/headers/tools/cppunit/TestUtils.h b/headers/tools/cppunit/TestUtils.h index 48fe0c661e..117e7f177e 100644 --- a/headers/tools/cppunit/TestUtils.h +++ b/headers/tools/cppunit/TestUtils.h @@ -4,6 +4,8 @@ #include #include +#include + // 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 @@ -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__ diff --git a/headers/tools/cppunit/ThreadManager.h b/headers/tools/cppunit/ThreadManager.h index 5e1ff0b875..712dee6ca0 100644 --- a/headers/tools/cppunit/ThreadManager.h +++ b/headers/tools/cppunit/ThreadManager.h @@ -13,7 +13,7 @@ // Helper class to handle thread management template -class BThreadManager { +class CPPUNIT_API BThreadManager { public: typedef void (TestClass::*ThreadMethod)(); diff --git a/headers/tools/cppunit/ThreadedTestCaller.h b/headers/tools/cppunit/ThreadedTestCaller.h index daee1a1151..8f078f430e 100644 --- a/headers/tools/cppunit/ThreadedTestCaller.h +++ b/headers/tools/cppunit/ThreadedTestCaller.h @@ -14,7 +14,7 @@ class TestResult; template -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. diff --git a/headers/tools/cppunit/ThreadedTestCase.h b/headers/tools/cppunit/ThreadedTestCase.h index d62a67c7d0..95601686c9 100644 --- a/headers/tools/cppunit/ThreadedTestCase.h +++ b/headers/tools/cppunit/ThreadedTestCase.h @@ -9,7 +9,7 @@ #include //! 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(); diff --git a/headers/tools/cppunit/cppunit/Portability.h b/headers/tools/cppunit/cppunit/Portability.h index c1151042c7..30ddc3e91e 100644 --- a/headers/tools/cppunit/cppunit/Portability.h +++ b/headers/tools/cppunit/cppunit/Portability.h @@ -41,7 +41,11 @@ // CPPUNIT_API is defined in 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 diff --git a/src/tests/UnitTesterHelper.cpp b/src/tests/UnitTesterHelper.cpp index ee4f2244a6..51fc2d0e5d 100644 --- a/src/tests/UnitTesterHelper.cpp +++ b/src/tests/UnitTesterHelper.cpp @@ -1,3 +1,5 @@ +#include + #include "UnitTesterHelper.h" #include #include @@ -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; diff --git a/src/tests/UnitTesterHelper.h b/src/tests/UnitTesterHelper.h index a5fcf4078f..4d2f463b2b 100644 --- a/src/tests/UnitTesterHelper.h +++ b/src/tests/UnitTesterHelper.h @@ -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(); diff --git a/src/tools/cppunit/Jamfile b/src/tools/cppunit/Jamfile index 75fc4664dd..92cb97adce 100644 --- a/src/tools/cppunit/Jamfile +++ b/src/tools/cppunit/Jamfile @@ -6,13 +6,20 @@ rule CppUnitLibrary { # CppUnitLibrary ; 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 ; +} diff --git a/src/tools/cppunit/SemaphoreSyncObject.cpp b/src/tools/cppunit/SemaphoreSyncObject.cpp index 017a7b0401..01e93ff949 100644 --- a/src/tools/cppunit/SemaphoreSyncObject.cpp +++ b/src/tools/cppunit/SemaphoreSyncObject.cpp @@ -1,6 +1,7 @@ #include #include +_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) diff --git a/src/tools/cppunit/TestApp.cpp b/src/tools/cppunit/TestApp.cpp index bb3e982f8e..1e5b9d4f61 100644 --- a/src/tools/cppunit/TestApp.cpp +++ b/src/tools/cppunit/TestApp.cpp @@ -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) { diff --git a/src/tools/cppunit/TestCase.cpp b/src/tools/cppunit/TestCase.cpp index 6065b56cf4..52b0bff6ee 100644 --- a/src/tools/cppunit/TestCase.cpp +++ b/src/tools/cppunit/TestCase.cpp @@ -4,6 +4,7 @@ #include #include +_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) diff --git a/src/tools/cppunit/TestListener.cpp b/src/tools/cppunit/TestListener.cpp index e394b4cf3a..4a2deb7eac 100644 --- a/src/tools/cppunit/TestListener.cpp +++ b/src/tools/cppunit/TestListener.cpp @@ -7,6 +7,7 @@ #include #include +_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: diff --git a/src/tools/cppunit/TestShell.cpp b/src/tools/cppunit/TestShell.cpp index bb1244232b..52eeb3932c 100644 --- a/src/tools/cppunit/TestShell.cpp +++ b/src/tools/cppunit/TestShell.cpp @@ -21,32 +21,42 @@ #include #include -#include -BTestShell *BTestShell::fGlobalShell = NULL; +#ifndef NO_ELF_SYMBOL_PATCHING +# include +#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 diff --git a/src/tools/cppunit/TestSuite.cpp b/src/tools/cppunit/TestSuite.cpp index b41994bb37..26e8c8630f 100644 --- a/src/tools/cppunit/TestSuite.cpp +++ b/src/tools/cppunit/TestSuite.cpp @@ -3,18 +3,21 @@ #include // 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::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::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 & BTestSuite::getTests() const { return fTests; diff --git a/src/tools/cppunit/TestUtils.cpp b/src/tools/cppunit/TestUtils.cpp index 9112769436..13831494e6 100644 --- a/src/tools/cppunit/TestUtils.cpp +++ b/src/tools/cppunit/TestUtils.cpp @@ -5,6 +5,7 @@ #include #include +_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) { diff --git a/src/tools/cppunit/ThreadedTestCase.cpp b/src/tools/cppunit/ThreadedTestCase.cpp index 61038c82fb..2d753cc959 100644 --- a/src/tools/cppunit/ThreadedTestCase.cpp +++ b/src/tools/cppunit/ThreadedTestCase.cpp @@ -1,8 +1,10 @@ #include #include #include -#include +#include +#include +_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& BThreadedTestCase::AcquireUpdateList() { fUpdateLock->Lock(); return fUpdateList; } +_EXPORT void BThreadedTestCase::ReleaseUpdateList() { fUpdateLock->Unlock();