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

sud03r at users.sourceforge.net sud03r at users.sourceforge.net
Tue Jun 22 16:39:52 CEST 2010


Revision: 50140
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50140&view=rev
Author:   sud03r
Date:     2010-06-22 14:39:51 +0000 (Tue, 22 Jun 2010)

Log Message:
-----------
modified the filesystem test, added a script to directly create the game-data-directory, no zip file required

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

Added Paths:
-----------
    scummvm/branches/gsoc2010-testbed/dists/engine-data/create-testbed-data.sh

Removed Paths:
-------------
    scummvm/branches/gsoc2010-testbed/dists/engine-data/createGameData
    scummvm/branches/gsoc2010-testbed/dists/engine-data/testbed.zip

Added: scummvm/branches/gsoc2010-testbed/dists/engine-data/create-testbed-data.sh
===================================================================
--- scummvm/branches/gsoc2010-testbed/dists/engine-data/create-testbed-data.sh	                        (rev 0)
+++ scummvm/branches/gsoc2010-testbed/dists/engine-data/create-testbed-data.sh	2010-06-22 14:39:51 UTC (rev 50140)
@@ -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"


Property changes on: scummvm/branches/gsoc2010-testbed/dists/engine-data/create-testbed-data.sh
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + text/plain
Added: svn:eol-style
   + native

Deleted: scummvm/branches/gsoc2010-testbed/dists/engine-data/createGameData
===================================================================
--- scummvm/branches/gsoc2010-testbed/dists/engine-data/createGameData	2010-06-22 14:03:55 UTC (rev 50139)
+++ scummvm/branches/gsoc2010-testbed/dists/engine-data/createGameData	2010-06-22 14:39:51 UTC (rev 50140)
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-unzip testbed.zip
-mv testbed/testbed_mixed_case testbed/TeStBeD

Deleted: scummvm/branches/gsoc2010-testbed/dists/engine-data/testbed.zip
===================================================================
(Binary files differ)

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-22 14:03:55 UTC (rev 50139)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.cpp	2010-06-22 14:39:51 UTC (rev 50140)
@@ -7,7 +7,7 @@
 /**
  * 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,26 +15,13 @@
  * compares the message contained in it, with what it expects.
  *
  */
-bool FStests::testReadFile() {
-	const Common::String &path = ConfMan.get("path");
-	Common::FSNode gameRoot(path);
+bool FStests::readDataFromFile(Common::FSNode &directory, const char *file) {
 	
-	if (!gameRoot.isDirectory()) {
-		printf("LOG:game Path should be a directory");
-		return false;
-	}
 	
-	Common::FSNode subDir = gameRoot.getChild("TeStBeD");
+	Common::FSDirectory nestedDir(directory);
 
-	if (!subDir.exists()) {
-		printf("LOG:Unable to recognize TeStBeD Inside the game Dir");
-		return false;
-	}
-	
-	Common::FSDirectory testBedDir(subDir);
+	Common::SeekableReadStream *readStream = nestedDir.createReadStreamForMember(file);
 
-	Common::SeekableReadStream *readStream = testBedDir.createReadStreamForMember("testbed.conf");
-
 	if (!readStream) {
 		printf("LOG:Can't open game file for reading\n");
 		return false;
@@ -42,8 +29,9 @@
 	
 	Common::String msg = readStream->readLine();
 	delete readStream;
-	printf("LOG: Message Extracted: %s\n", msg.c_str());
+	printf("LOG: Message Extracted from %s : %s\n", file, msg.c_str());
 
+
 	Common::String expectedMsg = "It works!";
 
 	if (!msg.equals(expectedMsg)) {
@@ -54,6 +42,46 @@
 	return true;
 }
 
+
+bool FStests::testReadFile() {
+	const Common::String &path = ConfMan.get("path");
+	Common::FSNode gameRoot(path);
+	
+	if (!gameRoot.isDirectory()) {
+		printf("LOG:game Path should be a directory");
+		return false;
+	}
+	
+	Common::FSList dirList;
+	gameRoot.getChildren(dirList);
+	
+	const char *file[] = {"file.txt", "File.txt", "FILE.txt", "fILe.txt", "file."};
+
+	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;
+}
+
 /**
  * This test creates a file testbed.out, writes a sample data and confirms if
  * it is same by reading the file again.

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-22 14:03:55 UTC (rev 50139)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/fs.h	2010-06-22 14:39:51 UTC (rev 50140)
@@ -12,6 +12,7 @@
 // from commandline
 
 // Helper functions for FS tests
+bool readDataFromFile(Common::FSNode &directory, const char *file);
 
 // will contain function declarations for FS tests
 bool testReadFile();

Modified: scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp
===================================================================
--- scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-22 14:03:55 UTC (rev 50139)
+++ scummvm/branches/gsoc2010-testbed/engines/testbed/testbed.cpp	2010-06-22 14:39:51 UTC (rev 50140)
@@ -62,7 +62,7 @@
 
 	// 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");		


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