55 */
66
77#include < string.h>
8+ #include " Common/Cpp/Exceptions.h"
89#include " Common/PABotBase2/PABotBase2_ConnectionDebug.h"
910#include " MockDevice.h"
1011
1314using std::cout;
1415using std::endl;
1516
16- #if 0
17+ #if 1
1718#define PABB2_DROP_HOST_TO_DEVICE 0.2
1819#define PABB2_DROP_DEVICE_TO_HOST 0.2
1920#else
@@ -158,10 +159,17 @@ size_t MockDevice::verify_stream_data(){
158159 actual.data (), bytes
159160 );
160161
162+ if (read == 0 ){
163+ return bytes;
164+ }
165+
166+
167+ #if 0
161168 {
162169 std::lock_guard<Mutex> lg1(m_print_lock);
163170 cout << "read = " << read << endl;
164171 }
172+ #endif
165173
166174
167175 std::vector<uint8_t > expected (
@@ -178,17 +186,20 @@ size_t MockDevice::verify_stream_data(){
178186
179187 std::lock_guard<Mutex> lg1 (m_print_lock);
180188 if (matched){
189+ #if 0
181190 cout << "Matched: Bytes = " << read
182191 << ", Remaining = " << m_expected_host_to_device_stream.size()
183192 << ", Matched = "
184193 << std::string((const char*)actual.data(), read)
185194 << endl;
195+ #endif
186196 }else {
187197 cout << " MISMATCH: Expected = "
188198 << std::string ((const char *)expected.data (), read)
189199 << " , Actual = "
190200 << std::string ((const char *)actual.data (), read)
191201 << endl;
202+ throw InternalProgramError (nullptr , PA_CURRENT_FUNCTION , " Mismatch" );
192203 }
193204 return m_expected_host_to_device_stream.size ();
194205}
@@ -200,7 +211,7 @@ void MockDevice::device_thread(){
200211 std::unique_lock<Mutex> lg (m_device_lock);
201212 while (!m_stopping.load (std::memory_order_relaxed)){
202213 pabb2_ReliableStreamConnection_run_events (&m_connection);
203- m_device_cv.wait (lg);
214+ m_device_cv.wait_for (lg, Milliseconds ( 10 ) );
204215 }
205216}
206217void MockDevice::host_recv_thread (){
0 commit comments