Merge "Fix semaphore count bug in SI95 non-blocking rcv"
[ric-plt/lib/rmr.git] / test / rmr_nng_test.c
index 0b3068e..08758ad 100644 (file)
@@ -8,7 +8,7 @@
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
 
    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,
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
@@ -51,6 +51,8 @@
 #include <stdint.h>
 #include <ctype.h>
 #include <sys/epoll.h>
 #include <stdint.h>
 #include <ctype.h>
 #include <sys/epoll.h>
+#include <pthread.h>
+#include <semaphore.h>
 
 #define DEBUG 1
 
 
 #define DEBUG 1
 
 #include <nng/protocol/pipeline0/push.h>
 #include <nng/protocol/pipeline0/pull.h>
 
 #include <nng/protocol/pipeline0/push.h>
 #include <nng/protocol/pipeline0/pull.h>
 
+#define NNG_UNDER_TEST 1
 #define EMULATE_NNG
 #include "test_nng_em.c"                                                       // nng/nn emulation (before including things under test)
 
 
 #define EMULATE_NNG
 #include "test_nng_em.c"                                                       // nng/nn emulation (before including things under test)
 
 
-#include "../src/common/include/rmr.h"                                 // things the users see
-#include "../src/common/include/rmr_symtab.h"
-#include "../src/common/include/rmr_agnostic.h"                        // transport agnostic header
-#include "../src/nng/include/rmr_nng_private.h"                        // transport specific
+#include "rmr.h"                                       // things the users see
+#include "rmr_symtab.h"
+#include "rmr_logging.h"
+#include "rmr_agnostic.h"                      // transport agnostic header
 
 
-#include "../src/common/src/symtab.c"
-#include "../src/nng/src/rmr_nng.c"
-#include "../src/common/src/mbuf_api.c"
+#include "symtab.c"
+#include "logging.c"
+#include "rmr_nng.c"
+#include "mbuf_api.c"
 
 static void gen_rt( uta_ctx_t* ctx );          // defined in sr_nng_static_test, but used by a few others (eliminate order requirement below)
 
                                                                                        // specific test tools in this directory
 #include "test_support.c"                                      // things like fail_if()
 
 static void gen_rt( uta_ctx_t* ctx );          // defined in sr_nng_static_test, but used by a few others (eliminate order requirement below)
 
                                                                                        // specific test tools in this directory
 #include "test_support.c"                                      // things like fail_if()
+#include "test_ctx_support.c"                          // specifically geared to creating dummy contex structs
+#include "test_gen_rt.c"
                                                                                        // and finally....
 #include "tools_static_test.c"                         // local test functions pulled directly because of static nature of things
 #include "symtab_static_test.c"
                                                                                        // and finally....
 #include "tools_static_test.c"                         // local test functions pulled directly because of static nature of things
 #include "symtab_static_test.c"
@@ -94,42 +100,46 @@ static void gen_rt( uta_ctx_t* ctx );              // defined in sr_nng_static_test, but use
 int main() {
        int errors = 0;
 
 int main() {
        int errors = 0;
 
-       fprintf( stderr, "<INFO> starting tool tests\n" );
+       fprintf( stderr, "\n<INFO> starting tool tests\n" );
        errors += tools_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += tools_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting ring tests (%d)\n", errors );
+       fprintf( stderr, "\n<INFO> starting ring tests (%d)\n", errors );
        errors += ring_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += ring_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting symtab tests\n" );
+       fprintf( stderr, "\n<INFO> starting symtab tests\n" );
        errors += symtab_test( );
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += symtab_test( );
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting rtable tests\n" );
+       fprintf( stderr, "\n<INFO> starting rtable tests\n" );
        errors += rt_test();                            // route table tests
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += rt_test();                            // route table tests
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting RMr API tests\n" );
+       fprintf( stderr, "\n<INFO> starting RMr API tests\n" );
+       errors += rmr_api_test();
+
+       fprintf( stderr, "\n<INFO> run RMr API tests with src name only env var set\n" );
+       setenv( "RMR_SRC_NAMEONLY", "1", 1 );
        errors += rmr_api_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += rmr_api_test();
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting wormhole tests\n" );
+       fprintf( stderr, "\n<INFO> starting wormhole tests\n" );
        errors += worm_test();                          // test wormhole funcitons
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += worm_test();                          // test wormhole funcitons
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting send/receive tests\n" );
+       fprintf( stderr, "\n<INFO> starting send/receive tests\n" );
        errors += sr_nng_test();                                // test the send/receive static functions
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        errors += sr_nng_test();                                // test the send/receive static functions
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
-       fprintf( stderr, "<INFO> starting mbuf api tests\n" );
+       fprintf( stderr, "\n<INFO> starting mbuf api tests\n" );
        errors +=  mbuf_api_test( );
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        if( errors == 0 ) {
        errors +=  mbuf_api_test( );
        fprintf( stderr, "<INFO> error count: %d\n", errors );
 
        if( errors == 0 ) {
-               fprintf( stderr, "<PASS> all tests were OK\n" );
+               fprintf( stderr, "<PASS> all tests were OK\n\n" );
        } else {
        } else {
-               fprintf( stderr, "<FAIL> %d modules reported errors\n", errors );
+               fprintf( stderr, "<FAIL> %d modules reported errors\n\n", errors );
        }
 
        return !!errors;
        }
 
        return !!errors;