aboutsummaryrefslogtreecommitdiff
path: root/engines/testbed/fs.cpp
diff options
context:
space:
mode:
authorCameron Cawley2019-07-01 18:51:14 +0100
committerFilippos Karapetis2019-08-11 22:15:54 +0300
commit43b4528552dc7b2a04abd31f88e1e83a726fc98b (patch)
tree7156551fb6fabd894b7b3161f35808f04fdb2145 /engines/testbed/fs.cpp
parent75539407921c660f06b80ed2e242372bee76c5dd (diff)
downloadscummvm-rg350-43b4528552dc7b2a04abd31f88e1e83a726fc98b.tar.gz
scummvm-rg350-43b4528552dc7b2a04abd31f88e1e83a726fc98b.tar.bz2
scummvm-rg350-43b4528552dc7b2a04abd31f88e1e83a726fc98b.zip
TESTBED: Add createDirectory() test in FStests
Diffstat (limited to 'engines/testbed/fs.cpp')
-rw-r--r--engines/testbed/fs.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/engines/testbed/fs.cpp b/engines/testbed/fs.cpp
index 07b1c0f2af..012581a576 100644
--- a/engines/testbed/fs.cpp
+++ b/engines/testbed/fs.cpp
@@ -172,6 +172,35 @@ TestExitStatus FStests::testWriteFile() {
}
+/**
+ * This test creates a directory testbed.dir, and confirms if the directory is created successfully
+ */
+TestExitStatus FStests::testCreateDir() {
+ 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 kTestFailed;
+ }
+
+ Common::FSNode dirToCreate = gameRoot.getChild("testbed.dir");
+
+ // TODO: Delete the directory after creating it
+ if (dirToCreate.exists()) {
+ Testsuite::logDetailedPrintf("Directory already exists in game data dir\n");
+ return kTestSkipped;
+ }
+
+ if (!dirToCreate.createDirectory()) {
+ Testsuite::logDetailedPrintf("Can't create directory in game data dir\n");
+ return kTestFailed;
+ }
+
+ Testsuite::logDetailedPrintf("Directory created successfully\n");
+ return kTestPassed;
+}
+
+
FSTestSuite::FSTestSuite() {
// FS tests depend on Game Data files.
@@ -187,6 +216,7 @@ FSTestSuite::FSTestSuite() {
}
addTest("ReadingFile", &FStests::testReadFile, false);
addTest("WritingFile", &FStests::testWriteFile, false);
+ addTest("CreateDir", &FStests::testCreateDir, false);
}
void FSTestSuite::enable(bool flag) {