From c820b25c9c1ebe6012b383925644661c4bec396e Mon Sep 17 00:00:00 2001 From: "matej.gradicek" Date: Fri, 16 Jun 2017 07:34:46 +0000 Subject: [PATCH] Changed tmpnam with mkdtemp Reviewers: dgleich, buda Reviewed By: dgleich Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D431 --- tests/unit/dbms_recovery.cpp | 3 ++- tests/unit/recovery.cpp | 5 ++++- tests/unit/snapshot.cpp | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/unit/dbms_recovery.cpp b/tests/unit/dbms_recovery.cpp index b4daa7cde..145829ac2 100644 --- a/tests/unit/dbms_recovery.cpp +++ b/tests/unit/dbms_recovery.cpp @@ -11,7 +11,8 @@ DECLARE_int32(snapshot_cycle_sec); namespace fs = std::experimental::filesystem; -const fs::path SNAPSHOTS_DBMS_RECOVERY_ALL_DB = std::tmpnam(nullptr); +char tmp[] = "XXXXXX"; +const fs::path SNAPSHOTS_DBMS_RECOVERY_ALL_DB = mkdtemp(tmp); const fs::path SNAPSHOTS_DBMS_RECOVERY_DEFAULT_DB_DIR = SNAPSHOTS_DBMS_RECOVERY_ALL_DB / "default"; diff --git a/tests/unit/recovery.cpp b/tests/unit/recovery.cpp index f6b070b4e..6d4497093 100644 --- a/tests/unit/recovery.cpp +++ b/tests/unit/recovery.cpp @@ -14,7 +14,10 @@ DECLARE_int32(snapshot_cycle_sec); namespace fs = std::experimental::filesystem; -const fs::path SNAPSHOTS_RECOVERY_DEFAULT_DB_DIR = std::tmpnam(nullptr); +char tmp[] = "XXXXXX"; +const fs::path SNAPSHOTS_RECOVERY_ALL_DB_DIR = mkdtemp(tmp); +const fs::path SNAPSHOTS_RECOVERY_DEFAULT_DB_DIR = + SNAPSHOTS_RECOVERY_ALL_DB_DIR / "default"; std::vector GetFilesFromDir( const std::string &snapshots_default_db_dir) { diff --git a/tests/unit/snapshot.cpp b/tests/unit/snapshot.cpp index 5924e065e..eede9695f 100644 --- a/tests/unit/snapshot.cpp +++ b/tests/unit/snapshot.cpp @@ -12,13 +12,15 @@ DECLARE_string(snapshot_directory); namespace fs = std::experimental::filesystem; -const std::string SNAPSHOTS_FOLDER_ALL_DB = "snapshots_test"; -const std::string SNAPSHOTS_TEST_DEFAULT_DB_DIR = "snapshots_test/default"; +char tmp[] = "XXXXXX"; +const fs::path SNAPSHOTS_FOLDER_ALL_DB = mkdtemp(tmp); +const fs::path SNAPSHOTS_TEST_DEFAULT_DB_DIR = + SNAPSHOTS_FOLDER_ALL_DB / "default"; -// Other functionality will be tested in recovery tests. +// Other functionality is tested in recovery tests. std::vector GetFilesFromDir( - const std::string &snapshots_default_db_dir) { + const fs::path &snapshots_default_db_dir) { std::vector files; for (auto &file : fs::directory_iterator(snapshots_default_db_dir)) files.push_back(file.path());