diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-07-29 12:06:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-29 12:06:39 +0300 |
commit | c316eb5b2b3a25aaab6e9ef5e4850e9bb72ba635 (patch) | |
tree | 4b31b52d41337503826a7bda0cc0c18008799c55 /indra/llfilesystem/tests/lldir_test.cpp | |
parent | a9e1d0c781ffdddd5e04d48af604fcb014325b4c (diff) | |
parent | 42885c0d23d8efc47ad77e09bb327e4ec6a4fada (diff) |
Merge pull request #2133 from Nicky-D/feature/linux_tests
Add ability to compile and run tests on Linux
Diffstat (limited to 'indra/llfilesystem/tests/lldir_test.cpp')
-rw-r--r-- | indra/llfilesystem/tests/lldir_test.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp index 6e191ad096..15f2c0005d 100644 --- a/indra/llfilesystem/tests/lldir_test.cpp +++ b/indra/llfilesystem/tests/lldir_test.cpp @@ -27,12 +27,14 @@ #include "linden_common.h" +#include <filesystem> #include "llstring.h" #include "tests/StringVec.h" #include "../lldir.h" #include "../lldiriterator.h" #include "../test/lltut.h" +#include "../test/namedtempfile.h" #include "stringize.h" #include <boost/assign/list_of.hpp> @@ -425,23 +427,19 @@ namespace tut return path; } - std::string makeTestDir( const std::string& dirbase ) + std::string makeTestDir( ) { - int counter; - std::string uniqueDir; - bool foundUnused; - std::string delim = gDirUtilp->getDirDelimiter(); + auto p = NamedTempFile::temp_path(); + std::filesystem::create_directories(p.native()); - for (counter=0, foundUnused=false; !foundUnused; counter++ ) - { - char counterStr[3]; - sprintf(counterStr, "%02d", counter); - uniqueDir = dirbase + counterStr; - foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) ); - } - ensure("test directory '" + uniqueDir + "' creation failed", !LLFile::mkdir(uniqueDir)); + auto ret { p.native() }; - return uniqueDir + delim; // HACK - apparently, the trailing delimiter is needed... + // There's an implicit assumtion all over this code that the returned path ends with "/" (or "\") + + if(ret.size() >= 1 && ret[ ret.size()-1 ] != std::filesystem::path::preferred_separator ) + ret += std::filesystem::path::preferred_separator; + + return ret; } static const char* DirScanFilename[5] = { "file1.abc", "file2.abc", "file1.xyz", "file2.xyz", "file1.mno" }; @@ -497,8 +495,9 @@ namespace tut // Create the same 5 file names of the two directories - std::string dir1 = makeTestDir(dirTemp + "LLDirIterator"); - std::string dir2 = makeTestDir(dirTemp + "LLDirIterator"); + std::string dir1 = makeTestDir(); + std::string dir2 = makeTestDir(); + std::string dir1files[5]; std::string dir2files[5]; for (int i=0; i<5; i++) |