blob: bef4a24eeb9b5dbe97abcc6d104c87d81b05737d [file] [log] [blame]
E. Scott Daniels8dd46412019-04-16 20:47:54 +00001// :vi sw=4 ts=4 noet:
2/*
3==================================================================================
4 Copyright (c) 2019 Nokia
5 Copyright (c) 2018-2019 AT&T Intellectual Property.
6
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
10
E. Scott Daniels8790bf02019-04-23 12:59:28 +000011 http://www.apache.org/licenses/LICENSE-2.0
E. Scott Daniels8dd46412019-04-16 20:47:54 +000012
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==================================================================================
19*/
20
21/*
22 Mmemonic: rmr_nng_test.c
23 Abstract: This tests the whole rmr nng implementation. This driver
24 includes all of the module specific unit test static files
25 (e.g. wormhole_static_test.c) and drives the tests contained
26 there. The individual modules allow them to be driven by
27 a standalone driver, and to be maintained separately. We must
28 test by inclusion because of the static nature of the internal
29 functions of the library.
30
31 Author: E. Scott Daniels
32 Date: 18 January 2018 (IMO HRTL)
33*/
34
35#include <stdio.h>
36#include <stdlib.h>
37#include <netdb.h>
38#include <errno.h>
39#include <string.h>
40#include <errno.h>
41#include <pthread.h>
42#include <ctype.h>
43
44
45#include <unistd.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <strings.h>
49#include <errno.h>
50#include <string.h>
51#include <stdint.h>
52#include <ctype.h>
53#include <sys/epoll.h>
E. Scott Daniels412d53d2019-05-20 20:00:52 +000054#include <pthread.h>
55#include <semaphore.h>
E. Scott Daniels8dd46412019-04-16 20:47:54 +000056
57#define DEBUG 1
58
59#include <nng/nng.h>
60#include <nng/protocol/pubsub0/pub.h>
61#include <nng/protocol/pubsub0/sub.h>
62#include <nng/protocol/pipeline0/push.h>
63#include <nng/protocol/pipeline0/pull.h>
64
E. Scott Danielsfc5c77b2020-02-21 13:24:29 -050065#define NNG_UNDER_TEST 1
E. Scott Daniels8dd46412019-04-16 20:47:54 +000066#define EMULATE_NNG
67#include "test_nng_em.c" // nng/nn emulation (before including things under test)
68
69
E. Scott Daniels412d53d2019-05-20 20:00:52 +000070#include "rmr.h" // things the users see
71#include "rmr_symtab.h"
E. Scott Daniels0d4def62020-01-28 16:50:27 -050072#include "rmr_logging.h"
E. Scott Daniels412d53d2019-05-20 20:00:52 +000073#include "rmr_agnostic.h" // transport agnostic header
E. Scott Daniels8dd46412019-04-16 20:47:54 +000074
E. Scott Daniels412d53d2019-05-20 20:00:52 +000075#include "symtab.c"
E. Scott Daniels0d4def62020-01-28 16:50:27 -050076#include "logging.c"
E. Scott Daniels412d53d2019-05-20 20:00:52 +000077#include "rmr_nng.c"
78#include "mbuf_api.c"
E. Scott Daniels8dd46412019-04-16 20:47:54 +000079
80static void gen_rt( uta_ctx_t* ctx ); // defined in sr_nng_static_test, but used by a few others (eliminate order requirement below)
81
82 // specific test tools in this directory
83#include "test_support.c" // things like fail_if()
E. Scott Danielsfc5c77b2020-02-21 13:24:29 -050084#include "test_ctx_support.c" // specifically geared to creating dummy contex structs
E. Scott Daniels0b79fc22019-12-04 15:20:16 -050085#include "test_gen_rt.c"
E. Scott Daniels8dd46412019-04-16 20:47:54 +000086 // and finally....
87#include "tools_static_test.c" // local test functions pulled directly because of static nature of things
88#include "symtab_static_test.c"
89#include "ring_static_test.c"
90#include "rt_static_test.c"
91#include "sr_nng_static_test.c"
92#include "wormhole_static_test.c"
93#include "rmr_nng_api_static_test.c"
E. Scott Danielsd7109572019-04-18 14:01:16 +000094#include "mbuf_api_static_test.c"
E. Scott Daniels8dd46412019-04-16 20:47:54 +000095
96
97/*
98 Drive each of the separate tests and report.
99*/
100int main() {
101 int errors = 0;
102
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400103 fprintf( stderr, "\n<INFO> starting tool tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000104 errors += tools_test();
105 fprintf( stderr, "<INFO> error count: %d\n", errors );
106
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400107 fprintf( stderr, "\n<INFO> starting ring tests (%d)\n", errors );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000108 errors += ring_test();
109 fprintf( stderr, "<INFO> error count: %d\n", errors );
110
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400111 fprintf( stderr, "\n<INFO> starting symtab tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000112 errors += symtab_test( );
113 fprintf( stderr, "<INFO> error count: %d\n", errors );
114
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400115 fprintf( stderr, "\n<INFO> starting rtable tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000116 errors += rt_test(); // route table tests
117 fprintf( stderr, "<INFO> error count: %d\n", errors );
118
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400119 fprintf( stderr, "\n<INFO> starting RMr API tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000120 errors += rmr_api_test();
E. Scott Daniels68d09fa2019-06-03 19:45:12 +0000121
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400122 fprintf( stderr, "\n<INFO> run RMr API tests with src name only env var set\n" );
E. Scott Daniels68d09fa2019-06-03 19:45:12 +0000123 setenv( "RMR_SRC_NAMEONLY", "1", 1 );
124 errors += rmr_api_test();
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000125 fprintf( stderr, "<INFO> error count: %d\n", errors );
126
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400127 fprintf( stderr, "\n<INFO> starting wormhole tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000128 errors += worm_test(); // test wormhole funcitons
129 fprintf( stderr, "<INFO> error count: %d\n", errors );
130
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400131 fprintf( stderr, "\n<INFO> starting send/receive tests\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000132 errors += sr_nng_test(); // test the send/receive static functions
133 fprintf( stderr, "<INFO> error count: %d\n", errors );
134
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400135 fprintf( stderr, "\n<INFO> starting mbuf api tests\n" );
E. Scott Danielsd7109572019-04-18 14:01:16 +0000136 errors += mbuf_api_test( );
137 fprintf( stderr, "<INFO> error count: %d\n", errors );
138
E. Scott Daniels77526eb2020-09-17 16:39:31 -0400139 test_summary( errors, "tool tests" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000140 if( errors == 0 ) {
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400141 fprintf( stderr, "<PASS> all tests were OK\n\n" );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000142 } else {
E. Scott Daniels6511ac72019-08-27 10:17:21 -0400143 fprintf( stderr, "<FAIL> %d modules reported errors\n\n", errors );
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000144 }
145
146 return !!errors;
147}