No longer needed, thus removed
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@291 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,127 +0,0 @@
|
||||
#include "StorageKitTester.h"
|
||||
#include <unistd.h>
|
||||
#include "TestUtils.h"
|
||||
|
||||
#include <Path.h>
|
||||
|
||||
// ##### Include your test headers here #####
|
||||
#include "DirectoryTest.h"
|
||||
#include "EntryTest.h"
|
||||
#include "FileTest.h"
|
||||
#include "FindDirectoryTest.h"
|
||||
#include "MimeTypeTest.h"
|
||||
#include "NodeTest.h"
|
||||
#include "PathTest.h"
|
||||
#include "QueryTest.h"
|
||||
#include "ResourcesTest.h"
|
||||
#include "ResourceStringsTest.h"
|
||||
#include "SymLinkTest.h"
|
||||
|
||||
|
||||
StorageKit::TestShell shell;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// ##### Add your test suites here #####
|
||||
shell.AddSuite( "BDirectory", &DirectoryTest::Suite );
|
||||
shell.AddSuite( "BEntry", &EntryTest::Suite );
|
||||
shell.AddSuite( "BFile", &FileTest::Suite );
|
||||
shell.AddSuite( "BMimeType", &MimeTypeTest::Suite );
|
||||
shell.AddSuite( "BNode", &NodeTest::Suite );
|
||||
shell.AddSuite( "BPath", &PathTest::Suite );
|
||||
shell.AddSuite( "BQuery", &QueryTest::Suite );
|
||||
shell.AddSuite( "BResources", &ResourcesTest::Suite );
|
||||
shell.AddSuite( "BResourceStrings", &ResourceStringsTest::Suite );
|
||||
shell.AddSuite( "BSymLink", &SymLinkTest::Suite );
|
||||
shell.AddSuite( "FindDirectory", &FindDirectoryTest::Suite );
|
||||
|
||||
return shell.Run(argc, argv);
|
||||
}
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// StorageKit::TestShell
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
TestShell::TestShell()
|
||||
: CppUnitShell(),
|
||||
fTestDir(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
TestShell::~TestShell()
|
||||
{
|
||||
delete fTestDir;
|
||||
}
|
||||
|
||||
int
|
||||
TestShell::Run(int argc, char *argv[])
|
||||
{
|
||||
// Let's hope BPath does work. ;-)
|
||||
BPath path(argv[0]);
|
||||
if (path.InitCheck() == B_OK) {
|
||||
fTestDir = new BPath();
|
||||
if (path.GetParent(fTestDir) != B_OK)
|
||||
printf("Couldn't get test dir.\n");
|
||||
} else
|
||||
printf("Couldn't find the path to the test app.\n");
|
||||
return CppUnitShell::Run(argc, argv);
|
||||
}
|
||||
|
||||
void
|
||||
TestShell::PrintDescription(int argc, char *argv[]) {
|
||||
std::string AppName = argv[0];
|
||||
cout << endl;
|
||||
cout << "This program is the central testing framework for the purpose" << endl;
|
||||
cout << "of testing and verifying the behavior of the OpenBeOS Storage" << endl;
|
||||
cout << "Kit." << endl;
|
||||
|
||||
if (AppName.rfind("Test.StorageKit.R5") != std::string::npos) {
|
||||
cout << endl;
|
||||
cout << "Judging by its name (Test.StorageKit.R5), this copy was" << endl;
|
||||
cout << "probably linked again Be Inc.'s R5 Storage Kit for the sake" << endl;
|
||||
cout << "of comparison against our own implementation." << endl;
|
||||
}
|
||||
else if (AppName.rfind("Test.StorageKit.OpenBeOS") != std::string::npos) {
|
||||
cout << endl;
|
||||
cout << "Judging by its name (Test.StorageKit.OpenBeOS), this copy" << endl;
|
||||
cout << "was probably linked against the OpenBeOS implementation of" << endl;
|
||||
cout << "the Storage Kit." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
TestShell::TestDir() const
|
||||
{
|
||||
return (fTestDir ? fTestDir->Path() : NULL);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// TestCase
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
TestCase::TestCase() : fValidCWD(false) {
|
||||
}
|
||||
|
||||
// Saves the location of the current working directory. To return to the
|
||||
// last saved working directory, all \ref RestorCWD().
|
||||
void
|
||||
TestCase::SaveCWD() {
|
||||
fValidCWD = getcwd(fCurrentWorkingDir, B_PATH_NAME_LENGTH);
|
||||
}
|
||||
|
||||
/* Restores the current working directory to last directory saved by a
|
||||
call to SaveCWD(). If SaveCWD() has not been called and an alternate
|
||||
directory is specified by alternate, the current working directory is
|
||||
changed to alternate. If alternate is null, the current working directory
|
||||
is not modified.
|
||||
*/
|
||||
void
|
||||
TestCase::RestoreCWD(const char *alternate) {
|
||||
if (fValidCWD)
|
||||
chdir(fCurrentWorkingDir);
|
||||
else if (alternate != NULL)
|
||||
chdir(alternate);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
#ifndef __sk_testing_is_so_much_fun_h__
|
||||
#define __sk_testing_is_so_much_fun_h__
|
||||
|
||||
// Some nicer test macros.
|
||||
#ifdef TEST_R5
|
||||
#define SK_TEST_R5 1
|
||||
#define SK_TEST_OBOS_POSIX 0
|
||||
#else
|
||||
#define SK_TEST_R5 0
|
||||
#define SK_TEST_OBOS_POSIX 1
|
||||
#endif
|
||||
|
||||
#include <CppUnitShell.h>
|
||||
#include <cppunit/TestCase.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Handy defines :-)
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
#define RES DecodeResult
|
||||
|
||||
class BPath;
|
||||
|
||||
namespace StorageKit {
|
||||
|
||||
class TestSuite : public CppUnit::TestSuite {
|
||||
virtual void run (CppUnit::TestResult *result) {
|
||||
setUp();
|
||||
CppUnit::TestSuite::run(result);
|
||||
tearDown();
|
||||
}
|
||||
|
||||
// This function called *once* before the entire suite of tests is run
|
||||
virtual void setUp() {}
|
||||
|
||||
// This function called *once* after the entire suite of tests is run
|
||||
virtual void tearDown() {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TestShell : public CppUnitShell {
|
||||
public:
|
||||
TestShell();
|
||||
~TestShell();
|
||||
int Run(int argc, char *argv[]);
|
||||
virtual void PrintDescription(int argc, char *argv[]);
|
||||
const char* TestDir() const;
|
||||
private:
|
||||
BPath *fTestDir;
|
||||
};
|
||||
|
||||
class TestCase : public CppUnit::TestCase {
|
||||
public:
|
||||
TestCase();
|
||||
void SaveCWD();
|
||||
void RestoreCWD(const char *alternate = NULL);
|
||||
protected:
|
||||
bool fValidCWD;
|
||||
char fCurrentWorkingDir[B_PATH_NAME_LENGTH+1];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
extern StorageKit::TestShell shell;
|
||||
|
||||
|
||||
#endif // __sk_testing_is_so_much_fun_h__
|
||||
@@ -1,89 +0,0 @@
|
||||
// TestApp.cpp
|
||||
|
||||
#include "TestApp.h"
|
||||
|
||||
// TestHandler
|
||||
|
||||
// MessageReceived
|
||||
void
|
||||
TestHandler::MessageReceived(BMessage *message)
|
||||
{
|
||||
// clone and push it
|
||||
BMessage *clone = new BMessage(*message);
|
||||
fQueue.Lock();
|
||||
fQueue.AddMessage(clone);
|
||||
fQueue.Unlock();
|
||||
}
|
||||
|
||||
// Queue
|
||||
BMessageQueue &
|
||||
TestHandler::Queue()
|
||||
{
|
||||
return fQueue;
|
||||
}
|
||||
|
||||
|
||||
// TestApp
|
||||
|
||||
// constructor
|
||||
TestApp::TestApp(const char *signature)
|
||||
: BApplication(signature),
|
||||
fAppThread(B_ERROR),
|
||||
fHandler()
|
||||
{
|
||||
AddHandler(&fHandler);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
// Init
|
||||
status_t
|
||||
TestApp::Init()
|
||||
{
|
||||
status_t error = B_OK;
|
||||
fAppThread = spawn_thread(&_AppThreadStart, "query app",
|
||||
B_NORMAL_PRIORITY, this);
|
||||
if (fAppThread < 0)
|
||||
error = fAppThread;
|
||||
else {
|
||||
error = resume_thread(fAppThread);
|
||||
if (error != B_OK)
|
||||
kill_thread(fAppThread);
|
||||
}
|
||||
if (error != B_OK)
|
||||
fAppThread = B_ERROR;
|
||||
return error;
|
||||
}
|
||||
|
||||
// Terminate
|
||||
void
|
||||
TestApp::Terminate()
|
||||
{
|
||||
PostMessage(B_QUIT_REQUESTED, this);
|
||||
int32 result;
|
||||
wait_for_thread(fAppThread, &result);
|
||||
}
|
||||
|
||||
// ReadyToRun
|
||||
void
|
||||
TestApp::ReadyToRun()
|
||||
{
|
||||
}
|
||||
|
||||
// Handler
|
||||
TestHandler &
|
||||
TestApp::Handler()
|
||||
{
|
||||
return fHandler;
|
||||
}
|
||||
|
||||
// _AppThreadStart
|
||||
int32
|
||||
TestApp::_AppThreadStart(void *data)
|
||||
{
|
||||
if (TestApp *app = (TestApp*)data) {
|
||||
app->Lock();
|
||||
app->Run();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// TestApp.h
|
||||
|
||||
#ifndef _sk_test_app_h_
|
||||
#define _sk_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 // _sk_test_app_h_
|
||||
@@ -1,199 +0,0 @@
|
||||
// TestUtils.cpp
|
||||
|
||||
#include "TestUtils.h"
|
||||
#include <TestShell.h>
|
||||
|
||||
status_t DecodeResult(status_t result) {
|
||||
if (!BTestShell::GlobalBeVerbose())
|
||||
return result;
|
||||
|
||||
std::string str;
|
||||
switch (result) {
|
||||
|
||||
case B_OK:
|
||||
str = "B_OK";
|
||||
break;
|
||||
|
||||
case B_ERROR:
|
||||
str = "B_ERROR";
|
||||
break;
|
||||
|
||||
|
||||
// Storage Kit Errors
|
||||
case B_FILE_ERROR:
|
||||
str = "B_FILE_ERROR";
|
||||
break;
|
||||
|
||||
case B_FILE_NOT_FOUND:
|
||||
str = "B_FILE_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_FILE_EXISTS:
|
||||
str = "B_FILE_EXISTS";
|
||||
break;
|
||||
|
||||
case B_ENTRY_NOT_FOUND:
|
||||
str = "B_ENTRY_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_NAME_TOO_LONG:
|
||||
str = "B_NAME_TOO_LONG";
|
||||
break;
|
||||
|
||||
case B_DIRECTORY_NOT_EMPTY:
|
||||
str = "B_DIRECTORY_NOT_EMPTY";
|
||||
break;
|
||||
|
||||
case B_DEVICE_FULL:
|
||||
str = "B_DEVICE_FULL";
|
||||
break;
|
||||
|
||||
case B_READ_ONLY_DEVICE:
|
||||
str = "B_READ_ONLY_DEVICE";
|
||||
break;
|
||||
|
||||
case B_IS_A_DIRECTORY:
|
||||
str = "B_IS_A_DIRECTORY";
|
||||
break;
|
||||
|
||||
case B_NO_MORE_FDS:
|
||||
str = "B_NO_MORE_FDS";
|
||||
break;
|
||||
|
||||
case B_CROSS_DEVICE_LINK:
|
||||
str = "B_CROSS_DEVICE_LINK";
|
||||
break;
|
||||
|
||||
case B_LINK_LIMIT:
|
||||
str = "B_LINK_LIMIT";
|
||||
break;
|
||||
|
||||
case B_BUSTED_PIPE:
|
||||
str = "B_BUSTED_PIPE";
|
||||
break;
|
||||
|
||||
case B_UNSUPPORTED:
|
||||
str = "B_UNSUPPORTED";
|
||||
break;
|
||||
|
||||
case B_PARTITION_TOO_SMALL:
|
||||
str = "B_PARTITION_TOO_SMALL";
|
||||
break;
|
||||
|
||||
|
||||
// General Errors
|
||||
case B_NO_MEMORY:
|
||||
str = "B_NO_MEMORY";
|
||||
break;
|
||||
|
||||
case B_IO_ERROR:
|
||||
str = "B_IO_ERROR";
|
||||
break;
|
||||
|
||||
case B_PERMISSION_DENIED:
|
||||
str = "B_PERMISSION_DENIED";
|
||||
break;
|
||||
|
||||
case B_BAD_INDEX:
|
||||
str = "B_BAD_INDEX";
|
||||
break;
|
||||
|
||||
case B_BAD_TYPE:
|
||||
str = "B_BAD_TYPE";
|
||||
break;
|
||||
|
||||
case B_BAD_VALUE:
|
||||
str = "B_BAD_VALUE";
|
||||
break;
|
||||
|
||||
case B_MISMATCHED_VALUES:
|
||||
str = "B_MISMATCHED_VALUES";
|
||||
break;
|
||||
|
||||
case B_NAME_NOT_FOUND:
|
||||
str = "B_NAME_NOT_FOUND";
|
||||
break;
|
||||
|
||||
case B_NAME_IN_USE:
|
||||
str = "B_NAME_IN_USE";
|
||||
break;
|
||||
|
||||
case B_TIMED_OUT:
|
||||
str = "B_TIMED_OUT";
|
||||
break;
|
||||
|
||||
case B_INTERRUPTED:
|
||||
str = "B_INTERRUPTED";
|
||||
break;
|
||||
|
||||
case B_WOULD_BLOCK:
|
||||
str = "B_WOULD_BLOCK";
|
||||
break;
|
||||
|
||||
case B_CANCELED:
|
||||
str = "B_CANCELED";
|
||||
break;
|
||||
|
||||
case B_NO_INIT:
|
||||
str = "B_NO_INIT";
|
||||
break;
|
||||
|
||||
case B_BUSY:
|
||||
str = "B_BUSY";
|
||||
break;
|
||||
|
||||
case B_NOT_ALLOWED:
|
||||
str = "B_NOT_ALLOWED";
|
||||
break;
|
||||
|
||||
|
||||
// Kernel Errors
|
||||
case B_BAD_ADDRESS:
|
||||
str = "B_BAD_ADDRESS";
|
||||
break;
|
||||
|
||||
// OS Errors
|
||||
case B_BAD_PORT_ID:
|
||||
str = "B_BAD_PORT_ID";
|
||||
break;
|
||||
|
||||
// Anything Else
|
||||
default:
|
||||
str = "??????????";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
cout << endl << "DecodeResult() -- " "0x" << hex << result << " (" << dec << result << ") == " << str << endl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command) {
|
||||
if (command)
|
||||
system(command);
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command, const char *parameter) {
|
||||
if (command && parameter) {
|
||||
char *cmdLine = new char[strlen(command) + strlen(parameter) + 1];
|
||||
strcpy(cmdLine, command);
|
||||
strcat(cmdLine, parameter);
|
||||
system(cmdLine);
|
||||
delete[] cmdLine;
|
||||
}
|
||||
}
|
||||
|
||||
void ExecCommand(const char *command, const char *parameter1,
|
||||
const char *parameter2) {
|
||||
if (command && parameter1 && parameter2) {
|
||||
char *cmdLine = new char[strlen(command) + strlen(parameter1)
|
||||
+ 1 + strlen(parameter2) + 1];
|
||||
strcpy(cmdLine, command);
|
||||
strcat(cmdLine, parameter1);
|
||||
strcat(cmdLine, " ");
|
||||
strcat(cmdLine, parameter2);
|
||||
system(cmdLine);
|
||||
delete[] cmdLine;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef __sk_test_utils_h__
|
||||
#define __sk_test_utils_h__
|
||||
|
||||
#include <string>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// 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 // __sk_test_utils_h__
|
||||
Reference in New Issue
Block a user