aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Bentham <matthew.bentham@arm.com>2019-03-20 12:46:58 +0000
committerMatthew Bentham <matthew.bentham@arm.com>2019-03-25 12:34:38 +0000
commit9fc8c0f0587d798b927ae4364e0b8a6db808c244 (patch)
tree0164d1ef056488afdbf11d94050fb9dfb0408be9
parentef38d5d0f071c53883e2b2f13c85bfb3df34bf88 (diff)
downloadarmnn-9fc8c0f0587d798b927ae4364e0b8a6db808c244.tar.gz
Use unique names for temporary files
Change-Id: I06653135c5fef38a52995da6c4b6de7ba5786b6a Signed-off-by: Matthew Bentham <matthew.bentham@arm.com>
-rw-r--r--src/armnn/test/CsvReaderTest.cpp32
-rw-r--r--src/armnnTfLiteParser/test/LoadModel.cpp5
2 files changed, 22 insertions, 15 deletions
diff --git a/src/armnn/test/CsvReaderTest.cpp b/src/armnn/test/CsvReaderTest.cpp
index 1fa7b93e2c..22d510bcb6 100644
--- a/src/armnn/test/CsvReaderTest.cpp
+++ b/src/armnn/test/CsvReaderTest.cpp
@@ -10,6 +10,7 @@
#include <iostream>
#include <string>
#include <boost/filesystem.hpp>
+#include <boost/optional.hpp>
using namespace armnnUtils;
@@ -28,8 +29,8 @@ struct TestHelper {
std::string CreateTempCsvFile()
{
- std::string fileDir = boost::filesystem::temp_directory_path().c_str();
- boost::filesystem::path p{fileDir + "/sampleFile.csv"};
+ boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
+ boost::filesystem::path p{fileDir / boost::filesystem::unique_path("%%%%-%%%%-%%%%.csv")};
try
{
boost::filesystem::ofstream ofs{p};
@@ -41,7 +42,9 @@ struct TestHelper {
std::cerr << "Unable to write to file at location [" << p.c_str() << "] : " << e.what() << std::endl;
BOOST_TEST(false);
}
- return fileDir + "/sampleFile.csv";
+
+ m_CsvFile = p;
+ return p.string();
}
int CheckStringsMatch(CsvRow &row, unsigned int index, std::string expectedValue)
@@ -56,18 +59,21 @@ struct TestHelper {
void RemoveCsvFile()
{
- std::string fileDir = boost::filesystem::temp_directory_path().c_str();
- std::string filePath = fileDir + "/sampleFile.csv";
- try
- {
- boost::filesystem::remove(filePath);
- }
- catch (std::exception &e)
+ if (m_CsvFile)
{
- std::cerr << "Unable to delete file [" << filePath << "] : " << e.what() << std::endl;
- BOOST_TEST(false);
+ try
+ {
+ boost::filesystem::remove(*m_CsvFile);
+ }
+ catch (std::exception &e)
+ {
+ std::cerr << "Unable to delete file [" << *m_CsvFile << "] : " << e.what() << std::endl;
+ BOOST_TEST(false);
+ }
}
}
+
+ boost::optional<boost::filesystem::path> m_CsvFile;
};
BOOST_AUTO_TEST_SUITE(CsvReaderTest)
@@ -121,4 +127,4 @@ BOOST_FIXTURE_TEST_CASE(TestLoadingFileFromDisk, TestHelper)
BOOST_CHECK(CheckStringsMatch(row2, 2, "ice") == 0);
}
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfLiteParser/test/LoadModel.cpp b/src/armnnTfLiteParser/test/LoadModel.cpp
index 2bb05ba15c..ea490106c4 100644
--- a/src/armnnTfLiteParser/test/LoadModel.cpp
+++ b/src/armnnTfLiteParser/test/LoadModel.cpp
@@ -198,7 +198,8 @@ BOOST_FIXTURE_TEST_CASE(LoadModelFromBinary, LoadModelFixture)
BOOST_FIXTURE_TEST_CASE(LoadModelFromFile, LoadModelFixture)
{
- std::string fname = boost::filesystem::temp_directory_path().string() + "/testtflite.tflite";
+ using namespace boost::filesystem;
+ std::string fname = unique_path(temp_directory_path() / "%%%%-%%%%-%%%%.tflite").string();
bool saved = flatbuffers::SaveFile(fname.c_str(),
reinterpret_cast<char *>(m_GraphBinary.data()),
m_GraphBinary.size(), true);
@@ -213,7 +214,7 @@ BOOST_FIXTURE_TEST_CASE(LoadModelFromFile, LoadModelFixture)
tflite::CustomOptionsFormat_FLEXBUFFERS);
CheckOperator(model->subgraphs[1]->operators[0], 1, { 0, 2 }, { 1 }, tflite::BuiltinOptions_Conv2DOptions,
tflite::CustomOptionsFormat_FLEXBUFFERS);
- remove(fname.c_str());
+ remove(fname);
}
BOOST_AUTO_TEST_CASE(LoadNullBinary)