aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorMax Horn2006-04-25 21:31:55 +0000
committerMax Horn2006-04-25 21:31:55 +0000
commite9332e41d6508bd143df2e1e2fa31e8434011552 (patch)
tree3b16c667d1f38fdd9b58ec0245f2cb12dd10d3eb /base
parent66783576d419478cab6f85bca2fc44d542a459e7 (diff)
downloadscummvm-rg350-e9332e41d6508bd143df2e1e2fa31e8434011552.tar.gz
scummvm-rg350-e9332e41d6508bd143df2e1e2fa31e8434011552.tar.bz2
scummvm-rg350-e9332e41d6508bd143df2e1e2fa31e8434011552.zip
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)
svn-id: r22158
Diffstat (limited to 'base')
-rw-r--r--base/gameDetector.cpp5
-rw-r--r--base/main.cpp127
2 files changed, 80 insertions, 52 deletions
diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp
index dbe9e7fb16..4c7efa90bd 100644
--- a/base/gameDetector.cpp
+++ b/base/gameDetector.cpp
@@ -382,6 +382,11 @@ Common::String GameDetector::parseCommandLine(Common::StringMap &settings, int a
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
diff --git a/base/main.cpp b/base/main.cpp
index 48b00a0aef..00e5b8b49f 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -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 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String &
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 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
#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