aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/test/SendCounterPacketTests.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-03 11:21:18 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-10-03 11:53:34 +0100
commit61d6f7305b02e025ee10aa07e5499993a0e77cc1 (patch)
tree896078c3400939c6eb85fdd6e8d35eb6e66d3fab /src/profiling/test/SendCounterPacketTests.cpp
parent342a8ba08a67fcbc6f179c32118ca2035002698d (diff)
downloadarmnn-61d6f7305b02e025ee10aa07e5499993a0e77cc1.tar.gz
IVGCVSW-3440 Fix intermittently failing send thread test
* Simplified the implementation of the MockStreamCounterBuffer * Minor refactoring Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I3aed97daee0ac32d384e1f830e8cc57aae84950b
Diffstat (limited to 'src/profiling/test/SendCounterPacketTests.cpp')
-rw-r--r--src/profiling/test/SendCounterPacketTests.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/profiling/test/SendCounterPacketTests.cpp b/src/profiling/test/SendCounterPacketTests.cpp
index 96596066c1..ba1d470a50 100644
--- a/src/profiling/test/SendCounterPacketTests.cpp
+++ b/src/profiling/test/SendCounterPacketTests.cpp
@@ -1694,7 +1694,7 @@ BOOST_AUTO_TEST_CASE(SendCounterDirectoryPacketTest7)
BOOST_AUTO_TEST_CASE(SendThreadTest0)
{
MockProfilingConnection mockProfilingConnection;
- MockStreamCounterBuffer mockStreamCounterBuffer(1, 0);
+ MockStreamCounterBuffer mockStreamCounterBuffer(0);
SendCounterPacket sendCounterPacket(mockProfilingConnection, mockStreamCounterBuffer);
// Try to start the send thread many times, it must only start once
@@ -1718,7 +1718,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest1)
unsigned int totalWrittenSize = 0;
MockProfilingConnection mockProfilingConnection;
- MockStreamCounterBuffer mockStreamCounterBuffer(5,1024);
+ MockStreamCounterBuffer mockStreamCounterBuffer(1024);
SendCounterPacket sendCounterPacket(mockProfilingConnection, mockStreamCounterBuffer);
sendCounterPacket.Start();
@@ -1732,8 +1732,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest1)
// Get the size of the Stream Metadata Packet
std::string processName = GetProcessName().substr(0, 60);
- unsigned int processNameSize = boost::numeric_cast<unsigned int>(processName.size()) > 0 ?
- boost::numeric_cast<unsigned int>(processName.size()) + 1 : 0;
+ unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<unsigned int>(processName.size()) + 1;
unsigned int streamMetadataPacketsize = 118 + processNameSize;
totalWrittenSize += streamMetadataPacketsize;
@@ -1811,15 +1810,15 @@ BOOST_AUTO_TEST_CASE(SendThreadTest1)
sendCounterPacket.SetReadyToRead();
- // To test an exact value of the "read size" in the mock buffer, wait a second to allow the send thread to
+ // To test an exact value of the "read size" in the mock buffer, wait two seconds to allow the send thread to
// read all what's remaining in the buffer
std::this_thread::sleep_for(std::chrono::seconds(2));
sendCounterPacket.Stop();
- BOOST_CHECK(mockStreamCounterBuffer.GetReadableBufferSize() == totalWrittenSize);
BOOST_CHECK(mockStreamCounterBuffer.GetCommittedSize() == totalWrittenSize);
- BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() == totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadableSize() == totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() == totalWrittenSize);
}
BOOST_AUTO_TEST_CASE(SendThreadTest2)
@@ -1827,7 +1826,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest2)
unsigned int totalWrittenSize = 0;
MockProfilingConnection mockProfilingConnection;
- MockStreamCounterBuffer mockStreamCounterBuffer(5, 1024);
+ MockStreamCounterBuffer mockStreamCounterBuffer(1024);
SendCounterPacket sendCounterPacket(mockProfilingConnection, mockStreamCounterBuffer);
sendCounterPacket.Start();
@@ -1843,8 +1842,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest2)
// Get the size of the Stream Metadata Packet
std::string processName = GetProcessName().substr(0, 60);
- unsigned int processNameSize = boost::numeric_cast<unsigned int>(processName.size()) > 0 ?
- boost::numeric_cast<unsigned int>(processName.size()) + 1 : 0;
+ unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<unsigned int>(processName.size()) + 1;
unsigned int streamMetadataPacketsize = 118 + processNameSize;
totalWrittenSize += streamMetadataPacketsize;
@@ -1932,15 +1930,15 @@ BOOST_AUTO_TEST_CASE(SendThreadTest2)
sendCounterPacket.SetReadyToRead();
- // To test an exact value of the "read size" in the mock buffer, wait a second to allow the send thread to
+ // To test an exact value of the "read size" in the mock buffer, wait two seconds to allow the send thread to
// read all what's remaining in the buffer
std::this_thread::sleep_for(std::chrono::seconds(2));
sendCounterPacket.Stop();
- BOOST_CHECK(mockStreamCounterBuffer.GetReadableBufferSize() == totalWrittenSize);
BOOST_CHECK(mockStreamCounterBuffer.GetCommittedSize() == totalWrittenSize);
- BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() == totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadableSize() == totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() == totalWrittenSize);
}
BOOST_AUTO_TEST_CASE(SendThreadTest3)
@@ -1948,7 +1946,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest3)
unsigned int totalWrittenSize = 0;
MockProfilingConnection mockProfilingConnection;
- MockStreamCounterBuffer mockStreamCounterBuffer(10, 1024);
+ MockStreamCounterBuffer mockStreamCounterBuffer(1024);
SendCounterPacket sendCounterPacket(mockProfilingConnection, mockStreamCounterBuffer);
sendCounterPacket.Start();
@@ -1961,8 +1959,7 @@ BOOST_AUTO_TEST_CASE(SendThreadTest3)
// Get the size of the Stream Metadata Packet
std::string processName = GetProcessName().substr(0, 60);
- unsigned int processNameSize = boost::numeric_cast<unsigned int>(processName.size()) > 0 ?
- boost::numeric_cast<unsigned int>(processName.size()) + 1 : 0;
+ unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<unsigned int>(processName.size()) + 1;
unsigned int streamMetadataPacketsize = 118 + processNameSize;
totalWrittenSize += streamMetadataPacketsize;
@@ -2040,10 +2037,11 @@ BOOST_AUTO_TEST_CASE(SendThreadTest3)
// thread is not guaranteed to flush the buffer)
sendCounterPacket.Stop();
- BOOST_CHECK(mockStreamCounterBuffer.GetReadableBufferSize() <= totalWrittenSize);
- BOOST_CHECK(mockStreamCounterBuffer.GetCommittedSize() <= totalWrittenSize);
- BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() <= totalWrittenSize);
- BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() <= mockStreamCounterBuffer.GetCommittedSize());
+ BOOST_CHECK(mockStreamCounterBuffer.GetCommittedSize() == totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadableSize() <= totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() <= totalWrittenSize);
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() <= mockStreamCounterBuffer.GetReadableSize());
+ BOOST_CHECK(mockStreamCounterBuffer.GetReadSize() <= mockStreamCounterBuffer.GetCommittedSize());
}
BOOST_AUTO_TEST_SUITE_END()