diff options
author | Arnstein Ressem <aressem@gmail.com> | 2016-08-23 15:10:36 +0200 |
---|---|---|
committer | Vegard Sjonfjell <vegardsjo@gmail.com> | 2016-08-23 15:10:36 +0200 |
commit | 55e5a91901109161186e05d3a6e959e06958bbba (patch) | |
tree | f312bab2c60207ee305dbcfa047fcc4fa8fd2dc1 /fastos | |
parent | d337a29392fb752dc725e4aea5efa0cc0df5f17a (diff) |
Aressem/cmake more out of source tests (#441)
* vespalib tests run out of source.
* staging_vespalib run tests out of source.
* fastos tests run out of source.
* Fixed storage tests out of source.
* Fixed some of the config tests.
* config* tests run out of source.
* document_* tests run out of source.
* documentapi_ tests run out of source.
* Fixed fsa out of source tests.
* Fix jrt_test out of source.
* More tests run out of source.
* Fix some slobrok and messagebus tests.
* More fixes for out of source tests.
* Done with first pass of regular tests out of source.
* Only use SOURCE_DIRECTORY in a limited set of places.
* Fix some remaining tests.
* Some cleanups.
* No need for extra slash.
Diffstat (limited to 'fastos')
-rw-r--r-- | fastos/src/tests/filetest.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/fastos/src/tests/filetest.cpp b/fastos/src/tests/filetest.cpp index ca53c359605..ca7a3b235e1 100644 --- a/fastos/src/tests/filetest.cpp +++ b/fastos/src/tests/filetest.cpp @@ -41,9 +41,10 @@ class FileTest : public BaseTest private: virtual bool useProcessStarter() const { return true; } public: - static const char * roFilename; - static const char * woFilename; - static const char * rwFilename; + const std::string srcDir = getenv("SOURCE_DIRECTORY") ? getenv("SOURCE_DIRECTORY") : "."; + const std::string roFilename = srcDir + "/hello.txt"; + const std::string woFilename = "generated/writeonlytest.txt"; + const std::string rwFilename = "generated/readwritetest.txt"; void DirectoryTest() { @@ -435,7 +436,7 @@ public: { TestHeader("Read-Only Test"); - FastOS_File *myFile = new FastOS_File(roFilename); + FastOS_File *myFile = new FastOS_File(roFilename.c_str()); if (myFile->OpenReadOnly()) { int64_t filesize; @@ -472,7 +473,7 @@ public: } } } else { - Progress(false, "Unable to open file '%s'.", roFilename); + Progress(false, "Unable to open file '%s'.", roFilename.c_str()); } delete(myFile); PrintSeparator(); @@ -483,7 +484,7 @@ public: TestHeader("Write-Only Test"); FastOS_File::MakeDirectory("generated"); - FastOS_File *myFile = new FastOS_File(woFilename); + FastOS_File *myFile = new FastOS_File(woFilename.c_str()); if (myFile->OpenWriteOnly()) { int64_t filesize; @@ -531,12 +532,12 @@ public: bool closeResult = myFile->Close(); Progress(closeResult, "Close file."); } else { - Progress(false, "Unable to open file '%s'.", woFilename); + Progress(false, "Unable to open file '%s'.", woFilename.c_str()); } bool deleteResult = myFile->Delete(); - Progress(deleteResult, "Delete file '%s'.", woFilename); + Progress(deleteResult, "Delete file '%s'.", woFilename.c_str()); delete(myFile); FastOS_File::EmptyAndRemoveDirectory("generated"); @@ -548,13 +549,13 @@ public: TestHeader("Read/Write Test"); FastOS_File::MakeDirectory("generated"); - FastOS_File *myFile = new FastOS_File(rwFilename); + FastOS_File *myFile = new FastOS_File(rwFilename.c_str()); if (myFile->OpenExisting()) { - Progress(false, "OpenExisting() should not work when '%s' does not exist.", rwFilename); + Progress(false, "OpenExisting() should not work when '%s' does not exist.", rwFilename.c_str()); myFile->Close(); } else { - Progress(true, "OpenExisting() should fail when '%s' does not exist, and it did.", rwFilename); + Progress(true, "OpenExisting() should fail when '%s' does not exist, and it did.", rwFilename.c_str()); } if (myFile->OpenReadWrite()) { @@ -628,10 +629,10 @@ public: bool closeResult = myFile->Close(); Progress(closeResult, "Close file."); } else { - Progress(false, "Unable to open file '%s'.", rwFilename); + Progress(false, "Unable to open file '%s'.", rwFilename.c_str()); } bool deleteResult = myFile->Delete(); - Progress(deleteResult, "Delete file '%s'.", rwFilename); + Progress(deleteResult, "Delete file '%s'.", rwFilename.c_str()); delete(myFile); FastOS_File::EmptyAndRemoveDirectory("generated"); @@ -661,7 +662,7 @@ public: { TestHeader("ReadBuf Test"); - FastOS_File file(roFilename); + FastOS_File file(roFilename.c_str()); char buffer[20]; @@ -691,7 +692,7 @@ public: { TestHeader("DiskFreeSpace Test"); - int64_t freeSpace = FastOS_File::GetFreeDiskSpace(roFilename); + int64_t freeSpace = FastOS_File::GetFreeDiskSpace(roFilename.c_str()); ProgressI64(freeSpace != -1, "DiskFreeSpace using file ('hello.txt'): %ld MB.", freeSpace == -1 ? -1 : freeSpace/(1024*1024)); freeSpace = FastOS_File::GetFreeDiskSpace("."); ProgressI64(freeSpace != -1, "DiskFreeSpace using dir (.): %ld MB.", freeSpace == -1 ? -1 : freeSpace/(1024*1024)); @@ -817,11 +818,6 @@ public: } }; -const char *FileTest::roFilename = "hello.txt"; -const char *FileTest::woFilename = "generated/writeonlytest.txt"; -const char *FileTest::rwFilename = "generated/readwritetest.txt"; - - int main (int argc, char **argv) { FileTest app; |