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 Mnemonic: test_ctx_support.c
23 Abstract: This is some support for defining dummy contex struct as
24 they may need to contian rings and the like for successful
25 testing, and it may be too much to call rmr_init() to generate
26 one without dragging the whole test under.
28 Author: E. Scott Daniels
29 Date: 21 February 2020
32 #ifndef _test_ctx_support_c
33 #define _test_ctx_support_c
35 #ifdef NNG_UNDER_TEST // add in the nng only things
37 #include <rmr_nng_private.h> // nng specific context
39 static inline uta_ctx_t *mk_dummy_ctx() {
42 ctx = (uta_ctx_t *) malloc( sizeof( *ctx ) );
47 memset( ctx, 0, sizeof( *ctx ) );
52 #else // assume si is under test
54 #include <rmr_si_private.h> // si specific context
55 #include <ring_static.c>
57 static inline uta_ctx_t *mk_dummy_ctx() {
60 ctx = (uta_ctx_t *) malloc( sizeof( *ctx ) );
65 memset( ctx, 0, sizeof( *ctx ) );
67 ctx->mring = uta_mk_ring( 4096 ); // message ring is always on for si
68 ctx->zcb_mring = uta_mk_ring( 128 ); // zero copy buffer mbuf ring to reduce malloc/free calls
69 ctx->si_ctx = malloc( 1024 );