diff --git a/dists/engine-data/create-testbed-data.sh b/dists/engine-data/create-testbed-data.sh new file mode 100755 index 00000000000..1ed6c733b5b --- /dev/null +++ b/dists/engine-data/create-testbed-data.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Create the directory structure +# Avoided bash shortcuts/ file-seperators in interest of portability + +if [ -e testbed ]; then + echo "Game-data already present as testbed/" + echo "To regenerate, remove and rerun" + exit 0 +fi + +mkdir testbed + +cd testbed + +# For game detection +echo "ScummVM rocks!" > TESTBED + +mkdir test1 +mkdir Test2 +mkdir TEST3 +mkdir tEST4 +mkdir test5 + + +cd test1 +echo "It works!" > file.txt +cd .. + +cd Test2 +echo "It works!" > File.txt +cd .. + +cd TEST3 +echo "It works!" > FILE.txt +cd .. + +cd tEST4 +echo "It works!" > fILe.txt +cd .. + +cd test5 +echo "It works!" > file. +cd .. + +# back to the top +cd .. +echo "Game data created" diff --git a/dists/engine-data/createGameData b/dists/engine-data/createGameData deleted file mode 100755 index 8a3cabe0c3a..00000000000 --- a/dists/engine-data/createGameData +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -unzip testbed.zip -mv testbed/testbed_mixed_case testbed/TeStBeD diff --git a/dists/engine-data/testbed.zip b/dists/engine-data/testbed.zip deleted file mode 100644 index 33e1a83ab5a..00000000000 Binary files a/dists/engine-data/testbed.zip and /dev/null differ diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp index fc2204e41c8..847cb28c211 100644 --- a/engines/testbed/fs.cpp +++ b/engines/testbed/fs.cpp @@ -7,7 +7,7 @@ namespace Testbed { /** * This test does the following: * 1) acquires the game-data path - * 2) In the game-data dir, there are three files: testbed, TeStBeD and TESTBED + * 2) In the game-root it navigates to "directory" and opens the file "file" * The former two are directories while the latter is a text file used for game engine detection * * Both the directories contain the file testbed.conf each which has a message written in it. @@ -15,6 +15,34 @@ namespace Testbed { * compares the message contained in it, with what it expects. * */ +bool FStests::readDataFromFile(Common::FSNode &directory, const char *file) { + + + Common::FSDirectory nestedDir(directory); + + Common::SeekableReadStream *readStream = nestedDir.createReadStreamForMember(file); + + if (!readStream) { + printf("LOG:Can't open game file for reading\n"); + return false; + } + + Common::String msg = readStream->readLine(); + delete readStream; + printf("LOG: Message Extracted from %s : %s\n", file, msg.c_str()); + + + Common::String expectedMsg = "It works!"; + + if (!msg.equals(expectedMsg)) { + printf("LOG: Can't read Correct data from file\n"); + return false; + } + + return true; +} + + bool FStests::testReadFile() { const Common::String &path = ConfMan.get("path"); Common::FSNode gameRoot(path); @@ -24,31 +52,31 @@ bool FStests::testReadFile() { return false; } - Common::FSNode subDir = gameRoot.getChild("TeStBeD"); - - if (!subDir.exists()) { - printf("LOG:Unable to recognize TeStBeD Inside the game Dir"); - return false; - } + Common::FSList dirList; + gameRoot.getChildren(dirList); - Common::FSDirectory testBedDir(subDir); + const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file."}; - Common::SeekableReadStream *readStream = testBedDir.createReadStreamForMember("testbed.conf"); - - if (!readStream) { - printf("LOG:Can't open game file for reading\n"); - return false; - } - - Common::String msg = readStream->readLine(); - delete readStream; - printf("LOG: Message Extracted: %s\n", msg.c_str()); - - Common::String expectedMsg = "It works!"; - - if (!msg.equals(expectedMsg)) { - printf("LOG: Can't read Correct data from file\n"); - return false; + for (unsigned int i = 0; i < dirList.size(); i++) { + Common::String fileName = file[i]; + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } + + fileName.toLowercase(); + + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } + + fileName.toUppercase(); + + if (!readDataFromFile(dirList[i], fileName.c_str())) { + printf("LOG : reading from %s failed", fileName.c_str()); + return false; + } } return true; diff --git a/engines/testbed/fs.h b/engines/testbed/fs.h index c4217254073..6f73babf7a3 100644 --- a/engines/testbed/fs.h +++ b/engines/testbed/fs.h @@ -12,6 +12,7 @@ namespace FStests { // from commandline // Helper functions for FS tests +bool readDataFromFile(Common::FSNode &directory, const char *file); // will contain function declarations for FS tests bool testReadFile(); diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index 242504ca114..789fe7c2ecb 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -62,7 +62,7 @@ Common::Error TestbedEngine::run() { // To be set from config file // XXX: disabling these as of now for fastly testing other tests - interactive = true; + interactive = false; if (interactive) { printf("Running Interactive tests as well\n");