blob: 5dbeb2108f4492b1e4618a2987e3d394440551de [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>
54
55#define DEBUG 1
56
57#include <nng/nng.h>
58#include <nng/protocol/pubsub0/pub.h>
59#include <nng/protocol/pubsub0/sub.h>
60#include <nng/protocol/pipeline0/push.h>
61#include <nng/protocol/pipeline0/pull.h>
62
63#define EMULATE_NNG
64#include "test_nng_em.c" // nng/nn emulation (before including things under test)
65
66
67#include "../src/common/include/rmr.h" // things the users see
68#include "../src/common/include/rmr_symtab.h"
69#include "../src/common/include/rmr_agnostic.h" // transport agnostic header
70#include "../src/nng/include/rmr_nng_private.h" // transport specific
71
72#include "../src/common/src/symtab.c"
73#include "../src/nng/src/rmr_nng.c"
E. Scott Danielsd7109572019-04-18 14:01:16 +000074#include "../src/common/src/mbuf_api.c"
E. Scott Daniels8dd46412019-04-16 20:47:54 +000075
76static void gen_rt( uta_ctx_t* ctx ); // defined in sr_nng_static_test, but used by a few others (eliminate order requirement below)
77
78 // specific test tools in this directory
79#include "test_support.c" // things like fail_if()
80 // and finally....
81#include "tools_static_test.c" // local test functions pulled directly because of static nature of things
82#include "symtab_static_test.c"
83#include "ring_static_test.c"
84#include "rt_static_test.c"
85#include "sr_nng_static_test.c"
86#include "wormhole_static_test.c"
87#include "rmr_nng_api_static_test.c"
E. Scott Danielsd7109572019-04-18 14:01:16 +000088#include "mbuf_api_static_test.c"
E. Scott Daniels8dd46412019-04-16 20:47:54 +000089
90
91/*
92 Drive each of the separate tests and report.
93*/
94int main() {
95 int errors = 0;
96
97 fprintf( stderr, "<INFO> starting tool tests\n" );
98 errors += tools_test();
99 fprintf( stderr, "<INFO> error count: %d\n", errors );
100
101 fprintf( stderr, "<INFO> starting ring tests (%d)\n", errors );
102 errors += ring_test();
103 fprintf( stderr, "<INFO> error count: %d\n", errors );
104
105 fprintf( stderr, "<INFO> starting symtab tests\n" );
106 errors += symtab_test( );
107 fprintf( stderr, "<INFO> error count: %d\n", errors );
108
109 fprintf( stderr, "<INFO> starting rtable tests\n" );
110 errors += rt_test(); // route table tests
111 fprintf( stderr, "<INFO> error count: %d\n", errors );
112
113 fprintf( stderr, "<INFO> starting RMr API tests\n" );
114 errors += rmr_api_test();
115 fprintf( stderr, "<INFO> error count: %d\n", errors );
116
117 fprintf( stderr, "<INFO> starting wormhole tests\n" );
118 errors += worm_test(); // test wormhole funcitons
119 fprintf( stderr, "<INFO> error count: %d\n", errors );
120
121 fprintf( stderr, "<INFO> starting send/receive tests\n" );
122 errors += sr_nng_test(); // test the send/receive static functions
123 fprintf( stderr, "<INFO> error count: %d\n", errors );
124
E. Scott Danielsd7109572019-04-18 14:01:16 +0000125 fprintf( stderr, "<INFO> starting mbuf api tests\n" );
126 errors += mbuf_api_test( );
127 fprintf( stderr, "<INFO> error count: %d\n", errors );
128
E. Scott Daniels8dd46412019-04-16 20:47:54 +0000129 if( errors == 0 ) {
130 fprintf( stderr, "<PASS> all tests were OK\n" );
131 } else {
132 fprintf( stderr, "<FAIL> %d modules reported errors\n", errors );
133 }
134
135 return !!errors;
136}