[Scummvm-cvs-logs] SF.net SVN: scummvm:[50545] scummvm/branches/gsoc2010-testbed/engines/ testbed

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Thu Jul 1 14:30:56 CEST 2010


Revision: 50545
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50545&view=rev
Author:   sud03r
Date:     2010-07-01 12:30:56 +0000 (Thu, 01 Jul 2010)

Log Message:
-----------
testbed now keeps a list of executed testsuites

Modified Paths:
--------------
    scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/savegame.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
    scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-07-01 12:30:56 UTC (rev 50545)
@@ -148,11 +148,11 @@
 
 
 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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/misc.cpp	2010-07-01 12:30:56 UTC (rev 50545)
@@ -77,7 +77,7 @@
 	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 @@
 }
 
 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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/savegame.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/savegame.cpp	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/savegame.cpp	2010-07-01 12:30:56 UTC (rev 50545)
@@ -195,11 +195,11 @@
 }
 
 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 {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-07-01 12:30:56 UTC (rev 50545)
@@ -33,7 +33,6 @@
 #include "testbed/misc.h"
 #include "testbed/savegame.h"
 #include "testbed/testbed.h"
-#include "testbed/testsuite.h"
  
 namespace Testbed {
  
@@ -50,14 +49,57 @@
 	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() {
 	// Initialize graphics using following:
 	initGraphics(320, 200, false);
@@ -73,9 +115,9 @@
 	// 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 @@
 		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;
 }

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.h	2010-07-01 12:30:56 UTC (rev 50545)
@@ -26,7 +26,9 @@
 #define TESTBED_H
  
 #include "engines/engine.h"
- 
+
+#include "testbed/testsuite.h"
+
 namespace Testbed {
 
 enum {
@@ -40,6 +42,20 @@
 	~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

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.cpp	2010-07-01 12:30:56 UTC (rev 50545)
@@ -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 @@
 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 @@
 	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()) {

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-01 12:01:17 UTC (rev 50544)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testsuite.h	2010-07-01 12:30:56 UTC (rev 50545)
@@ -50,11 +50,17 @@
  */
 
 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 @@
 	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 @@
 	 *
 	 * @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 @@
 	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:
 	/**


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list