blob: ed1a2119025ce15ca8ae51055abc19fdd76fec7e [file] [log] [blame]
E. Scott Daniels5efb1e62019-05-02 17:09:35 +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
11 http://www.apache.org/licenses/LICENSE-2.0
12
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_nano_test.c
23 Abstract: This tests the whole rmr nanomsg 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 This test only needs to drive the soruce in nanomsg/src. The
32 common library functions are driven by the nng tests.
33
34 Author: E. Scott Daniels
35 Date: 18 January 2018 (IMO HRTL)
36*/
37
38#include <stdio.h>
39#include <stdlib.h>
40#include <netdb.h>
41#include <errno.h>
42#include <string.h>
43#include <errno.h>
44#include <pthread.h>
45#include <ctype.h>
46
47
48#include <unistd.h>
49#include <stdio.h>
50#include <stdlib.h>
51#include <strings.h>
52#include <errno.h>
53#include <string.h>
54#include <stdint.h>
55#include <ctype.h>
56#include <sys/epoll.h>
E. Scott Daniels412d53d2019-05-20 20:00:52 +000057#include <pthread.h>
58#include <semaphore.h>
E. Scott Daniels5efb1e62019-05-02 17:09:35 +000059
60#define DEBUG 1
61
62#include <nanomsg/nn.h>
E. Scott Daniels5efb1e62019-05-02 17:09:35 +000063
64#undef EMULATE_NNG
65#include "test_nng_em.c" // nng/nn emulation (before including things under test)
66
67
E. Scott Daniels412d53d2019-05-20 20:00:52 +000068#include "rmr.h" // things the users see
69#include "rmr_symtab.h"
70#include "rmr_agnostic.h" // transport agnostic header
71#include "rmr_private.h" // transport specific
E. Scott Daniels5efb1e62019-05-02 17:09:35 +000072
E. Scott Daniels412d53d2019-05-20 20:00:52 +000073#include "symtab.c"
74#include "rmr.c"
75#include "mbuf_api.c"
76#include "rtable_static.c"
E. Scott Daniels5efb1e62019-05-02 17:09:35 +000077
78static void gen_rt( uta_ctx_t* ctx ); // defined in sr_static_test, but used by a few others (eliminate order requirement below)
79
80 // specific test tools in this directory
81#include "test_support.c" // things like fail_if()
82 // and finally....
E. Scott Daniels5efb1e62019-05-02 17:09:35 +000083#include "mbuf_api_static_test.c"
84
85#include "sr_nano_static_test.c"
86#include "rmr_nng_api_static_test.c" // this can be used for both nng and nano
87#include "rt_nano_static_test.c" // this can be used for both
88
89
90/*
91 Drive each of the separate tests and report.
92*/
93int main() {
94 int errors = 0;
95
96 fprintf( stderr, "<INFO> starting RMr Nanomsg based API tests\n" );
97 errors += rmr_api_test();
98 fprintf( stderr, "<INFO> error count: %d\n", errors );
99
100 fprintf( stderr, "<INFO> starting mbuf related tests\n" );
101 errors += mbuf_api_test( );
102 fprintf( stderr, "<INFO> error count: %d\n", errors );
103
104 fprintf( stderr, "<INFO> starting send/receive tests\n" );
105 errors += sr_nano_test(); // test the send/receive static functions
106 fprintf( stderr, "<INFO> error count: %d\n", errors );
107
108 fprintf( stderr, "<INFO> starting rt_static tests\n" );
109 errors += rt_test(); // route table things specific to nano
110 fprintf( stderr, "<INFO> error count: %d\n", errors );
111
E. Scott Daniels77526eb2020-09-17 16:39:31 -0400112 test_summary( errors, "nanomsg API tests" );
E. Scott Daniels5efb1e62019-05-02 17:09:35 +0000113 if( errors == 0 ) {
114 fprintf( stderr, "<PASS> all tests were OK\n" );
115 } else {
116 fprintf( stderr, "<FAIL> %d modules reported errors\n", errors );
117 }
118
119 return !!errors;
120}