Motr  M0
module.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include "net/module.h"
23 #include "module/instance.h" /* m0_get */
24 #include "lib/memory.h" /* m0_free0 */
25 #include "ut/ut.h"
26 
27 static void test_net_modules(void)
28 {
29  struct m0 *inst = m0_get();
30  struct m0_module *net;
31  struct m0_module *xprt;
32  int rc;
33 
36  M0_UT_ASSERT(net != NULL);
38  container_of(net, struct m0_net_module, n_module));
39 
40  xprt = &((struct m0_net_module *)inst->i_moddata[M0_MODULE_NET])
41  ->n_xprts[M0_NET_XPRT_BULKMEM].nx_module;
42  M0_UT_ASSERT(xprt->m_cur == M0_MODLEV_NONE);
43  M0_UT_ASSERT(net->m_cur == M0_MODLEV_NONE);
44 
46  M0_UT_ASSERT(rc == 0);
48  M0_UT_ASSERT(net->m_cur == M0_LEVEL_NET);
49 
51  M0_UT_ASSERT(xprt->m_cur == M0_MODLEV_NONE);
52  M0_UT_ASSERT(net->m_cur == M0_MODLEV_NONE);
53 
55 }
57  .ts_name = "net-module",
58  .ts_tests = {
59  { "test", test_net_modules },
60  { NULL, NULL }
61  }
62 };
#define NULL
Definition: misc.h:38
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
#define container_of(ptr, type, member)
Definition: misc.h:33
Definition: ut.h:77
struct m0_module *(* mt_create)(struct m0 *instance)
Definition: module.h:199
const struct m0_module_type m0_net_module_type
Definition: module.c:38
#define m0_free0(pptr)
Definition: memory.h:77
Definition: instance.h:80
const char * ts_name
Definition: ut.h:99
static void test_net_modules(void)
Definition: module.c:27
void * i_moddata[M0_MODULE_NR]
Definition: instance.h:94
static struct m0_addb2_net * net
Definition: net.c:27
struct m0_net_xprt * xprt
Definition: module.c:61
struct m0_ut_suite m0_net_module_ut
Definition: module.c:56
int32_t rc
Definition: trigger_fop.h:47
#define M0_UT_ASSERT(a)
Definition: ut.h:46
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
Definition: module.c:142
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131