[Scummvm-cvs-logs] SF.net SVN: scummvm: [22158] scummvm/trunk/base

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Apr 25 14:33:00 CEST 2006


Revision: 22158
Author:   fingolfin
Date:     2006-04-25 14:31:55 -0700 (Tue, 25 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22158&view=rev

Log Message:
-----------
Added hidden --test-detector command line option to make it easy to test the detector on your config file (to be removed before the next release)

Modified Paths:
--------------
    scummvm/trunk/base/gameDetector.cpp
    scummvm/trunk/base/main.cpp
Modified: scummvm/trunk/base/gameDetector.cpp
===================================================================
--- scummvm/trunk/base/gameDetector.cpp	2006-04-25 21:26:49 UTC (rev 22157)
+++ scummvm/trunk/base/gameDetector.cpp	2006-04-25 21:31:55 UTC (rev 22158)
@@ -382,7 +382,12 @@
 			END_OPTION
 
 
+			// HACK FIXME TODO: This switch is intentionally *not* documented!
+			DO_LONG_OPTION_CMD("test-detector")
+				return "test-detector";
+			END_OPTION
 
+
 			DO_OPTION('c', "config")
 			END_OPTION
 

Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp	2006-04-25 21:26:49 UTC (rev 22157)
+++ scummvm/trunk/base/main.cpp	2006-04-25 21:31:55 UTC (rev 22158)
@@ -51,7 +51,7 @@
 #endif
 
 
-//#define DETECTOR_TESTING_HACK
+#define DETECTOR_TESTING_HACK
 
 #ifdef DETECTOR_TESTING_HACK
 #include "backends/fs/fs.h"
@@ -237,6 +237,77 @@
 	return result;
 }
 
+#ifdef DETECTOR_TESTING_HACK
+static void runDetectorTest() {
+	// HACK: The following code can be used to test the detection code of our
+	// engines. Basically, it loops over all targets, and calls the detector
+	// for the given path. It then prints out the result and also checks
+	// whether the result agrees with the settings of the target.
+	
+	const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
+	Common::ConfigManager::DomainMap::const_iterator iter = domains.begin();
+	int success = 0, failure = 0;
+	for (iter = domains.begin(); iter != domains.end(); ++iter) {
+		Common::String name(iter->_key);
+		Common::String gameid(iter->_value.get("gameid"));
+		Common::String path(iter->_value.get("path"));
+		printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
+				name.c_str(), gameid.c_str(), path.c_str());
+		if (path.empty()) {
+			printf(" ... no path specified, skipping\n");
+			continue;
+		}
+		if (gameid.empty()) {
+			gameid = name;
+		}
+		
+		FilesystemNode dir(path);
+		
+		if (!dir.isValid() || !dir.isDirectory()) {
+			printf(" ... invalid path, skipping\n");
+			continue;
+		}
+		
+		FSList files = dir.listDir(FilesystemNode::kListAll);
+		DetectedGameList candidates(PluginManager::instance().detectGames(files));
+
+		bool gameidDiffers = false;
+		for (DetectedGameList::iterator x = candidates.begin(); x != candidates.end(); ++x) {
+			gameidDiffers |= scumm_stricmp(gameid.c_str(), x->gameid.c_str());
+		}
+		
+		if (candidates.empty()) {
+			printf(" FAILURE: No games detected\n");
+			failure++;
+		} else if (candidates.size() > 1) {
+			if (gameidDiffers) {
+				printf(" FAILURE: Multiple games detected, some/all with wrong gameid\n");
+			} else {
+				printf(" FAILURE: Multiple games detected, but all have the same gameid\n");
+			}
+			failure++;
+		} else if (gameidDiffers) {
+			printf(" FAILURE: Wrong gameid detected\n");
+			failure++;
+		} else {
+			printf(" SUCCESS: Game was detected correctly\n");
+			success++;
+		}
+		
+		for (DetectedGameList::iterator x = candidates.begin(); x != candidates.end(); ++x) {
+			printf("    gameid '%s', desc '%s', language '%s', platform '%s'\n",
+					x->gameid.c_str(),
+					x->description.c_str(),
+					Common::getLanguageCode(x->language),
+					Common::getPlatformCode(x->platform));
+		}
+	}
+	int total = domains.size();
+	printf("Detector test run: %d fail, %d success, %d skipped, out of %d\n",
+			failure, success, total - failure - success, total);
+}
+#endif
+
 extern "C" int scummvm_main(int argc, char *argv[]) {
 	Common::String specialDebug;
 	Common::String command;
@@ -294,58 +365,10 @@
 
 
 #ifdef DETECTOR_TESTING_HACK
-	// HACK: The following code can be used to test the detection code of our
-	// engines. Basically, it loops over all targets, and calls the detector
-	// for the given path. It then prints out the result and also checks
-	// whether the result agrees with the settings of the target.
-	
-	const Common::ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
-	Common::ConfigManager::DomainMap::const_iterator iter = domains.begin();
-	for (iter = domains.begin(); iter != domains.end(); ++iter) {
-		Common::String name(iter->_key);
-		Common::String gameid(iter->_value.get("gameid"));
-		Common::String path(iter->_value.get("path"));
-		printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
-				name.c_str(), gameid.c_str(), path.c_str());
-		if (path.empty()) {
-			printf(" ... no path specified, skipping\n");
-			continue;
-		}
-		if (gameid.empty()) {
-			gameid = name;
-		}
-		
-		FilesystemNode dir(path);
-		
-		if (!dir.isValid() || !dir.isDirectory()) {
-			printf(" ... invalid path, skipping\n");
-			continue;
-		}
-		
-		FSList files = dir.listDir(FilesystemNode::kListAll);
-		DetectedGameList candidates(PluginManager::instance().detectGames(files));
-		
-		if (candidates.empty()) {
-			printf(" FAILURE: No games detected\n");
-		} else if (candidates.size() > 1) {
-			printf(" FAILURE: Multiple games detected\n");
-		} else if (scumm_stricmp(gameid.c_str(), candidates.begin()->gameid.c_str())) {
-			printf(" FAILURE: Wrong gameid detected\n");
-		} else {
-			printf(" SUCCESS: Game was detected correctly\n");
-		}
-		
-		for (DetectedGameList::iterator x = candidates.begin(); x != candidates.end(); ++x) {
-			printf("    gameid '%s', desc '%s', language '%s', platform '%s'\n",
-					x->gameid.c_str(),
-					x->description.c_str(),
-					Common::getLanguageCode(x->language),
-					Common::getPlatformCode(x->platform));
-		}
+	else if (command == "test-detector") {
+		runDetectorTest();
+		return 0;
 	}
-	
-	return 0;
-
 #endif
 	
 


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