X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=test%2Fapp_test%2Fv_sender.c;h=a597d03591c214c7bbe0d8e0bc6069731a53578b;hb=77406e61f2158f5b88b7a9f6e3e86d8f62c8f71a;hp=3d53204d56802fbf6054a46edb767b2aaf59e89c;hpb=d9de79acd9c205dc4f795e90a98331628ed6c85b;p=ric-plt%2Flib%2Frmr.git diff --git a/test/app_test/v_sender.c b/test/app_test/v_sender.c index 3d53204..a597d03 100644 --- a/test/app_test/v_sender.c +++ b/test/app_test/v_sender.c @@ -182,13 +182,14 @@ 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; // reset on first good message out + } 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 - } - if( fail_count > 10 ) { - fprintf( stderr, "too many failures\n" ); + fail_count++; // count failures after first successful message + if( ! successful && fail_count > 10 ) { + fprintf( stderr, "[FAIL] too many send failures\n" ); exit( 1 ); } } @@ -201,6 +202,12 @@ int main( int argc, char** argv ) { default: if( successful ) { fail_count++; // count failures after first successful message + } else { + fail_count++; + if( fail_count > 10 ) { + fprintf( stderr, " giving up\n" ); + exit( 1 ); + } } // some error (not connected likely), don't count this //sleep( 1 ); @@ -221,11 +228,13 @@ int main( int argc, char** argv ) { errno = 0; rbuf = rmr_rcv_msg( mrc, rbuf ); if( rbuf && rbuf->state == RMR_OK ) { - if( rmr_payload_size( rbuf ) > HDR_SIZE+DATA_SIZE ) { // verify that response has a larger payload than we should have sent + if( rmr_payload_size( rbuf ) >= HDR_SIZE+DATA_SIZE ) { // vet message rts_ok += validate_msg( rbuf->payload, rbuf->len ); } else { + fprintf( stderr, " received short response: >%d expected, got %d\n", HDR_SIZE+DATA_SIZE, rmr_payload_size( rbuf ) ); short_count++; } + rcvd_count++; } } @@ -243,7 +252,7 @@ int main( int argc, char** argv ) { } } - timeout = time( NULL ) + 2; // allow 2 seconds for the pipe to drain from the receiver + 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 ) { @@ -252,18 +261,19 @@ int main( int argc, char** argv ) { rbuf = rmr_rcv_msg( mrc, rbuf ); if( rbuf && rbuf->state == RMR_OK ) { rcvd_count++; - if( rmr_payload_size( rbuf ) > HDR_SIZE+DATA_SIZE ) { // verify that response has a larger payload than we should have sent + if( rmr_payload_size( rbuf ) >= HDR_SIZE+DATA_SIZE ) { // vet message rts_ok += validate_msg( rbuf->payload, rbuf->len ); } - timeout = time( NULL ) + 2; + timeout = time( NULL ) + 10; } } } } } - if( rcvd_count != rts_ok || count != nmsgs ) { // we might not receive all back if receiver didn't retry, so that is NOT a failure here + if( (rcvd_count != rts_ok) || (count != nmsgs) ) { // we might not receive all back if receiver didn't retry, so that is NOT a failure here + fprintf( stderr, " recvd=%d rts_ok=%d short=%d count=%d nmsg=%d\n", rcvd_count, rts_ok, short_count, count, nmsgs ); pass = 0; }