1 // : vi ts=4 sw=4 noet :
3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
22 Mmemonic: rmr_si_lgb_static_test.c
23 Abstract: These are specific tests to exercise the ability to receive
24 a buffer larger than what was specified as the normal max
27 Author: E. Scott Daniels
39 #include <semaphore.h>
42 #include "rmr_agnostic.h"
44 static int rmr_lgbuf_test( ) {
46 void* rmc; // route manager context
47 rmr_mbuf_t* msg; // message buffers
49 if( (rmc = rmr_init( "4560", 128, FL_NOTHREAD )) == NULL ) { // use a short "normal max" value
50 fail_if_nil( rmc, "rmr_init returned a nil pointer when trying to initialise a short normal max" );
54 gen_rt( rmc ); // dummy route table so the send works
55 msg = rmr_alloc_msg( rmc, 4024 ); // payload size, and the msg len must be larger than 128
59 snprintf( msg->payload, msg->len, "Rambling Wreck from Georgia Tech!\n\n" );
60 msg = rmr_send_msg( rmc, msg );
61 if( msg && msg->state != RMR_OK ) {
62 printf( stderr, "[ERR] lg buf test: send failed? %d\n", msg->state );
66 msg = rmr_torcv_msg( rmc, NULL, 2000 );
67 errors += fail_if( msg == NULL, "rmr_rcv_msg returned nil msg when given nil msg " );
69 errors += fail_not_equal( msg->state, RMR_OK, "receive given nil message did not return msg with good state" );
71 errors += fail_if_false( msg->len > 128, "expected larger message than the small buffer" );