diff options
author | Riccardo Spagni <ric@spagni.net> | 2017-04-11 00:20:57 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2017-04-11 00:20:57 +0200 |
commit | 6e9b659c0793438e87b05de8d0827a16b0815930 (patch) | |
tree | 9a497c359f2c8d7d46cb8e2f38e12ba12bfca298 | |
parent | Merge pull request #1940 (diff) | |
parent | Replace deprecated tmpnam function. (diff) | |
download | monero-6e9b659c0793438e87b05de8d0827a16b0815930.tar.xz |
Merge pull request #1944
933e08f2 Replace deprecated tmpnam function. (Randi Joseph)
-rw-r--r-- | tests/unit_tests/blockchain_db.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/unit_tests/blockchain_db.cpp b/tests/unit_tests/blockchain_db.cpp index 5e798e31c..5592106cb 100644 --- a/tests/unit_tests/blockchain_db.cpp +++ b/tests/unit_tests/blockchain_db.cpp @@ -242,27 +242,31 @@ TYPED_TEST_CASE(BlockchainDBTest, implementations); TYPED_TEST(BlockchainDBTest, OpenAndClose) { - std::string fname(tmpnam(NULL)); + boost::filesystem::path tempPath = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); + std::string dirPath = tempPath.string(); - this->set_prefix(fname); + this->set_prefix(dirPath); // make sure open does not throw - ASSERT_NO_THROW(this->m_db->open(fname)); + ASSERT_NO_THROW(this->m_db->open(dirPath)); this->get_filenames(); // make sure open when already open DOES throw - ASSERT_THROW(this->m_db->open(fname), DB_OPEN_FAILURE); + ASSERT_THROW(this->m_db->open(dirPath), DB_OPEN_FAILURE); ASSERT_NO_THROW(this->m_db->close()); } TYPED_TEST(BlockchainDBTest, AddBlock) { - std::string fname(tmpnam(NULL)); - this->set_prefix(fname); + + boost::filesystem::path tempPath = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); + std::string dirPath = tempPath.string(); + + this->set_prefix(dirPath); // make sure open does not throw - ASSERT_NO_THROW(this->m_db->open(fname)); + ASSERT_NO_THROW(this->m_db->open(dirPath)); this->get_filenames(); this->init_hard_fork(); @@ -302,11 +306,13 @@ TYPED_TEST(BlockchainDBTest, AddBlock) TYPED_TEST(BlockchainDBTest, RetrieveBlockData) { - std::string fname(tmpnam(NULL)); - this->set_prefix(fname); + boost::filesystem::path tempPath = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); + std::string dirPath = tempPath.string(); + + this->set_prefix(dirPath); // make sure open does not throw - ASSERT_NO_THROW(this->m_db->open(fname)); + ASSERT_NO_THROW(this->m_db->open(dirPath)); this->get_filenames(); this->init_hard_fork(); |