X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fapp_test%2Fsender.c;h=51429b551811ceaa922d6174d3a8f55380f34d5c;hb=refs%2Fchanges%2F33%2F1933%2F1;hp=015b943ffafaf34cf7bf7f0fa76ffbdcd9ad9e59;hpb=f7d44570f8de6e15f768e8e2d9b6061cd0bff11f;p=ric-plt%2Flib%2Frmr.git diff --git a/test/app_test/sender.c b/test/app_test/sender.c index 015b943..51429b5 100644 --- a/test/app_test/sender.c +++ b/test/app_test/sender.c @@ -214,10 +214,15 @@ int main( int argc, char** argv ) { sbuf = rmr_send_msg( mrc, sbuf ); // retry send until it's good (simple test; real programmes should do better) } if( sbuf->state == RMR_OK ) { + if( successful == 0 ) { + fail_count = 0; // count only after first message goes through + } successful = 1; // indicates only that we sent one successful message, not the current state } else { - if( successful ) { - fail_count++; // count failures after first successful message + fail_count++; // count failures after first successful message + if( !successful && fail_count > 30 ) { + fprintf( stderr, "[FAIL] too many send errors for this test\n" ); + exit( 1 ); } } break; @@ -273,8 +278,9 @@ int main( int argc, char** argv ) { } } - timeout = time( NULL ) + 2; // allow 2 seconds for the pipe to drain from the receiver - while( time( NULL ) < timeout ); + fprintf( stderr, " draining begins\n" ); + timeout = time( NULL ) + 20; // allow 20 seconds for the pipe to drain from the receiver + while( time( NULL ) < timeout ) { if( rcv_fd >= 0 ) { while( (nready = epoll_wait( ep_fd, events, 1, 100 )) > 0 ) { // if something ready to receive (non-blocking check) if( events[0].data.fd == rcv_fd ) { // we only are waiting on 1 thing, so [0] is ok @@ -283,7 +289,7 @@ int main( int argc, char** argv ) { if( rbuf ) { rcvd_count++; rts_ok += vet_received( me, rbuf->payload ); - timeout = time( NULL ) + 2; + timeout = time( NULL ) + 10; // break 10s after last received message } } } @@ -295,6 +301,8 @@ int main( int argc, char** argv ) { } } } + } + fprintf( stderr, " draining finishes\n" ); if( rcvd_count != rts_ok || count != nmsgs ) { pass = 0;