Finished migrating Storage Kit tests to new framework.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@292 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// TestApp.h
|
||||
|
||||
#ifndef _beos_test_app_h_
|
||||
#define _beos_test_app_h_
|
||||
|
||||
#include <Application.h>
|
||||
#include <MessageQueue.h>
|
||||
|
||||
// TestHandler
|
||||
|
||||
class TestHandler : public BHandler {
|
||||
public:
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
BMessageQueue &Queue();
|
||||
|
||||
private:
|
||||
BMessageQueue fQueue;
|
||||
};
|
||||
|
||||
|
||||
// TestApp
|
||||
|
||||
class TestApp : public BApplication {
|
||||
public:
|
||||
TestApp(const char *signature);
|
||||
|
||||
status_t Init();
|
||||
void Terminate();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
|
||||
TestHandler &Handler();
|
||||
|
||||
private:
|
||||
static int32 _AppThreadStart(void *data);
|
||||
|
||||
private:
|
||||
thread_id fAppThread;
|
||||
TestHandler fHandler;
|
||||
};
|
||||
|
||||
#endif // _beos_test_app_h_
|
||||
@@ -29,9 +29,6 @@ public:
|
||||
//! Restores the current working directory to last directory saved by a call to SaveCWD().
|
||||
void RestoreCWD(const char *alternate = NULL);
|
||||
protected:
|
||||
//! Returns true if the current shell settings allow us to print to standard output.
|
||||
bool BeVerbose();
|
||||
|
||||
bool fValidCWD;
|
||||
char fCurrentWorkingDir[B_PATH_NAME_LENGTH+1];
|
||||
int32 fSubTestNum;
|
||||
|
||||
@@ -30,7 +30,8 @@ typedef CppUnit::SynchronizedObject::SynchronizationObject SyncObject;
|
||||
*/
|
||||
class BTestShell {
|
||||
public:
|
||||
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||
BTestShell(const std::string &description = "", SyncObject *syncObject = 0);
|
||||
virtual ~BTestShell();
|
||||
|
||||
// This function is used to add the tests for a given kit (as contained
|
||||
// in a BTestSuite object) to the list of available tests. The shell assumes
|
||||
@@ -72,11 +73,15 @@ public:
|
||||
// access to verbosity information. Don't rely on it if you don't
|
||||
// have to (and always make sure the pointer it returns isn't NULL
|
||||
// before you try to use it :-).
|
||||
static BTestShell* Shell() { return fGlobalShell; };
|
||||
static BTestShell* GlobalShell() { return fGlobalShell; };
|
||||
|
||||
// Sets the global BTestShell pointer. The BTestShell class does
|
||||
// not assume ownership of the object.
|
||||
static void SetShell(BTestShell *shell) { fGlobalShell = shell; };
|
||||
static void SetGlobalShell(BTestShell *shell) { fGlobalShell = shell; };
|
||||
|
||||
const char* TestDir() const;
|
||||
static const char* GlobalTestDir() { return (fGlobalShell ? fGlobalShell->TestDir() : NULL); };
|
||||
|
||||
|
||||
protected:
|
||||
VerbosityLevel fVerbosityLevel;
|
||||
@@ -90,6 +95,7 @@ protected:
|
||||
static BTestShell* fGlobalShell;
|
||||
static const char indent[];
|
||||
bool fListTestsAndExit;
|
||||
BPath *fTestDir;
|
||||
|
||||
//! Prints a brief description of the program.
|
||||
virtual void PrintDescription(int argc, char *argv[]);
|
||||
@@ -127,6 +133,10 @@ protected:
|
||||
*/
|
||||
virtual void LoadDynamicSuites();
|
||||
|
||||
//! Sets the current test directory.
|
||||
void UpdateTestDir(char *argv[]);
|
||||
|
||||
|
||||
private:
|
||||
//! Prevents the use of the copy constructor.
|
||||
BTestShell( const BTestShell © );
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
#include <TestShell.h>
|
||||
#ifndef __beos_test_utils_h__
|
||||
#define __beos_test_utils_h__
|
||||
|
||||
#include <string>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// Handy defines :-)
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
#define RES DecodeResult
|
||||
|
||||
// Prints out a description of the given status_t
|
||||
// return code to standard out. Helpful for figuring
|
||||
// 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);
|
||||
|
||||
// Calls system() with the concatenated string of command and parameter.
|
||||
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);
|
||||
|
||||
// Calls system() with the given command (kind of silly, but it's consistent :-)
|
||||
void ExecCommand(const char *command);
|
||||
|
||||
#endif // __beos_test_utils_h__
|
||||
|
||||
@@ -153,9 +153,6 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
||||
// Try to acquire the semaphore
|
||||
err = acquire_sem_etc(fThreadSem, fThreads.size(), B_RELATIVE_TIMEOUT, 500000);
|
||||
|
||||
// Get a pointer to the current global shell
|
||||
BTestShell *shell = BTestShell::Shell();
|
||||
|
||||
// Empty the UpdateList
|
||||
std::vector<std::string> &list = fObject->AcquireUpdateList();
|
||||
for (std::vector<std::string>::iterator i = list.begin();
|
||||
@@ -164,7 +161,7 @@ BThreadedTestCaller<TestClass, ExpectedException>::run(CppUnit::TestResult *resu
|
||||
{
|
||||
// Only print to standard out if the current global shell
|
||||
// lets us (or if no global shell is designated).
|
||||
if ((shell && shell->BeVerbose()) || !shell) {
|
||||
if (BTestShell::GlobalBeVerbose()) {
|
||||
printf("%s", (*i).c_str());
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user