// : vi ts=4 sw=4 noet :
/*
==================================================================================
- Copyright (c) 2019 Nokia
- Copyright (c) 2018-2019 AT&T Intellectual Property.
+ Copyright (c) 2019 Nokia
+ Copyright (c) 2018-2019 AT&T Intellectual Property.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Abstract: Specific tests related to the API functions in rmr_nng.c/rmr.c.
This should be included by a driver, but only the main RMr
driver and there likely not be a specific stand alone driver
- for just this small set of tests because of the depth of the
+ for just this small set of tests because of the depth of the
library needed to test at this level.
The message buffer specific API tests are in a different static
} else {
errors += fail_if( v < 0, "rmr_payload_size returned invalid size for good message" );
}
-
+
v = rmr_get_rcvfd( NULL );
errors += fail_if( v >= 0, "rmr_get_rcvfd returned a valid file descriptor when given nil context" );
v = rmr_get_rcvfd( rmc );
msg2 = rmr_send_msg( NULL, NULL ); // drive for coverage
errors += fail_not_nil( msg2, "send_msg returned msg pointer when given a nil message and context" );
+ msg->state = 0;
+ msg = rmr_send_msg( NULL, msg );
+ errors += fail_if( msg->state == 0, "rmr_send_msg did not set msg state when msg given with nil context" );
+
// --- sends will fail with a no endpoint error until a dummy route table is set, so we test fail case first.
msg->len = 100;
msg->mtype = 1;
rmr_rts_msg( rmc, NULL );
errors += fail_if( errno == 0, "rmr_rts_msg did not set errno when given a nil message" );
+ msg->state = 0;
+ msg = rmr_rts_msg( NULL, msg ); // should set state in msg
+ errors += fail_if_equal( msg->state, 0, "rmr_rts_msg did not set state when given valid message but no context" );
+
+
msg = rmr_rts_msg( rmc, msg ); // return the buffer to the sender
errors += fail_if_nil( msg, "rmr_rts_msg did not return a message pointer" );
errors += fail_if( errno != 0, "rmr_rts_msg did not reset errno" );
snprintf( msg->xaction, 17, "%015d", 16 ); // dummy transaction id (emulation generates, this should arrive after a few calls to recv)
+
+ msg->state = 0;
+ msg = rmr_call( NULL, msg );
+ errors += fail_if( msg->state == 0, "rmr_call did not set message state when given message with nil context" );
+
+ msg->mtype = 0;
msg = rmr_call( rmc, msg ); // this call should return a message as we can anticipate a dummy message in
errors += fail_if_nil( msg, "rmr_call returned a nil message on call expected to succeed" );
if( msg ) {
errors += fail_not_equal( msg->state, RMR_OK, "rmr_call did not properly set state on successful return" );
- errors += fail_if( errno != 0, "rmr_call did not properly set errno on successful return" );
+ errors += fail_not_equal( errno, 0, "rmr_call did not properly set errno (a) on successful return" );
}
snprintf( wbuf, 17, "%015d", 14 ); // if we call receive we should find this in the first 15 tries
}
errors += fail_if( i >= 16, "did not find expected message on queue" );
-
+
if( ! msg ) {
msg = rmr_alloc_msg( rmc, 2048 ); // something buggered above; get a new one
}
rmr_free_msg( msg2 );
+ msg2 = rmr_torcv_msg( NULL, NULL, 10 );
+ errors += fail_not_nil( msg2, "rmr_torcv_msg returned a pointer when given nil information" );
+ msg2 = rmr_torcv_msg( rmc, NULL, 10 );
+ errors += fail_if_nil( msg2, "rmr_torcv_msg did not return a message pointer when given a nil old msg" );
+
// --- test timeout receive; our dummy epoll function will return 1 ready on first call and 0 ready (timeout emulation) on second
// however we must drain the swamp (queue) first, so run until we get a timeout error, or 20 and report error if we get to 20.
msg = NULL;
errors += fail_not_equal( state, 17, "len of trace data (a) returned after msg allocation was not expected size (b)" );
state = strcmp( wbuf, "1904308620110417" );
errors += fail_not_equal( state, 0, "trace data returned after tralloc was not correct" );
-
+
em_send_failures = 1;
send_n_msgs( rmc, 30 ); // send 30 messages with emulation failures
em_send_failures = 0;
-
+
rmr_close( NULL ); // drive for coverage
rmr_close( rmc ); // no return to check; drive for coverage