aboutsummaryrefslogtreecommitdiff
path: root/engines/testbed/fs.cpp
diff options
context:
space:
mode:
authorNeeraj Kumar2010-08-07 21:01:31 +0000
committerNeeraj Kumar2010-08-07 21:01:31 +0000
commit37d28b35b9b7ed2c71af7ea59b7bc4706412192c (patch)
tree7907f135d86237b0d2df810309448c5691512750 /engines/testbed/fs.cpp
parentdab72c519c7aa4ba1e7bc451222e8d0ac3367ac3 (diff)
downloadscummvm-rg350-37d28b35b9b7ed2c71af7ea59b7bc4706412192c.tar.gz
scummvm-rg350-37d28b35b9b7ed2c71af7ea59b7bc4706412192c.tar.bz2
scummvm-rg350-37d28b35b9b7ed2c71af7ea59b7bc4706412192c.zip
TESTBED: added checks to make sure the object is acquired before use, fixed a typo
svn-id: r51841
Diffstat (limited to 'engines/testbed/fs.cpp')
-rw-r--r--engines/testbed/fs.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index 7cae7ef6c1..ca255d547d 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -68,8 +68,8 @@ bool FStests::testReadFile() {
Common::FSDirectory gameRoot(path);
int numFailed = 0;
- if (!gameRoot.getFSNode().isDirectory()) {
- Testsuite::logDetailedPrintf("game Path should be a directory");
+ if (!gameRoot.getFSNode().exists() || !gameRoot.getFSNode().isDirectory()) {
+ Testsuite::logDetailedPrintf("game Path should be an existing directory");
return false;
}
@@ -81,6 +81,11 @@ bool FStests::testReadFile() {
Common::String fileName = file[i];
Common::FSDirectory *directory = gameRoot.getSubDirectory(dirName);
+ if (!directory) {
+ Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
+ return false;
+ }
+
if (!readDataFromFile(directory, fileName.c_str())) {
Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
numFailed++;
@@ -90,7 +95,12 @@ bool FStests::testReadFile() {
fileName.toLowercase();
delete directory;
directory = gameRoot.getSubDirectory(dirName);
-
+
+ if (!directory) {
+ Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
+ return false;
+ }
+
if (!readDataFromFile(directory, fileName.c_str())) {
Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
numFailed++;
@@ -100,7 +110,12 @@ bool FStests::testReadFile() {
fileName.toUppercase();
delete directory;
directory = gameRoot.getSubDirectory(dirName);
-
+
+ if (!directory) {
+ Testsuite::logDetailedPrintf("Failed to open directory %s during FS tests\n", dirName.c_str());
+ return false;
+ }
+
if (!readDataFromFile(directory, fileName.c_str())) {
Testsuite::logDetailedPrintf("Reading from %s/%s failed\n", dirName.c_str(), fileName.c_str());
numFailed++;
@@ -119,6 +134,10 @@ bool FStests::testReadFile() {
bool FStests::testWriteFile() {
const Common::String &path = ConfMan.get("path");
Common::FSNode gameRoot(path);
+ if (!gameRoot.exists()) {
+ Testsuite::logPrintf("Couldn't open the game data directory %s", path.c_str());
+ return false;
+ }
Common::FSNode fileToWrite = gameRoot.getChild("testbed.out");
@@ -134,6 +153,10 @@ bool FStests::testWriteFile() {
delete ws;
Common::SeekableReadStream *rs = fileToWrite.createReadStream();
+ if (!rs) {
+ Testsuite::logDetailedPrintf("Can't open recently written file testbed.out in game data dir\n");
+ return false;
+ }
Common::String readFromFile = rs->readLine();
delete rs;
@@ -159,6 +182,9 @@ FSTestSuite::FSTestSuite() {
logPrintf("WARNING! : Game Data not found. Skipping FS tests\n");
_isGameDataFound = false;
Testsuite::enable(false);
+ } else {
+ _isGameDataFound = true;
+ Testsuite::enable(true);
}
addTest("ReadingFile", &FStests::testReadFile, false);
addTest("WritingFile", &FStests::testWriteFile, false);