aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeeraj Kumar2010-07-01 12:30:56 +0000
committerNeeraj Kumar2010-07-01 12:30:56 +0000
commit9a4bd4220fa000159cb300b2f66301b7150d0bd7 (patch)
tree53ee2184c017cbf5e98d4ab21ce39f5ff12d6090
parent68d691bc3e5ee711daad2979c7db325c16e4c1f0 (diff)
downloadscummvm-rg350-9a4bd4220fa000159cb300b2f66301b7150d0bd7.tar.gz
scummvm-rg350-9a4bd4220fa000159cb300b2f66301b7150d0bd7.tar.bz2
scummvm-rg350-9a4bd4220fa000159cb300b2f66301b7150d0bd7.zip
testbed now keeps a list of executed testsuites
svn-id: r50545
-rw-r--r--engines/testbed/fs.cpp6
-rw-r--r--engines/testbed/misc.cpp10
-rw-r--r--engines/testbed/savegame.cpp10
-rw-r--r--engines/testbed/testbed.cpp62
-rw-r--r--engines/testbed/testbed.h18
-rw-r--r--engines/testbed/testsuite.cpp12
-rw-r--r--engines/testbed/testsuite.h24
7 files changed, 109 insertions, 33 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index c59455ee83..b0ef8f8d46 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -148,11 +148,11 @@ bool FStests::testWriteFile() {
FSTestSuite::FSTestSuite() {
- addTest("ReadingFile", &FStests::testReadFile);
- addTest("WritingFile", &FStests::testWriteFile);
+ addTest("ReadingFile", &FStests::testReadFile, false);
+ addTest("WritingFile", &FStests::testWriteFile, false);
}
const char *FSTestSuite::getName() const {
- return "File System";
+ return "FS";
}
} // End of namespace Testbed
diff --git a/engines/testbed/misc.cpp b/engines/testbed/misc.cpp
index 4359127053..12b31ea5ab 100644
--- a/engines/testbed/misc.cpp
+++ b/engines/testbed/misc.cpp
@@ -77,7 +77,7 @@ bool MiscTests::testDateTime() {
getHumanReadableFormat(t1, dateTimeNow);
Testsuite::logDetailedPrintf("%s\n", dateTimeNow.c_str());
- if (Testsuite::isInteractive) {
+ if (Testsuite::isSessionInteractive) {
// Directly verify date
dateTimeNow = "We expect the current date time to be " + dateTimeNow;
Testsuite::clearScreen();
@@ -143,12 +143,12 @@ bool MiscTests::testMutexes() {
}
MiscTestSuite::MiscTestSuite() {
- addTest("Date/time", &MiscTests::testDateTime);
- addTest("Timers", &MiscTests::testTimers);
- addTest("Mutexes", &MiscTests::testMutexes);
+ addTest("Date/time", &MiscTests::testDateTime, false);
+ addTest("Timers", &MiscTests::testTimers, false);
+ addTest("Mutexes", &MiscTests::testMutexes, false);
}
const char *MiscTestSuite::getName() const {
- return "Misc. Tests: Datetime/Timer/Mutextes";
+ return "Misc";
}
} // End of namespace Testbed
diff --git a/engines/testbed/savegame.cpp b/engines/testbed/savegame.cpp
index 1e645c2439..6349f0af7f 100644
--- a/engines/testbed/savegame.cpp
+++ b/engines/testbed/savegame.cpp
@@ -195,11 +195,11 @@ bool SaveGametests::testErrorMessages() {
}
SaveGameTestSuite::SaveGameTestSuite() {
- addTest("Opening SaveFile", &SaveGametests::testSaveLoadState);
- addTest("Removing SaveFile", &SaveGametests::testRemovingSavefile);
- addTest("Renaming SaveFile", &SaveGametests::testRenamingSavefile);
- addTest("Listing SaveFile", &SaveGametests::testListingSavefile);
- addTest("Verify Error Messages", &SaveGametests::testErrorMessages);
+ addTest("Opening SaveFile", &SaveGametests::testSaveLoadState, false);
+ addTest("Removing SaveFile", &SaveGametests::testRemovingSavefile, false);
+ addTest("Renaming SaveFile", &SaveGametests::testRenamingSavefile, false);
+ addTest("Listing SaveFile", &SaveGametests::testListingSavefile, false);
+ addTest("Verify Error Messages", &SaveGametests::testErrorMessages, false);
}
const char *SaveGameTestSuite::getName() const {
diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp
index 3bb2490cf3..76ad50baa1 100644
--- a/engines/testbed/testbed.cpp
+++ b/engines/testbed/testbed.cpp
@@ -33,7 +33,6 @@
#include "testbed/misc.h"
#include "testbed/savegame.h"
#include "testbed/testbed.h"
-#include "testbed/testsuite.h"
namespace Testbed {
@@ -50,12 +49,55 @@ TestbedEngine::TestbedEngine(OSystem *syst)
DebugMan.addDebugChannel(kTestbedLogOutput, "LOG", "Log of test results generated by testbed");
DebugMan.addDebugChannel(kTestbedEngineDebug, "Debug", "Engine-specific debug statements");
DebugMan.enableDebugChannel("LOG");
+
+ // Initialize testsuites here
+ // GFX
+ Testsuite *ts = new GFXTestSuite();
+ _testsuiteList.push_back(ts);
+ // FS
+ ts = new FSTestSuite();
+ _testsuiteList.push_back(ts);
+ // Savegames
+ ts = new SaveGameTestSuite();
+ _testsuiteList.push_back(ts);
+ // Misc.
+ ts = new MiscTestSuite();
+ _testsuiteList.push_back(ts);
}
TestbedEngine::~TestbedEngine() {
Testsuite::deleteWriteStream();
// Remove all of our debug levels here
DebugMan.clearAllDebugChannels();
+
+ for (Common::Array<Testsuite*>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
+ delete (*i);
+ }
+}
+
+void TestbedEngine::enableTestsuite(const char *name, bool enable) {
+ Common::Array<Testsuite*>::const_iterator iter;
+ Common::String tsName(name);
+
+
+ for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
+ if (tsName.equalsIgnoreCase((*iter)->getName())) {
+ (*iter)->enable(enable);
+ break;
+ }
+ }
+
+ return;
+}
+
+void TestbedEngine::invokeTestsuites() {
+ Common::Array<Testsuite*>::const_iterator iter;
+
+ for (iter = _testsuiteList.begin(); iter != _testsuiteList.end(); iter++) {
+ if ((*iter)->isEnabled()) {
+ (*iter)->execute();
+ }
+ }
}
Common::Error TestbedEngine::run() {
@@ -73,9 +115,9 @@ Common::Error TestbedEngine::run() {
// To be set from config file
// By default Interactive tests are enabled
// XXX: disabling these as of now for fastly testing other tests
- Testsuite::isInteractive = false;
+ Testsuite::isSessionInteractive = false;
- if (Testsuite::isInteractive) {
+ if (Testsuite::isSessionInteractive) {
Testsuite::logPrintf("Info! : Interactive tests are also being executed.\n");
Testsuite::displayMessage(prompt, "Proceed?");
// Executing GFX Tests
@@ -83,14 +125,14 @@ Common::Error TestbedEngine::run() {
gts.execute();
}
- FSTestSuite fts;
- fts.execute();
-
- SaveGameTestSuite sts;
- sts.execute();
+ // Enable the testsuites you want to execute
+ enableTestsuite("FS", true);
+ enableTestsuite("GFX", true);
+ enableTestsuite("savegames", true);
+ enableTestsuite("misc", true);
+ // invoke them
+ invokeTestsuites();
- MiscTestSuite mts;
- mts.execute();
return Common::kNoError;
}
diff --git a/engines/testbed/testbed.h b/engines/testbed/testbed.h
index 554c0290a0..7c45c5aa56 100644
--- a/engines/testbed/testbed.h
+++ b/engines/testbed/testbed.h
@@ -26,7 +26,9 @@
#define TESTBED_H
#include "engines/engine.h"
-
+
+#include "testbed/testsuite.h"
+
namespace Testbed {
enum {
@@ -40,6 +42,20 @@ public:
~TestbedEngine();
virtual Common::Error run();
+
+ /**
+ * All testsuites are disabled by default
+ * To enable testsuite X, call enableTestsuite("X", true);
+ */
+ void enableTestsuite(const char *name, bool enable);
+
+ /**
+ * Invokes configured testsuites.
+ */
+ void invokeTestsuites();
+
+private:
+ Common::Array<Testsuite*> _testsuiteList;
};
} // End of namespace Testbed
diff --git a/engines/testbed/testsuite.cpp b/engines/testbed/testsuite.cpp
index 488f3e0a8c..e1e39dbfeb 100644
--- a/engines/testbed/testsuite.cpp
+++ b/engines/testbed/testsuite.cpp
@@ -36,7 +36,7 @@
namespace Testbed {
// Static public variable of Testsuite
-bool Testsuite::isInteractive = true;
+bool Testsuite::isSessionInteractive = true;
// Static private variable of Testsuite
Common::String Testsuite::_logDirectory = "";
@@ -113,6 +113,8 @@ void Testsuite::logDetailedPrintf(const char *fmt, ...) {
Testsuite::Testsuite() {
_numTestsPassed = 0;
_numTestsExecuted = 0;
+ // Initially all testsuites are disabled, enable them by calling enableTestSuite(name, true)
+ _isTsEnabled = false;
}
Testsuite::~Testsuite() {
@@ -200,13 +202,17 @@ void Testsuite::clearScreen(bool flag) {
g_system->updateScreen();
}
-void Testsuite::addTest(const Common::String &name, InvokingFunction f) {
- Test* featureTest = new Test(name, f);
+void Testsuite::addTest(const Common::String &name, InvokingFunction f, bool isInteractive) {
+ Test* featureTest = new Test(name, f, isInteractive);
_testsToExecute.push_back(featureTest);
}
void Testsuite::execute() {
for (Common::Array<Test*>::iterator i = _testsToExecute.begin(); i != _testsToExecute.end(); ++i) {
+ if((*i)->isInteractive && !isSessionInteractive) {
+ logPrintf("Info! Skipping Test: %s, non-interactive environment is selected\n", ((*i)->featureName).c_str());
+ continue;
+ }
logPrintf("Info! Executing Test: %s\n", ((*i)->featureName).c_str());
_numTestsExecuted++;
if ((*i)->driver()) {
diff --git a/engines/testbed/testsuite.h b/engines/testbed/testsuite.h
index b67023ae07..10a673bde6 100644
--- a/engines/testbed/testsuite.h
+++ b/engines/testbed/testsuite.h
@@ -50,11 +50,17 @@ typedef bool (*InvokingFunction)();
*/
struct Test {
- Test(Common::String name, InvokingFunction f) : featureName(name), driver(f), enabled(true), passed(false) {}
- Common::String featureName; ///< Name of feature to be tested
- InvokingFunction driver; ///< Pointer to the function that will invoke this feature test
+ Test(Common::String name, InvokingFunction f, bool interactive) : featureName(name) {
+ driver = f;
+ enabled = true;
+ passed = false;
+ isInteractive = interactive;
+ }
+ const Common::String featureName; ///< Name of feature to be tested
+ InvokingFunction driver; ///< Pointer to the function that will invoke this feature test
bool enabled; ///< Decides whether or not this test is to be executed
bool passed; ///< Collects and stores result of this feature test
+ bool isInteractive; ///< Decides if the test is interactive or not, An interactive testsuite may have non-interactive tests, hence this change.
};
@@ -71,6 +77,10 @@ public:
int getNumTestsPassed() const { return _numTestsPassed; }
int getNumTestsFailed() const { return _numTestsExecuted - _numTestsPassed; }
void genReport() const;
+ bool isEnabled() const { return _isTsEnabled; }
+ void enable(bool flag) {
+ _isTsEnabled = flag;
+ }
/**
* Prompts for User Input in form of "Yes" or "No" for interactive tests
@@ -92,8 +102,9 @@ public:
*
* @param name the string description of the test, for display purposes
* @param f pointer to the function that invokes this test
+ * @param isInteractive decides if the test is to be executed in interactive mode/ default true
*/
- void addTest(const Common::String &name, InvokingFunction f);
+ void addTest(const Common::String &name, InvokingFunction f, bool isInteractive = true);
/**
* The driver function for the testsuite
@@ -119,14 +130,15 @@ protected:
Common::Array<Test*> _testsToExecute; ///< List of tests to be executed
int _numTestsPassed; ///< Number of tests passed
int _numTestsExecuted; ///< Number of tests executed
+ bool _isTsEnabled;
public:
/**
- * Static variable of this class that determines if the tests are interactive or not.
+ * Static variable of this class that determines if the user initiated testing session is interactive or not.
* Used by various tests to respond accordingly
*/
- static bool isInteractive;
+ static bool isSessionInteractive;
private:
/**