+ Moved BAutolock and BArchivable over to new testing framework.
+ Added ability to specify entire suites to the UnitTester program. + BAutolock and BArchivable tests now use CPPUNIT_ASSERT, but BLocker tests crash for some unknown reason with said assertion, so plain old vanilla assert() is still used. I'll look into this later. + BArchivable tests that try to load a RemoteTestObject are failing because the resource file doesn't appear to be linked into libsupporttest_RemoteTestObject.so. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@332 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -83,11 +83,15 @@ public:
|
||||
static const char* GlobalTestDir() { return (fGlobalShell ? fGlobalShell->TestDir() : NULL); };
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
typedef std::map<std::string, CppUnit::Test*> TestMap;
|
||||
typedef std::map<std::string, BTestSuite*> SuiteMap;
|
||||
|
||||
VerbosityLevel fVerbosityLevel;
|
||||
std::set<std::string> fTestsToRun;
|
||||
std::map<std::string, CppUnit::Test*> fTests;
|
||||
std::map<std::string, BTestSuite*> fSuites;
|
||||
std::set<std::string> fSuitesToRun;
|
||||
TestMap fTests;
|
||||
SuiteMap fSuites;
|
||||
std::set<std::string> fLibDirs;
|
||||
CppUnit::TestResult fTestResults;
|
||||
CppUnit::TestResultCollector fResultsCollector;
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
// use it inline in tests if necessary.
|
||||
status_t DecodeResult(status_t result);
|
||||
|
||||
// Returns a string version of the given integer
|
||||
std::string IntToStr(int i);
|
||||
|
||||
// Calls system() with the concatenated string of command and parameter.
|
||||
void ExecCommand(const char *command, const char *parameter);
|
||||
|
||||
|
||||
@@ -176,10 +176,13 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
||||
// If we get this far, we actually managed to acquire the semaphore,
|
||||
// so we should release it now.
|
||||
release_sem_etc(fThreadSem, fThreads.size(), 0);
|
||||
|
||||
// Print out a newline for asthetics :-)
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
// Wait for them all to finish, then clean up
|
||||
for (ThreadManagerMap::iterator i = fThreads.begin();
|
||||
i != fThreads.end ();
|
||||
@@ -254,7 +257,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::tearDown() {
|
||||
template <class TestClass, class ExpectedException>
|
||||
std::string
|
||||
BThreadedTestCaller<TestClass, ExpectedException>::toString() const {
|
||||
return "BThreadedTestCaller for " + getName();
|
||||
return std::string("BThreadedTestCaller for ") + getName();
|
||||
}
|
||||
|
||||
#endif // _beos_threaded_test_caller_h_
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <kernel/OS.h>
|
||||
#include <TestUtils.h>
|
||||
|
||||
ExampleTest::ExampleTest(std::string name)
|
||||
: BThreadedTestCase(name)
|
||||
@@ -33,6 +34,13 @@ ExampleTest::Suite() {
|
||||
caller->addThread("Thread3", &ExampleTest::TestFunc1);
|
||||
suite->addTest(caller);
|
||||
|
||||
// And one that fails, if you're so inclined
|
||||
caller = new BThreadedTestCaller<ExampleTest>("ExampleTests::MultiThreaded Failing Test");
|
||||
caller->addThread("GoodThread1", &ExampleTest::TestFunc1);
|
||||
caller->addThread("GoodThread2", &ExampleTest::TestFunc2);
|
||||
caller->addThread("BadThread", &ExampleTest::FailureFunc);
|
||||
suite->addTest(caller);
|
||||
|
||||
// And some single threaded ones
|
||||
suite->addTest(new CppUnit::TestCaller<ExampleTest>("ExampleTests::SingleThreaded Test #1", &ExampleTest::TestFunc1));
|
||||
suite->addTest(new CppUnit::TestCaller<ExampleTest>("ExampleTests::SingleThreaded Test #2", &ExampleTest::TestFunc2));
|
||||
@@ -81,3 +89,8 @@ ExampleTest::TestFunc3() {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ExampleTest::FailureFunc() {
|
||||
CHK(true == false);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
void TestFunc1(); // num += 10
|
||||
void TestFunc2(); // num *= 2
|
||||
void TestFunc3(); // num -= 5
|
||||
void FailureFunc(); // Fails assertion
|
||||
protected:
|
||||
BLocker *fLocker;
|
||||
int fNum;
|
||||
|
||||
@@ -51,9 +51,9 @@ UnitTesterShell::PrintDescription(int argc, char *argv[]) {
|
||||
void
|
||||
UnitTesterShell::PrintValidArguments() {
|
||||
BTestShell::PrintValidArguments();
|
||||
cout << indent << "-obos Runs tests linked against our OpenBeOS libraries (*default*)" << endl;
|
||||
cout << indent << "-r5 Runs tests linked against Be Inc.'s R5 libraries (instead" << endl;
|
||||
cout << indent << " of our libraries) for the sake of comparison." << endl;
|
||||
cout << indent << "-obos Runs tests linked against our OpenBeOS libraries (*default*)" << endl;
|
||||
cout << indent << "-r5 Runs tests linked against Be Inc.'s R5 libraries (instead" << endl;
|
||||
cout << indent << " of our libraries) for the sake of comparison." << endl;
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -1,15 +1,45 @@
|
||||
SubDir OBOS_TOP src tests kits support ;
|
||||
|
||||
# Let Jam know where to find some of our source files
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) barchivable ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) bautolock ] ;
|
||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) blocker ] ;
|
||||
|
||||
CommonTestLib libsupporttest.so
|
||||
: SupportKitTestAddon.cpp
|
||||
|
||||
# BArchivable
|
||||
ArchivableTest.cpp
|
||||
BArchivableTester.cpp
|
||||
FindInstantiationFuncTester.cpp
|
||||
InstantiateObjectTester.cpp
|
||||
LocalTestObject.cpp
|
||||
ValidateInstantiationTester.cpp
|
||||
|
||||
# BAutolock
|
||||
AutolockTest.cpp
|
||||
AutolockLockerTest.cpp
|
||||
AutolockLooperTest.cpp
|
||||
|
||||
# BLocker (all in ./blocker)
|
||||
LockerTest.cpp
|
||||
BenaphoreLockCountTest1.cpp
|
||||
ConcurrencyTest1.cpp
|
||||
ConcurrencyTest2.cpp
|
||||
ConstructionTest1.cpp
|
||||
DestructionTest1.cpp
|
||||
DestructionTest2.cpp
|
||||
LockerTestCase.cpp
|
||||
SemaphoreLockCountTest1.cpp
|
||||
|
||||
: <boot!home!config!lib>libopenbeos.so
|
||||
be stdc++.r4
|
||||
: be stdc++.r4
|
||||
: libsupporttest_blocker.so
|
||||
: libsupporttest_RemoteTestObject.so
|
||||
: support
|
||||
;
|
||||
|
||||
#SubInclude OBOS_TOP src tests kits support barchivable ;
|
||||
SubInclude OBOS_TOP src tests kits support barchivable ;
|
||||
#SubInclude OBOS_TOP src tests kits support bautolock ;
|
||||
SubInclude OBOS_TOP src tests kits support blocker ;
|
||||
#SubInclude OBOS_TOP src tests kits support blocker ;
|
||||
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
#include <TestSuiteAddon.h>
|
||||
|
||||
// ##### Include headers for your tests here #####
|
||||
#include "barchivable/ArchivableTest.h"
|
||||
#include "bautolock/AutolockTest.h"
|
||||
#include "blocker/LockerTest.h"
|
||||
|
||||
BTestSuite* getTestSuite() {
|
||||
BTestSuite *suite = new BTestSuite("Support");
|
||||
|
||||
// ##### Add test suites here #####
|
||||
suite->addTest("BArchivable", ArchivableTestSuite());
|
||||
suite->addTest("BAutolock", AutolockTestSuite());
|
||||
suite->addTest("BLocker", LockerTestSuite());
|
||||
|
||||
return suite;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
$Id:
|
||||
*/
|
||||
|
||||
#include "BArchivableTester.h"
|
||||
#include "ValidateInstantiationTester.h"
|
||||
#include "InstantiateObjectTester.h"
|
||||
#include "FindInstantiationFuncTester.h"
|
||||
#include "ArchivableTest.h"
|
||||
#include "cppunit/Test.h"
|
||||
#include "cppunit/TestSuite.h"
|
||||
|
||||
CppUnit::Test* ArchivableTestSuite()
|
||||
{
|
||||
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();
|
||||
|
||||
testSuite->addTest(TBArchivableTestCase::Suite());
|
||||
testSuite->addTest(TValidateInstantiationTest::Suite());
|
||||
testSuite->addTest(TInstantiateObjectTester::Suite());
|
||||
testSuite->addTest(TFindInstantiationFuncTester::Suite());
|
||||
|
||||
return testSuite;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef _archivable_test_file_h_
|
||||
#define _archivable_test_file_h_
|
||||
|
||||
class CppUnit::Test;
|
||||
|
||||
CppUnit::Test* ArchivableTestSuite();
|
||||
|
||||
#endif // _locker_test_h_
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
void TBArchivableTestCase::TestPerform()
|
||||
{
|
||||
BArchivable Archive;
|
||||
assert(Archive.Perform(0, NULL) == B_ERROR);
|
||||
CPPUNIT_ASSERT(Archive.Perform(0, NULL) == B_ERROR);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ void TBArchivableTestCase::TestPerform()
|
||||
void TBArchivableTestCase::InvalidArchiveShallow()
|
||||
{
|
||||
BArchivable Archive;
|
||||
assert(Archive.Archive(NULL, false) == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Archive.Archive(NULL, false) == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -63,10 +63,10 @@ void TBArchivableTestCase::ValidArchiveShallow()
|
||||
{
|
||||
BMessage Storage;
|
||||
BArchivable Archive;
|
||||
assert(Archive.Archive(&Storage, false) == B_OK);
|
||||
CPPUNIT_ASSERT(Archive.Archive(&Storage, false) == B_OK);
|
||||
const char* name;
|
||||
assert(Storage.FindString("class", &name) == B_OK);
|
||||
assert(strcmp(name, "BArchivable") == 0);
|
||||
CPPUNIT_ASSERT(Storage.FindString("class", &name) == B_OK);
|
||||
CPPUNIT_ASSERT(strcmp(name, "BArchivable") == 0);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -79,7 +79,7 @@ void TBArchivableTestCase::ValidArchiveShallow()
|
||||
void TBArchivableTestCase::InvalidArchiveDeep()
|
||||
{
|
||||
BArchivable Archive;
|
||||
assert(Archive.Archive(NULL, true) == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Archive.Archive(NULL, true) == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -95,15 +95,15 @@ void TBArchivableTestCase::ValidArchiveDeep()
|
||||
{
|
||||
BMessage Storage;
|
||||
BArchivable Archive;
|
||||
assert(Archive.Archive(&Storage, true) == B_OK);
|
||||
CPPUNIT_ASSERT(Archive.Archive(&Storage, true) == B_OK);
|
||||
const char* name;
|
||||
assert(Storage.FindString("class", &name) == B_OK);
|
||||
assert(strcmp(name, "BArchivable") == 0);
|
||||
CPPUNIT_ASSERT(Storage.FindString("class", &name) == B_OK);
|
||||
CPPUNIT_ASSERT(strcmp(name, "BArchivable") == 0);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TBArchivableTestCase::Suite()
|
||||
CppUnit::Test* TBArchivableTestCase::Suite()
|
||||
{
|
||||
TestSuite* SuiteOfTests = new TestSuite;
|
||||
CppUnit::TestSuite* SuiteOfTests = new CppUnit::TestSuite;
|
||||
ADD_TEST(SuiteOfTests, TBArchivableTestCase, TestPerform);
|
||||
#if !defined(TEST_R5)
|
||||
ADD_TEST(SuiteOfTests, TBArchivableTestCase, InvalidArchiveShallow);
|
||||
@@ -126,3 +126,5 @@ Test* TBArchivableTestCase::Suite()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class TBArchivableTestCase : public TestCase
|
||||
class TBArchivableTestCase : public BTestCase
|
||||
{
|
||||
public:
|
||||
TBArchivableTestCase(std::string name) : TestCase(name) {;}
|
||||
TBArchivableTestCase(std::string name = "") : BTestCase(name) {;}
|
||||
|
||||
void TestPerform();
|
||||
void InvalidArchiveShallow();
|
||||
@@ -30,7 +30,7 @@ class TBArchivableTestCase : public TestCase
|
||||
void InvalidArchiveDeep();
|
||||
void ValidArchiveDeep();
|
||||
|
||||
static Test* Suite();
|
||||
static CppUnit::Test* Suite();
|
||||
};
|
||||
|
||||
|
||||
@@ -43,3 +43,4 @@ class TBArchivableTestCase : public TestCase
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
void TFindInstantiationFuncTester::Case1()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(NULL, NULL);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ void TFindInstantiationFuncTester::Case1()
|
||||
void TFindInstantiationFuncTester::Case2()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gInvalidClassName, NULL);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ void TFindInstantiationFuncTester::Case2()
|
||||
void TFindInstantiationFuncTester::Case3()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(NULL, gInvalidSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ void TFindInstantiationFuncTester::Case4()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gInvalidClassName,
|
||||
gInvalidSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -103,12 +103,12 @@ void TFindInstantiationFuncTester::Case4()
|
||||
void TFindInstantiationFuncTester::Case5()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gLocalClassName, NULL);
|
||||
assert(f != NULL);
|
||||
CPPUNIT_ASSERT(f != NULL);
|
||||
|
||||
BMessage Archive;
|
||||
Archive.AddString("class", gLocalClassName);
|
||||
TIOTest* Test = dynamic_cast<TIOTest*>(f(&Archive));
|
||||
assert(Test != NULL);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -122,7 +122,7 @@ void TFindInstantiationFuncTester::Case5()
|
||||
void TFindInstantiationFuncTester::Case6()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gRemoteClassName, NULL);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ void TFindInstantiationFuncTester::Case7()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gLocalClassName,
|
||||
gInvalidSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ void TFindInstantiationFuncTester::Case8()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gRemoteClassName,
|
||||
gInvalidSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ void TFindInstantiationFuncTester::Case8()
|
||||
void TFindInstantiationFuncTester::Case9()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gLocalClassName, gLocalSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ void TFindInstantiationFuncTester::Case10()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func(gRemoteClassName,
|
||||
gRemoteSig);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -197,7 +197,7 @@ void TFindInstantiationFuncTester::Case10()
|
||||
void TFindInstantiationFuncTester::Case1M()
|
||||
{
|
||||
instantiation_func f = find_instantiation_func((BMessage*)NULL);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -212,7 +212,7 @@ void TFindInstantiationFuncTester::Case2M()
|
||||
BMessage Archive;
|
||||
Archive.AddString("class", gInvalidClassName);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -227,7 +227,7 @@ void TFindInstantiationFuncTester::Case3M()
|
||||
BMessage Archive;
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ void TFindInstantiationFuncTester::Case4M()
|
||||
Archive.AddString("class", gInvalidClassName);
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -260,10 +260,10 @@ void TFindInstantiationFuncTester::Case5M()
|
||||
Archive.AddString("class", gLocalClassName);
|
||||
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f != NULL);
|
||||
CPPUNIT_ASSERT(f != NULL);
|
||||
|
||||
TIOTest* Test = dynamic_cast<TIOTest*>(f(&Archive));
|
||||
assert(Test != NULL);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -279,7 +279,7 @@ void TFindInstantiationFuncTester::Case6M()
|
||||
BMessage Archive;
|
||||
Archive.AddString("class", gRemoteClassName);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -296,7 +296,7 @@ void TFindInstantiationFuncTester::Case7M()
|
||||
Archive.AddString("class", gLocalClassName);
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -313,7 +313,7 @@ void TFindInstantiationFuncTester::Case8M()
|
||||
Archive.AddString("class", gRemoteClassName);
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -333,7 +333,7 @@ void TFindInstantiationFuncTester::Case9M()
|
||||
Archive.AddString("class", gLocalClassName);
|
||||
Archive.AddString("add_on", gLocalSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -352,12 +352,12 @@ void TFindInstantiationFuncTester::Case10M()
|
||||
Archive.AddString("class", gRemoteClassName);
|
||||
Archive.AddString("add_on", gRemoteSig);
|
||||
instantiation_func f = find_instantiation_func(&Archive);
|
||||
assert(f == NULL);
|
||||
CPPUNIT_ASSERT(f == NULL);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TFindInstantiationFuncTester::Suite()
|
||||
CppUnit::Test* TFindInstantiationFuncTester::Suite()
|
||||
{
|
||||
TestSuite* SuiteOfTests = new TestSuite;
|
||||
CppUnit::TestSuite* SuiteOfTests = new CppUnit::TestSuite;
|
||||
|
||||
ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case1);
|
||||
ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case2);
|
||||
@@ -371,7 +371,7 @@ Test* TFindInstantiationFuncTester::Suite()
|
||||
ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case10);
|
||||
|
||||
// BMessage using versions
|
||||
#if !defined(SYSTEM_TEST)
|
||||
#if !defined(TEST_R5)
|
||||
ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case1M);
|
||||
#endif
|
||||
ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case2M);
|
||||
@@ -395,3 +395,5 @@ Test* TFindInstantiationFuncTester::Suite()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class TFindInstantiationFuncTester : public TestCase
|
||||
class TFindInstantiationFuncTester : public BTestCase
|
||||
{
|
||||
public:
|
||||
TFindInstantiationFuncTester(std::string name) : TestCase(name) {;}
|
||||
TFindInstantiationFuncTester(std::string name = "") : BTestCase(name) {;}
|
||||
|
||||
void Case1();
|
||||
void Case2();
|
||||
@@ -47,7 +47,7 @@ class TFindInstantiationFuncTester : public TestCase
|
||||
void Case9M();
|
||||
void Case10M();
|
||||
|
||||
static Test* Suite();
|
||||
static CppUnit::Test* Suite();
|
||||
};
|
||||
|
||||
#endif //FINDINSTATIATIONFUNCTESTER_H
|
||||
@@ -59,3 +59,4 @@ class TFindInstantiationFuncTester : public TestCase
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
#include <be/storage/Path.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include <cppunit/Exception.h>
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "framework/estring.h"
|
||||
#include "RemoteObjectDef/RemoteTestObject.h"
|
||||
#include "remoteobjectdef/RemoteTestObject.h"
|
||||
#include "InstantiateObjectTester.h"
|
||||
#include "LocalTestObject.h"
|
||||
|
||||
@@ -47,7 +47,7 @@ void FormatAndThrow(int line, const char* file, const char* msg, int err);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
TInstantiateObjectTester::TInstantiateObjectTester(string name)
|
||||
: TestCase(name), fAddonId(B_ERROR)
|
||||
: BTestCase(name), fAddonId(B_ERROR)
|
||||
{
|
||||
;
|
||||
}
|
||||
@@ -66,9 +66,9 @@ void TInstantiateObjectTester::Case1()
|
||||
errno = B_OK;
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(NULL, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -86,9 +86,9 @@ void TInstantiateObjectTester::Case2()
|
||||
BMessage Archive;
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -112,9 +112,9 @@ void TInstantiateObjectTester::Case3()
|
||||
Archive.AddString("class", gInvalidClassName);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -136,9 +136,9 @@ void TInstantiateObjectTester::Case4()
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ void TInstantiateObjectTester::Case5()
|
||||
Archive.AddString("add_on", gValidSig);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
// The system implementation returns the image_id of the last addon searched
|
||||
// Implies the addon is not unloaded. How to verify this behaviour? Should
|
||||
// the addon be unloaded if it doesn't contain our function? Addons do,
|
||||
@@ -171,9 +171,9 @@ void TInstantiateObjectTester::Case5()
|
||||
// runs after this case without explicitely unloaded the addon here, it
|
||||
// fails because it depends on the addon image not being available within
|
||||
// the team.
|
||||
assert(id > 0);
|
||||
CPPUNIT_ASSERT(id > 0);
|
||||
unload_add_on(id);
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -203,9 +203,9 @@ void TInstantiateObjectTester::Case6()
|
||||
Archive.AddString("class", gLocalClassName);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test != NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -231,9 +231,9 @@ void TInstantiateObjectTester::Case7()
|
||||
image_id id = B_OK;
|
||||
TRemoteTestObject* Test = (TRemoteTestObject*)instantiate_object(&Archive,
|
||||
&id);
|
||||
assert(Test != NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
|
||||
UnloadAddon();
|
||||
}
|
||||
@@ -257,9 +257,9 @@ void TInstantiateObjectTester::Case8()
|
||||
image_id id = B_OK;
|
||||
TRemoteTestObject* Test = (TRemoteTestObject*)instantiate_object(&Archive,
|
||||
&id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -282,9 +282,9 @@ void TInstantiateObjectTester::Case9()
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -310,9 +310,9 @@ void TInstantiateObjectTester::Case10()
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
|
||||
UnloadAddon();
|
||||
}
|
||||
@@ -337,9 +337,9 @@ void TInstantiateObjectTester::Case11()
|
||||
Archive.AddString("add_on", gInvalidSig);
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test == NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
CPPUNIT_ASSERT(Test == NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_LAUNCH_FAILED_APP_NOT_FOUND);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -367,9 +367,9 @@ void TInstantiateObjectTester::Case12()
|
||||
Archive.AddString("add_on", GetLocalSignature().c_str());
|
||||
image_id id = B_OK;
|
||||
TIOTest* Test = (TIOTest*)instantiate_object(&Archive, &id);
|
||||
assert(Test != NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -395,9 +395,9 @@ void TInstantiateObjectTester::Case13()
|
||||
Archive.AddString("add_on", gRemoteSig);
|
||||
image_id id = B_OK;
|
||||
TRemoteTestObject* Test = (TRemoteTestObject*)instantiate_object(&Archive, &id);
|
||||
assert(Test != NULL);
|
||||
assert(id == B_BAD_VALUE);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
CPPUNIT_ASSERT(id == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
|
||||
UnloadAddon();
|
||||
}
|
||||
@@ -423,15 +423,15 @@ void TInstantiateObjectTester::Case14()
|
||||
Archive.AddString("add_on", gRemoteSig);
|
||||
image_id id = B_OK;
|
||||
TRemoteTestObject* Test = (TRemoteTestObject*)instantiate_object(&Archive, &id);
|
||||
assert(Test != NULL);
|
||||
assert(id > 0);
|
||||
CPPUNIT_ASSERT(Test != NULL);
|
||||
CPPUNIT_ASSERT(id > 0);
|
||||
unload_add_on(id);
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TInstantiateObjectTester::Suite()
|
||||
CppUnit::Test* TInstantiateObjectTester::Suite()
|
||||
{
|
||||
TestSuite* SuiteOfTests = new TestSuite;
|
||||
CppUnit::TestSuite* SuiteOfTests = new CppUnit::TestSuite;
|
||||
|
||||
ADD_TEST(SuiteOfTests, TInstantiateObjectTester, Case1);
|
||||
ADD_TEST(SuiteOfTests, TInstantiateObjectTester, Case2);
|
||||
@@ -529,16 +529,16 @@ std::string TInstantiateObjectTester::GetLocalSignature()
|
||||
//------------------------------------------------------------------------------
|
||||
void FormatAndThrow(int line, const char *file, const char *msg, int err)
|
||||
{
|
||||
string s("line: ");
|
||||
s += estring(line);
|
||||
std::string s("line: ");
|
||||
s += IntToStr(line);
|
||||
s += " ";
|
||||
s += file;
|
||||
s += msg;
|
||||
s += strerror(err);
|
||||
s += "(";
|
||||
s += estring(err);
|
||||
s += IntToStr(err);
|
||||
s += ")";
|
||||
std::runtime_error re(s.c_str());
|
||||
CppUnit::Exception re(s.c_str());
|
||||
throw re;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -550,3 +550,4 @@ void FormatAndThrow(int line, const char *file, const char *msg, int err)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
class TInstantiateObjectTester : public TestCase
|
||||
class TInstantiateObjectTester : public BTestCase
|
||||
{
|
||||
public:
|
||||
TInstantiateObjectTester(std::string name);
|
||||
TInstantiateObjectTester(std::string name = "");
|
||||
|
||||
void Case1();
|
||||
void Case2();
|
||||
@@ -40,7 +40,7 @@ class TInstantiateObjectTester : public TestCase
|
||||
void Case13();
|
||||
void Case14();
|
||||
|
||||
static Test* Suite();
|
||||
static CppUnit::Test* Suite();
|
||||
|
||||
private:
|
||||
void LoadAddon();
|
||||
@@ -60,3 +60,4 @@ class TInstantiateObjectTester : public TestCase
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
SubDir OBOS_TOP src tests kits support barchivable ;
|
||||
|
||||
SubInclude OBOS_TOP src tests kits support barchivable remoteobjectdef ;
|
||||
@@ -7,15 +7,14 @@
|
||||
#define LOCALCOMMON_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <string>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#ifdef TEST_R5
|
||||
#include <be/support/Archivable.h>
|
||||
#else
|
||||
#include "Archivable.h"
|
||||
#endif
|
||||
#include <Archivable.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include <TestCase.h>
|
||||
#include <TestUtils.h>
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
#include "common.h"
|
||||
@@ -41,3 +40,5 @@ extern const char* gValidSig;
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -54,3 +54,5 @@ TIOTest* TIOTest::Instantiate(BMessage *archive)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,12 +9,8 @@
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <be/app/Message.h>
|
||||
#ifdef SYSTEM_TEST
|
||||
#include <be/support/Archivable.h>
|
||||
#else
|
||||
#include "../../../../source/lib/support/headers/Archivable.h"
|
||||
#endif
|
||||
#include <Message.h>
|
||||
#include <Archivable.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
@@ -48,3 +44,4 @@ class TIOTest : public BArchivable
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ const char* gBogusClassName = "BarFoo";
|
||||
void TValidateInstantiationTest::AllParamsInvalid()
|
||||
{
|
||||
errno = B_OK;
|
||||
assert(!validate_instantiation(NULL, NULL));
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(!validate_instantiation(NULL, NULL));
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -54,8 +54,8 @@ void TValidateInstantiationTest::ClassNameParamInvalid()
|
||||
{
|
||||
errno = B_OK;
|
||||
BMessage Archive;
|
||||
assert(!validate_instantiation(&Archive, NULL));
|
||||
assert(errno == B_MISMATCHED_VALUES);
|
||||
CPPUNIT_ASSERT(!validate_instantiation(&Archive, NULL));
|
||||
CPPUNIT_ASSERT(errno == B_MISMATCHED_VALUES);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -72,8 +72,8 @@ void TValidateInstantiationTest::ClassNameParamInvalid()
|
||||
void TValidateInstantiationTest::ArchiveParamInvalid()
|
||||
{
|
||||
errno = B_OK;
|
||||
assert(!validate_instantiation(NULL, gClassName));
|
||||
assert(errno == B_BAD_VALUE);
|
||||
CPPUNIT_ASSERT(!validate_instantiation(NULL, gClassName));
|
||||
CPPUNIT_ASSERT(errno == B_BAD_VALUE);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ void TValidateInstantiationTest::ClassFieldEmpty()
|
||||
{
|
||||
errno = B_OK;
|
||||
BMessage Archive;
|
||||
assert(!validate_instantiation(&Archive, gClassName));
|
||||
assert(errno == B_MISMATCHED_VALUES);
|
||||
CPPUNIT_ASSERT(!validate_instantiation(&Archive, gClassName));
|
||||
CPPUNIT_ASSERT(errno == B_MISMATCHED_VALUES);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -108,8 +108,8 @@ void TValidateInstantiationTest::ClassFieldBogus()
|
||||
errno = B_OK;
|
||||
BMessage Archive;
|
||||
Archive.AddString("class", gClassName);
|
||||
assert(!validate_instantiation(&Archive, gBogusClassName));
|
||||
assert(errno == B_MISMATCHED_VALUES);
|
||||
CPPUNIT_ASSERT(!validate_instantiation(&Archive, gBogusClassName));
|
||||
CPPUNIT_ASSERT(errno == B_MISMATCHED_VALUES);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
@@ -127,13 +127,13 @@ void TValidateInstantiationTest::AllValid()
|
||||
errno = B_OK;
|
||||
BMessage Archive;
|
||||
Archive.AddString("class", gClassName);
|
||||
assert(validate_instantiation(&Archive, gClassName));
|
||||
assert(errno == B_OK);
|
||||
CPPUNIT_ASSERT(validate_instantiation(&Archive, gClassName));
|
||||
CPPUNIT_ASSERT(errno == B_OK);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
Test* TValidateInstantiationTest::Suite()
|
||||
CppUnit::Test* TValidateInstantiationTest::Suite()
|
||||
{
|
||||
TestSuite* SuiteOfTests = new TestSuite;
|
||||
CppUnit::TestSuite* SuiteOfTests = new CppUnit::TestSuite;
|
||||
#if !defined(TEST_R5)
|
||||
ADD_TEST(SuiteOfTests, TValidateInstantiationTest, AllParamsInvalid);
|
||||
#endif
|
||||
@@ -156,3 +156,5 @@ Test* TValidateInstantiationTest::Suite()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
class TValidateInstantiationTest : public TestCase
|
||||
class TValidateInstantiationTest : public BTestCase
|
||||
{
|
||||
public:
|
||||
TValidateInstantiationTest(std::string name) : TestCase(name) {;}
|
||||
TValidateInstantiationTest(std::string name = "") : BTestCase(name) {;}
|
||||
|
||||
void AllParamsInvalid();
|
||||
void ClassNameParamInvalid();
|
||||
@@ -32,7 +32,7 @@ class TValidateInstantiationTest : public TestCase
|
||||
void ClassFieldBogus();
|
||||
void AllValid();
|
||||
|
||||
static Test* Suite();
|
||||
static CppUnit::Test* Suite();
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -46,3 +46,4 @@ class TValidateInstantiationTest : public TestCase
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
#include <posix/string.h>
|
||||
#include <errno.h>
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include "cppunit/TestCaller.h"
|
||||
#include "TestCase.h"
|
||||
//#include "TestResult.h"
|
||||
#include "cppunit/TestSuite.h"
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
#define assert_err(condition) \
|
||||
(this->assertImplementation ((condition), std::string((#condition)) + \
|
||||
strerror(condition),\
|
||||
__LINE__, __FILE__))
|
||||
|
||||
#define ADD_TEST(suitename, classname, funcname) \
|
||||
(suitename)->addTest(new CppUnit::TestCaller<classname>(std::string("BArchivable::") + \
|
||||
std::string((#funcname)), &classname::funcname));
|
||||
|
||||
#define CHECK_ERRNO \
|
||||
cout << endl << "errno == \"" << strerror(errno) << "\" (" << errno \
|
||||
<< ") in " << __PRETTY_FUNCTION__ << endl
|
||||
|
||||
#define CHECK_STATUS(status__) \
|
||||
cout << endl << "status_t == \"" << strerror((status__)) << "\" (" \
|
||||
<< (status__) << ") in " << __PRETTY_FUNCTION__ << endl
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif //COMMON_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
SubDir OBOS_TOP src tests kits support barchivable remoteobjectdef ;
|
||||
|
||||
CommonUnitTest RemoteTestObject
|
||||
CommonTestLib libsupporttest_RemoteTestObject.so
|
||||
: RemoteTestObject.cpp
|
||||
: kits support
|
||||
: <boot!home!config!lib>libopenbeos.so be stdc++.r4
|
||||
: be stdc++.r4
|
||||
:
|
||||
: support
|
||||
: Resource.rsrc
|
||||
;
|
||||
|
||||
# Add the libraries' resource files. If this sort of thing is needed
|
||||
# anywhere else, we ought to make it into a real rule.
|
||||
AddResources libsupporttest_RemoteTestObject.so : Resource.rsrc ;
|
||||
AddResources libsupporttest_RemoteTestObject_r5.so : Resource.rsrc ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: AutolockLockerTest.cpp,v 1.1 2002/07/09 12:24:57 ejakowatz Exp $
|
||||
$Id: AutolockLockerTest.cpp,v 1.2 2002/07/19 06:45:28 tylerdauwalder Exp $
|
||||
|
||||
This file tests all use cases of the BAutolock when used with a BLocker.
|
||||
BLooper based tests are done seperately.
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "ThreadedTestCaller.h"
|
||||
#include "AutolockLockerTest.h"
|
||||
#include <be/support/Autolock.h>
|
||||
#include "Autolock.h"
|
||||
#include <Autolock.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
@@ -17,26 +17,26 @@ const bigtime_t SNOOZE_TIME = 250000;
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::AutolockLockerTest()
|
||||
* Method: AutolockLockerTest::AutolockLockerTest()
|
||||
* Descr: This method is the only constructor for the AutolockLockerTest
|
||||
* class.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
AutolockLockerTest<Autolock, Locker>::AutolockLockerTest(std::string name) :
|
||||
TestCase(name), theLocker(new Locker)
|
||||
|
||||
AutolockLockerTest::AutolockLockerTest(std::string name) :
|
||||
BThreadedTestCase(name), theLocker(new BLocker)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::~AutolockLockerTest()
|
||||
* Method: AutolockLockerTest::~AutolockLockerTest()
|
||||
* Descr: This method is the destructor for the AutolockLockerTest class.
|
||||
* It only deallocates the autolocker and locker.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
AutolockLockerTest<Autolock, Locker>::~AutolockLockerTest()
|
||||
|
||||
AutolockLockerTest::~AutolockLockerTest()
|
||||
{
|
||||
delete theLocker;
|
||||
theLocker = NULL;
|
||||
@@ -44,7 +44,7 @@ template<class Autolock, class Locker>
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::TestThread1()
|
||||
* Method: AutolockLockerTest::TestThread1()
|
||||
* Descr: This method performs the tests on the Autolock. It first acquires the
|
||||
* lock and sleeps for a short time. It deletes the lock rather than Unlock()
|
||||
* it in order to test the other two threads. Then, it constructs a new
|
||||
@@ -54,91 +54,100 @@ template<class Autolock, class Locker>
|
||||
* constructed by passing a reference to the Locker.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
void AutolockLockerTest<Autolock, Locker>::TestThread1(void)
|
||||
|
||||
void AutolockLockerTest::TestThread1(void)
|
||||
{
|
||||
Autolock *theAutolock;
|
||||
BAutolock *theAutolock;
|
||||
|
||||
assert(theLocker->Lock());
|
||||
assert(theLocker->LockingThread() == find_thread(NULL));
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(theLocker->Lock());
|
||||
CPPUNIT_ASSERT(theLocker->LockingThread() == find_thread(NULL));
|
||||
snooze(SNOOZE_TIME);
|
||||
delete theLocker;
|
||||
|
||||
theLocker = new Locker;
|
||||
theAutolock = new Autolock(theLocker);
|
||||
NextSubTest();
|
||||
theLocker = new BLocker;
|
||||
theAutolock = new BAutolock(theLocker);
|
||||
|
||||
assert(theLocker->IsLocked());
|
||||
assert(theLocker->LockingThread() == find_thread(NULL));
|
||||
assert(theAutolock->IsLocked());
|
||||
CPPUNIT_ASSERT(theLocker->IsLocked());
|
||||
CPPUNIT_ASSERT(theLocker->LockingThread() == find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theAutolock->IsLocked());
|
||||
|
||||
NextSubTest();
|
||||
delete theAutolock;
|
||||
theAutolock = NULL;
|
||||
assert(theLocker->LockingThread() != find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theLocker->LockingThread() != find_thread(NULL));
|
||||
|
||||
theAutolock = new Autolock(*theLocker);
|
||||
assert(theLocker->IsLocked());
|
||||
assert(theLocker->LockingThread() == find_thread(NULL));
|
||||
assert(theAutolock->IsLocked());
|
||||
NextSubTest();
|
||||
theAutolock = new BAutolock(*theLocker);
|
||||
CPPUNIT_ASSERT(theLocker->IsLocked());
|
||||
CPPUNIT_ASSERT(theLocker->LockingThread() == find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theAutolock->IsLocked());
|
||||
|
||||
NextSubTest();
|
||||
delete theAutolock;
|
||||
theAutolock = NULL;
|
||||
assert(theLocker->LockingThread() != find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theLocker->LockingThread() != find_thread(NULL));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::TestThread2()
|
||||
* Method: AutolockLockerTest::TestThread2()
|
||||
* Descr: This method performs the tests on the Autolock. It first sleeps for a short
|
||||
* time and then tries to acquire the lock with an Autolock. It passes a pointer
|
||||
* to the lock to the Autolock. It expects the acquisition to fail and IsLocked()
|
||||
* is tested to be sure.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
void AutolockLockerTest<Autolock, Locker>::TestThread2(void)
|
||||
|
||||
void AutolockLockerTest::TestThread2(void)
|
||||
{
|
||||
NextSubTest();
|
||||
snooze(SNOOZE_TIME / 10);
|
||||
Autolock theAutolock(theLocker);
|
||||
assert(!theAutolock.IsLocked());
|
||||
BAutolock theAutolock(theLocker);
|
||||
CPPUNIT_ASSERT(!theAutolock.IsLocked());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::TestThread3()
|
||||
* Method: AutolockLockerTest::TestThread3()
|
||||
* Descr: This method performs the tests on the Autolock. It first sleeps for a short
|
||||
* time and then tries to acquire the lock with an Autolock. It passes a reference
|
||||
* to the lock to the Autolock. It expects the acquisition to fail and IsLocked()
|
||||
* is tested to be sure.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
void AutolockLockerTest<Autolock, Locker>::TestThread3(void)
|
||||
|
||||
void AutolockLockerTest::TestThread3(void)
|
||||
{
|
||||
NextSubTest();
|
||||
snooze(SNOOZE_TIME / 10);
|
||||
Autolock theAutolock(*theLocker);
|
||||
assert(!theAutolock.IsLocked());
|
||||
BAutolock theAutolock(*theLocker);
|
||||
CPPUNIT_ASSERT(!theAutolock.IsLocked());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLockerTest<Autolock, Locker>::suite()
|
||||
* Method: AutolockLockerTest::suite()
|
||||
* Descr: This static member function returns a test caller for performing
|
||||
* the "AutolockLockerTest" test. The test caller
|
||||
* is created as a ThreadedTestCaller (typedef'd as
|
||||
* BenaphoreLockCountTest1Caller) with three independent threads.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Locker>
|
||||
Test *AutolockLockerTest<Autolock, Locker>::suite(void)
|
||||
|
||||
CppUnit::Test *AutolockLockerTest::suite(void)
|
||||
{
|
||||
AutolockLockerTest<Autolock, Locker> *theTest = new AutolockLockerTest<Autolock, Locker>("");
|
||||
AutolockLockerTestCaller *threadedTest = new AutolockLockerTestCaller("", theTest);
|
||||
threadedTest->addThread(":Thread1", &AutolockLockerTest<Autolock, Locker>::TestThread1);
|
||||
threadedTest->addThread(":Thread2", &AutolockLockerTest<Autolock, Locker>::TestThread2);
|
||||
threadedTest->addThread(":Thread3", &AutolockLockerTest<Autolock, Locker>::TestThread3);
|
||||
typedef BThreadedTestCaller <AutolockLockerTest >
|
||||
AutolockLockerTestCaller;
|
||||
|
||||
AutolockLockerTest *theTest = new AutolockLockerTest("");
|
||||
AutolockLockerTestCaller *threadedTest = new AutolockLockerTestCaller("BAutolock::Locker Test", theTest);
|
||||
threadedTest->addThread("A", &AutolockLockerTest::TestThread1);
|
||||
threadedTest->addThread("B", &AutolockLockerTest::TestThread2);
|
||||
threadedTest->addThread("C", &AutolockLockerTest::TestThread3);
|
||||
return(threadedTest);
|
||||
}
|
||||
|
||||
|
||||
template class AutolockLockerTest<BAutolock, BLocker>;
|
||||
template class AutolockLockerTest<OpenBeOS::BAutolock, OpenBeOS::BLocker>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: AutolockLockerTest.h,v 1.1 2002/07/09 12:24:57 ejakowatz Exp $
|
||||
$Id: AutolockLockerTest.h,v 1.2 2002/07/19 06:45:28 tylerdauwalder Exp $
|
||||
|
||||
This file defines the class for performing all BAutolock tests on a
|
||||
BLocker.
|
||||
@@ -10,25 +10,28 @@
|
||||
#ifndef AutolockLockerTest_H
|
||||
#define AutolockLockerTest_H
|
||||
|
||||
#include "ThreadedTestCase.h"
|
||||
#include <string>
|
||||
|
||||
#include "ThreadedTestCaller.h"
|
||||
#include "TestCase.h"
|
||||
class BLocker;
|
||||
class CppUnit::Test;
|
||||
|
||||
template<class Autolock, class Locker> class AutolockLockerTest : public TestCase {
|
||||
class AutolockLockerTest : public BThreadedTestCase {
|
||||
|
||||
private:
|
||||
typedef ThreadedTestCaller <AutolockLockerTest<Autolock, Locker> >
|
||||
AutolockLockerTestCaller;
|
||||
|
||||
Locker *theLocker;
|
||||
BLocker *theLocker;
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
static CppUnit::Test *suite(void);
|
||||
void TestThread1(void);
|
||||
void TestThread2(void);
|
||||
void TestThread3(void);
|
||||
AutolockLockerTest(std::string);
|
||||
virtual ~AutolockLockerTest();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: AutolockLooperTest.cpp,v 1.1 2002/07/09 12:24:57 ejakowatz Exp $
|
||||
$Id: AutolockLooperTest.cpp,v 1.2 2002/07/19 06:45:28 tylerdauwalder Exp $
|
||||
|
||||
This file tests all use cases of the BAutolock when used with a BLooper.
|
||||
BLocker based tests are done seperately.
|
||||
@@ -7,9 +7,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "ThreadedTestCaller.h"
|
||||
#include "AutolockLooperTest.h"
|
||||
#include <be/support/Autolock.h>
|
||||
#include "Autolock.h"
|
||||
#include <Autolock.h>
|
||||
#include <Looper.h>
|
||||
#include <OS.h>
|
||||
|
||||
|
||||
@@ -17,27 +18,27 @@ const bigtime_t SNOOZE_TIME = 250000;
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLooperTest<Autolock, Looper>::AutolockLooperTest()
|
||||
* Method: AutolockLooperTest::AutolockLooperTest()
|
||||
* Descr: This method is the only constructor for the AutolockLooperTest
|
||||
* class.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Looper>
|
||||
AutolockLooperTest<Autolock, Looper>::AutolockLooperTest(std::string name) :
|
||||
TestCase(name), theLooper(new Looper)
|
||||
|
||||
AutolockLooperTest::AutolockLooperTest(std::string name) :
|
||||
BThreadedTestCase(name), theLooper(new BLooper)
|
||||
{
|
||||
theLooper->Run();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLooperTest<Autolock, Looper>::~AutolockLooperTest()
|
||||
* Method: AutolockLooperTest::~AutolockLooperTest()
|
||||
* Descr: This method is the destructor for the AutolockLooperTest class.
|
||||
* It only deallocates the autoLooper and Looper.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Looper>
|
||||
AutolockLooperTest<Autolock, Looper>::~AutolockLooperTest()
|
||||
|
||||
AutolockLooperTest::~AutolockLooperTest()
|
||||
{
|
||||
if (theLooper != NULL)
|
||||
theLooper->Lock();
|
||||
@@ -46,45 +47,50 @@ template<class Autolock, class Looper>
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLooperTest<Autolock, Looper>::TestThread1()
|
||||
* Method: AutolockLooperTest::TestThread1()
|
||||
* Descr: This method performs the tests on the Autolock. It constructs a new
|
||||
* Autolock and checks that both the Autolock and the Looper are
|
||||
* both locked. Then, the Autolock is released by deleting it. The Looper
|
||||
* is checked to see that it is now released.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Looper>
|
||||
void AutolockLooperTest<Autolock, Looper>::TestThread1(void)
|
||||
{
|
||||
Autolock *theAutolock = new Autolock(theLooper);
|
||||
|
||||
assert(theLooper->IsLocked());
|
||||
assert(theLooper->LockingThread() == find_thread(NULL));
|
||||
assert(theAutolock->IsLocked());
|
||||
void AutolockLooperTest::TestThread1(void)
|
||||
{
|
||||
BAutolock *theAutolock = new BAutolock(theLooper);
|
||||
|
||||
NextSubTest();
|
||||
CPPUNIT_ASSERT(theLooper->IsLocked());
|
||||
CPPUNIT_ASSERT(theLooper->LockingThread() == find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theAutolock->IsLocked());
|
||||
|
||||
NextSubTest();
|
||||
delete theAutolock;
|
||||
theAutolock = NULL;
|
||||
assert(theLooper->LockingThread() != find_thread(NULL));
|
||||
CPPUNIT_ASSERT(theLooper->LockingThread() != find_thread(NULL));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: AutolockLooperTest<Autolock, Looper>::suite()
|
||||
* Method: AutolockLooperTest::suite()
|
||||
* Descr: This static member function returns a test caller for performing
|
||||
* the "AutolockLooperTest" test. The test caller
|
||||
* is created as a ThreadedTestCaller (typedef'd as
|
||||
* BenaphoreLockCountTest1Caller) with three independent threads.
|
||||
*/
|
||||
|
||||
template<class Autolock, class Looper>
|
||||
Test *AutolockLooperTest<Autolock, Looper>::suite(void)
|
||||
|
||||
CppUnit::Test *AutolockLooperTest::suite(void)
|
||||
{
|
||||
AutolockLooperTest<Autolock, Looper> *theTest = new AutolockLooperTest<Autolock, Looper>("");
|
||||
AutolockLooperTestCaller *threadedTest = new AutolockLooperTestCaller("", theTest);
|
||||
threadedTest->addThread(":Thread1", &AutolockLooperTest<Autolock, Looper>::TestThread1);
|
||||
typedef BThreadedTestCaller <AutolockLooperTest >
|
||||
AutolockLooperTestCaller;
|
||||
|
||||
AutolockLooperTest *theTest = new AutolockLooperTest("");
|
||||
AutolockLooperTestCaller *threadedTest = new AutolockLooperTestCaller("BAutolock::Looper Test", theTest);
|
||||
threadedTest->addThread("A", &AutolockLooperTest::TestThread1);
|
||||
return(threadedTest);
|
||||
}
|
||||
|
||||
|
||||
template class AutolockLooperTest<BAutolock, BLooper>;
|
||||
template class AutolockLooperTest<OpenBeOS::BAutolock, BLooper>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: AutolockLooperTest.h,v 1.1 2002/07/09 12:24:57 ejakowatz Exp $
|
||||
$Id: AutolockLooperTest.h,v 1.2 2002/07/19 06:45:28 tylerdauwalder Exp $
|
||||
|
||||
This file defines the class for performing all BAutolock tests on a
|
||||
BLooper.
|
||||
@@ -11,22 +11,26 @@
|
||||
#define AutolockLooperTest_H
|
||||
|
||||
|
||||
#include "ThreadedTestCaller.h"
|
||||
#include "TestCase.h"
|
||||
#include "ThreadedTestCase.h"
|
||||
#include <string>
|
||||
|
||||
template<class Autolock, class Looper> class AutolockLooperTest : public TestCase {
|
||||
class BLooper;
|
||||
class CppUnit::Test;
|
||||
|
||||
class AutolockLooperTest : public BThreadedTestCase {
|
||||
|
||||
private:
|
||||
typedef ThreadedTestCaller <AutolockLooperTest<Autolock, Looper> >
|
||||
AutolockLooperTestCaller;
|
||||
|
||||
Looper *theLooper;
|
||||
BLooper *theLooper;
|
||||
|
||||
public:
|
||||
static Test *suite(void);
|
||||
void TestThread1(void);
|
||||
AutolockLooperTest(std::string);
|
||||
virtual ~AutolockLooperTest();
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
$Id:
|
||||
*/
|
||||
|
||||
#include "AutolockLockerTest.h"
|
||||
#include "AutolockLooperTest.h"
|
||||
#include "cppunit/Test.h"
|
||||
#include "cppunit/TestSuite.h"
|
||||
|
||||
CppUnit::Test* AutolockTestSuite()
|
||||
{
|
||||
CppUnit::TestSuite *testSuite = new CppUnit::TestSuite();
|
||||
|
||||
testSuite->addTest(AutolockLockerTest::suite());
|
||||
testSuite->addTest(AutolockLooperTest::suite());
|
||||
|
||||
return testSuite;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _autolock_test_h_
|
||||
#define _autolock_test_h_
|
||||
|
||||
class CppUnit::Test;
|
||||
|
||||
CppUnit::Test* AutolockTestSuite();
|
||||
|
||||
#endif // _autolock_test_h_
|
||||
@@ -13,7 +13,8 @@ BTestCase::BTestCase(std::string name)
|
||||
|
||||
void
|
||||
BTestCase::tearDown() {
|
||||
NextSubTestBlock();
|
||||
if (fSubTestNum != 0)
|
||||
NextSubTestBlock();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -27,7 +27,7 @@ void
|
||||
BTestListener::endTest( CppUnit::Test *test ) {
|
||||
if (fOkay)
|
||||
cout << " + PASSED" << endl;
|
||||
else
|
||||
cout << " - FAILED" << endl;
|
||||
// else
|
||||
// cout << " - FAILED" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ BTestShell::AddSuite(BTestSuite *suite) {
|
||||
fSuites[suite->getName()] = suite;
|
||||
|
||||
// Add its tests
|
||||
const std::map<std::string, CppUnit::Test*> &map = suite->getTests();
|
||||
for (std::map<std::string, CppUnit::Test*>::const_iterator i = map.begin();
|
||||
const TestMap &map = suite->getTests();
|
||||
for (TestMap::const_iterator i = map.begin();
|
||||
i != map.end();
|
||||
i++)
|
||||
AddTest(i->first, i->second);
|
||||
@@ -127,16 +127,39 @@ BTestShell::Run(int argc, char *argv[]) {
|
||||
cout << "ERROR: No installed tests to run!" << endl;
|
||||
return 0;
|
||||
|
||||
} else if (fTestsToRun.empty()) {
|
||||
} else if (fSuitesToRun.empty() && fTestsToRun.empty()) {
|
||||
|
||||
// None specified, so run them all
|
||||
std::map<std::string, CppUnit::Test*>::iterator i;
|
||||
TestMap::iterator i;
|
||||
for (i = fTests.begin(); i != fTests.end(); ++i)
|
||||
suite.addTest( i->second );
|
||||
|
||||
} else {
|
||||
// One or more specified, so only run those
|
||||
} else {
|
||||
std::set<std::string>::const_iterator i;
|
||||
std::set<std::string> suitesToRemove;
|
||||
|
||||
// Add all the tests from any specified suites to the list of
|
||||
// tests to run (since we use a set, this eliminates the concern
|
||||
// of having duplicate entries).
|
||||
for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) {
|
||||
// See if it's a suite (since it may just be a single test)
|
||||
if (fSuites.find(*i) != fSuites.end()) {
|
||||
suitesToRemove.insert(*i); // Note the suite name for later
|
||||
const TestMap &tests = fSuites[*i]->getTests();
|
||||
TestMap::const_iterator j;
|
||||
for (j = tests.begin(); j != tests.end(); j++) {
|
||||
fTestsToRun.insert( j->first );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the names of all of the suites we discovered from the
|
||||
// list of tests to run
|
||||
for (i = suitesToRemove.begin(); i != suitesToRemove.end(); i++) {
|
||||
fTestsToRun.erase(*i);
|
||||
}
|
||||
|
||||
// Everything still in fTestsToRun must then be an explicit test
|
||||
for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) {
|
||||
// Make sure it's a valid test
|
||||
if (fTests.find(*i) != fTests.end()) {
|
||||
@@ -184,27 +207,39 @@ BTestShell::PrintHelp() {
|
||||
|
||||
void
|
||||
BTestShell::PrintValidArguments() {
|
||||
cout << indent << "--help Displays this help text plus some other garbage" << endl;
|
||||
cout << indent << "--list Lists the names of classes with installed tests" << endl;
|
||||
cout << indent << "-v0 Sets verbosity level to 0 (concise summary only)" << endl;
|
||||
cout << indent << "-v1 Sets verbosity level to 1 (complete summary only)" << endl;
|
||||
cout << indent << "-v2 Sets verbosity level to 2 (*default* -- per-test results plus" << endl;
|
||||
cout << indent << " complete summary)" << endl;
|
||||
cout << indent << "-v3 Sets verbosity level to 3 (per-test results and timing info" << endl;
|
||||
cout << indent << " plus complete summary)" << endl;
|
||||
cout << indent << "CLASSNAME Instructs the program to run the test for the given class; if" << endl;
|
||||
cout << indent << " no classes are specified, all tests are run" << endl;
|
||||
cout << indent << "-lPATH Adds PATH to the search path for dynamically loadable test" << endl;
|
||||
cout << indent << " libraries." << endl;
|
||||
cout << indent << "--help Displays this help text plus some other garbage" << endl;
|
||||
cout << indent << "--list Lists the names of classes with installed tests" << endl;
|
||||
cout << indent << "-v0 Sets verbosity level to 0 (concise summary only)" << endl;
|
||||
cout << indent << "-v1 Sets verbosity level to 1 (complete summary only)" << endl;
|
||||
cout << indent << "-v2 Sets verbosity level to 2 (*default* -- per-test results plus" << endl;
|
||||
cout << indent << " complete summary)" << endl;
|
||||
cout << indent << "-v3 Sets verbosity level to 3 (dynamic loading information, per-test " << endl;
|
||||
cout << indent << " results and timing info, plus complete summary)" << endl;
|
||||
cout << indent << "NAME Instructs the program to run the test for the given class or all" << endl;
|
||||
cout << indent << " the tests for the given suite. If some bonehead adds both a class" << endl;
|
||||
cout << indent << " and a suite with the same name, the suite will be run, not the class" << endl;
|
||||
cout << indent << " (unless the class is part of the suite with the same name :-). If no" << endl;
|
||||
cout << indent << " classes or suites are specified, all available tests are run" << endl;
|
||||
cout << indent << "-lPATH Adds PATH to the search path for dynamically loadable test" << endl;
|
||||
cout << indent << " libraries" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
BTestShell::PrintInstalledTests() {
|
||||
// Print out the list of installed suites
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
cout << "Available Suites:" << endl;
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
SuiteMap::const_iterator j;
|
||||
for (j = fSuites.begin(); j != fSuites.end(); ++j)
|
||||
cout << j->first << endl;
|
||||
cout << endl;
|
||||
|
||||
// Print out the list of installed tests
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
cout << "Available Tests:" << endl;
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
std::map<std::string, CppUnit::Test*>::const_iterator i;
|
||||
TestMap::const_iterator i;
|
||||
for (i = fTests.begin(); i != fTests.end(); ++i)
|
||||
cout << i->first << endl;
|
||||
cout << endl;
|
||||
@@ -250,8 +285,9 @@ BTestShell::ProcessArgument(std::string arg, int argc, char *argv[]) {
|
||||
}
|
||||
else if (arg == "-v3") {
|
||||
fVerbosityLevel = v3;
|
||||
}
|
||||
else {
|
||||
} else if (arg.length() >= 2 && arg[0] == '-' && arg[1] == 'l') {
|
||||
fLibDirs.insert(arg.substr(2, arg.size()-2));
|
||||
} else {
|
||||
fTestsToRun.insert(arg);
|
||||
}
|
||||
return true;
|
||||
@@ -323,15 +359,26 @@ BTestShell::PrintResults() {
|
||||
|
||||
void
|
||||
BTestShell::LoadDynamicSuites() {
|
||||
if (Verbosity() >= v3) {
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
cout << "Loading " << endl;
|
||||
cout << "------------------------------------------------------------------------------" << endl;
|
||||
}
|
||||
|
||||
std::set<std::string>::iterator i;
|
||||
for (i = fLibDirs.begin(); i != fLibDirs.end(); i++) {
|
||||
BDirectory libDir((*i).c_str());
|
||||
if (Verbosity() >= v3)
|
||||
cout << "Checking " << *i << endl;
|
||||
int count = LoadSuitesFrom(&libDir);
|
||||
if (Verbosity() >= v3) {
|
||||
cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s");
|
||||
cout << " from " << *i << endl;
|
||||
if (Verbosity() >= v3) {
|
||||
// cout << "Loaded " << count << " suite" << (count == 1 ? "" : "s");
|
||||
// cout << " from " << *i << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (Verbosity() >= v3)
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <TestUtils.h>
|
||||
#include <TestShell.h>
|
||||
#include <stdio.h>
|
||||
|
||||
status_t DecodeResult(status_t result) {
|
||||
if (!BTestShell::GlobalBeVerbose())
|
||||
@@ -169,6 +170,12 @@ status_t DecodeResult(status_t result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string IntToStr(int i) {
|
||||
char num[32];
|
||||
sprintf(num, "%d", i);
|
||||
return std::string(num);
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command) {
|
||||
if (command)
|
||||
system(command);
|
||||
|
||||
Reference in New Issue
Block a user