IVGCVSW-4118 Fix long unit test execution

 * Reduced sleep_for timings
 * Removed duplicate SendStreamMetaDataPacket.
 * Modified SendCounterPacket::WaitForPacketSent to use wait_for
 * Modified SendCounterPacket::Send WaitingForAck to use wait_for
 * Added destructor to StreamRedirector.
 * Added method SendCounterPacketTests::HasWrittenData
 * Restructured many tests in ProfilingTests.

Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: I55c59cac6674ac40a1056a5302a997d5da9e9d91
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
diff --git a/src/profiling/SendCounterPacket.cpp b/src/profiling/SendCounterPacket.cpp
index 1ed926b..2d64583 100644
--- a/src/profiling/SendCounterPacket.cpp
+++ b/src/profiling/SendCounterPacket.cpp
@@ -1012,10 +1012,10 @@
                  // Flush the buffer manually to send the packet
                 FlushBuffer(profilingConnection);
 
-                // Wait indefinitely until notified otherwise (it could that the profiling state has changed due to the
-                // connection being acknowledged, or that new data is ready to be sent, or that the send thread is
-                // being shut down, etc.)
-                m_WaitCondition.wait(lock);
+                // Wait for a connection ack from the remote server. We should expect a response within timeout value.
+                // If not, drop back to the start of the loop and detect somebody closing the thread. Then send the
+                // StreamMetadata again.
+                m_WaitCondition.wait_for(lock, std::chrono::milliseconds(m_Timeout));
 
                 // Do not flush the buffer again
                 continue;