IVGCVSW-4728 Attempt to fix test failures
authorÉanna Ó Catháin <eanna.ocathain@arm.com>
Mon, 27 Apr 2020 11:54:11 +0000 (12:54 +0100)
committerÉanna Ó Catháin <eanna.ocathain@arm.com>
Mon, 27 Apr 2020 11:54:32 +0000 (12:54 +0100)
Change-Id: I0e0d4a8338c7df4f09518d9f84605b3cc002f2b0
Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
src/timelineDecoder/JSONTimelineDecoder.cpp
src/timelineDecoder/JSONTimelineDecoder.hpp
src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp

index 520995a..84472d8 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <string>
 #include <fstream>
+#include <boost/filesystem/fstream.hpp>
 
 namespace armnn
 {
@@ -245,9 +246,9 @@ void JSONTimelineDecoder::JSONEntity::SetParent(JSONEntity& parent)
 void JSONTimelineDecoder::PrintJSON(JSONTimelineDecoder::JSONEntity& rootEntity)
 {
     std::string jsonString = GetJSONString(rootEntity);
-    std::ofstream outfile;
-    outfile.open(this->outputJSONFile);
-    outfile << jsonString;
+    boost::filesystem::ofstream ofs{this->outputJSONFile};
+    ofs << jsonString;
+    ofs.close();
 }
 
 std::string JSONTimelineDecoder::GetJSONString(JSONTimelineDecoder::JSONEntity& rootEntity)
index 17ee84b..c4e0855 100644 (file)
@@ -9,6 +9,8 @@
 
 #include <map>
 #include <vector>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem.hpp>
 
 namespace armnn
 {
@@ -63,7 +65,10 @@ public:
 
 private:
     Model m_Model;
-    std::string outputJSONFile = "/tmp/output.json";
+    boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
+    boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
+
+    std::string outputJSONFile = p.string();
 
     void HandleRetentionLink(const Relationship& relationship);
     void HandleLabelLink(const Relationship& relationship);
index 71e76b1..2d78564 100644 (file)
@@ -11,6 +11,7 @@
 #include <boost/test/unit_test_suite.hpp>
 
 #include <fstream>
+#include <boost/filesystem.hpp>
 
 BOOST_AUTO_TEST_SUITE(JSONTimelineDecoderTests)
 
@@ -796,8 +797,11 @@ BOOST_AUTO_TEST_CASE(JSONTimelineDecoderTestJSON)
 
     timelineDecoder.PrintJSON(rootEntity);
 
-    std::ifstream inFile;
-    inFile.open("/tmp/output.json"); //open the input file
+    boost::filesystem::ifstream inFile;
+    boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
+    boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
+
+    inFile.open(p); //open the input file
 
     std::stringstream strStream;
     strStream << inFile.rdbuf(); //read the file