aboutsummaryrefslogtreecommitdiff
path: root/src/timelineDecoder/tests
diff options
context:
space:
mode:
authorJan Eilers <jan.eilers@arm.com>2020-07-01 15:37:50 +0100
committerColm Donelan <colm.donelan@arm.com>2020-07-01 16:06:22 +0000
commit1f2494456b64cb50009c279cac34ee17286ed4ed (patch)
tree741c6b2141e05a040f379f548bebdf1f4f41d2b1 /src/timelineDecoder/tests
parent526647333571169076f5e72c9fb18c71025bf7c0 (diff)
downloadarmnn-1f2494456b64cb50009c279cac34ee17286ed4ed.tar.gz
Refactor: Remove need of OutgoingCaptureFile in JSONTimelineDecoder
* moves ownership of the output file to caller of TimelineDecoder * by using ostream the output can be printed to std::cout or any other file stream * updated unit test accordingly Signed-off-by: Jan Eilers <jan.eilers@arm.com> Change-Id: Iaa8994e9997c674c1a026a65fcbd1ab8e3832d3e
Diffstat (limited to 'src/timelineDecoder/tests')
-rw-r--r--src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
index 82414192f2..3961f9bfb5 100644
--- a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
+++ b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2020 Arm Ltd. All rights reserved.
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -795,14 +795,23 @@ BOOST_AUTO_TEST_CASE(JSONTimelineDecoderTestJSON)
BOOST_CHECK(jsonString.find("normalization_2: {")!=std::string::npos);
BOOST_CHECK(jsonString.find("output_4: {")!=std::string::npos);
- timelineDecoder.PrintJSON(rootEntity);
+ // Create a temporary file to write Json output to
+ fs::path tempFile = armnnUtils::Filesystem::NamedTempFile("JSONTimelineDecoderTestJSON.json");
+ // open temp file
+ std::ofstream ofs{tempFile};
+ // tell the timeline decoder to print into our temp file (you could also use std::cout)
+ timelineDecoder.PrintJSON(rootEntity, ofs);
+ // close temp file
+ ofs.close();
+ // Now everything in opposite order
fs::ifstream inFile;
- fs::path p{fs::temp_directory_path() / "output.json"};
- inFile.open(p); //open the input file
+ //reopen the file this time for reading
+ inFile.open(tempFile);
std::stringstream strStream;
strStream << inFile.rdbuf(); //read the file
+ inFile.close();
std::string outfileJson = strStream.str();
BOOST_CHECK(outfileJson != "");
@@ -811,5 +820,8 @@ BOOST_AUTO_TEST_CASE(JSONTimelineDecoderTestJSON)
"\t\t\tbackendId :CpuRef,")!=std::string::npos);
BOOST_CHECK(outfileJson.find("normalization_2: {")!=std::string::npos);
BOOST_CHECK(outfileJson.find("output_4: {")!=std::string::npos);
+
+ // Remove temporary file
+ fs::remove(tempFile);
}
BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file