aboutsummaryrefslogtreecommitdiff
path: root/test/UtilsTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/UtilsTests.cpp')
-rw-r--r--test/UtilsTests.cpp55
1 files changed, 27 insertions, 28 deletions
diff --git a/test/UtilsTests.cpp b/test/UtilsTests.cpp
index 6ece4e26..5ab768a1 100644
--- a/test/UtilsTests.cpp
+++ b/test/UtilsTests.cpp
@@ -31,18 +31,20 @@ public:
// Setup: set the output dump directory and an empty dummy model (as only its memory address is used).
// Defaulting the output dump directory to "/data" because it should exist and be writable in all deployments.
ExportNetworkGraphFixture()
- : ExportNetworkGraphFixture("/data", 1)
+ : ExportNetworkGraphFixture("/data")
{}
- ExportNetworkGraphFixture(const std::string& requestInputsAndOutputsDumpDir, armnn::NetworkId networkId)
+ ExportNetworkGraphFixture(const std::string& requestInputsAndOutputsDumpDir)
: m_RequestInputsAndOutputsDumpDir(requestInputsAndOutputsDumpDir)
- , m_NetworkId(networkId)
, m_FileName()
, m_FileStream()
{
// Set the name of the output .dot file.
+ // NOTE: the export now uses a time stamp to name the file so we
+ // can't predict ahead of time what the file name will be.
+ std::string timestamp = "dummy";
m_FileName = boost::str(boost::format("%1%/%2%_networkgraph.dot")
% m_RequestInputsAndOutputsDumpDir
- % std::to_string(m_NetworkId));
+ % timestamp);
}
// Teardown: delete the dump file regardless of the outcome of the tests.
@@ -63,6 +65,11 @@ public:
m_FileStream.close();
}
+ if (m_FileName.empty())
+ {
+ return false;
+ }
+
// Open the file.
m_FileStream.open(m_FileName, std::ifstream::in);
@@ -90,10 +97,9 @@ public:
}
std::string m_RequestInputsAndOutputsDumpDir;
- armnn::NetworkId m_NetworkId;
+ std::string m_FileName;
private:
- std::string m_FileName;
std::ifstream m_FileStream;
};
@@ -127,7 +133,7 @@ private:
BOOST_AUTO_TEST_CASE(ExportToEmptyDirectory)
{
// Set the fixture for this test.
- ExportNetworkGraphFixture fixture("", 0);
+ ExportNetworkGraphFixture fixture("");
// Set a mock content for the optimized network.
std::string mockSerializedContent = "This is a mock serialized content.";
@@ -136,9 +142,8 @@ BOOST_AUTO_TEST_CASE(ExportToEmptyDirectory)
MockOptimizedNetwork mockOptimizedNetwork(mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture.m_RequestInputsAndOutputsDumpDir,
- 0);
+ fixture.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture.m_RequestInputsAndOutputsDumpDir);
// Check that the output file does not exist.
BOOST_TEST(!fixture.FileExists());
@@ -156,9 +161,8 @@ BOOST_AUTO_TEST_CASE(ExportNetwork)
MockOptimizedNetwork mockOptimizedNetwork(mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture.m_RequestInputsAndOutputsDumpDir,
- fixture.m_NetworkId);
+ fixture.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture.m_RequestInputsAndOutputsDumpDir);
// Check that the output file exists and that it has the correct name.
BOOST_TEST(fixture.FileExists());
@@ -179,9 +183,8 @@ BOOST_AUTO_TEST_CASE(ExportNetworkOverwriteFile)
MockOptimizedNetwork mockOptimizedNetwork(mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture.m_RequestInputsAndOutputsDumpDir,
- fixture.m_NetworkId);
+ fixture.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture.m_RequestInputsAndOutputsDumpDir);
// Check that the output file exists and that it has the correct name.
BOOST_TEST(fixture.FileExists());
@@ -194,9 +197,8 @@ BOOST_AUTO_TEST_CASE(ExportNetworkOverwriteFile)
mockOptimizedNetwork.UpdateMockSerializedContent(mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture.m_RequestInputsAndOutputsDumpDir,
- fixture.m_NetworkId);
+ fixture.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture.m_RequestInputsAndOutputsDumpDir);
// Check that the output file still exists and that it has the correct name.
BOOST_TEST(fixture.FileExists());
@@ -219,9 +221,8 @@ BOOST_AUTO_TEST_CASE(ExportMultipleNetworks)
MockOptimizedNetwork mockOptimizedNetwork(mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture1.m_RequestInputsAndOutputsDumpDir,
- fixture1.m_NetworkId);
+ fixture1.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture1.m_RequestInputsAndOutputsDumpDir);
// Check that the output file exists and that it has the correct name.
BOOST_TEST(fixture1.FileExists());
@@ -230,9 +231,8 @@ BOOST_AUTO_TEST_CASE(ExportMultipleNetworks)
BOOST_TEST(fixture1.GetFileContent() == mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture2.m_RequestInputsAndOutputsDumpDir,
- fixture2.m_NetworkId);
+ fixture2.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture2.m_RequestInputsAndOutputsDumpDir);
// Check that the output file exists and that it has the correct name.
BOOST_TEST(fixture2.FileExists());
@@ -241,9 +241,8 @@ BOOST_AUTO_TEST_CASE(ExportMultipleNetworks)
BOOST_TEST(fixture2.GetFileContent() == mockSerializedContent);
// Export the mock optimized network.
- armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
- fixture3.m_RequestInputsAndOutputsDumpDir,
- fixture3.m_NetworkId);
+ fixture3.m_FileName = armnn_driver::ExportNetworkGraphToDotFile(mockOptimizedNetwork,
+ fixture3.m_RequestInputsAndOutputsDumpDir);
// Check that the output file exists and that it has the correct name.
BOOST_TEST(fixture3.FileExists());