Motr  M0
m0ut_main.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2021 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include <linux/version.h> /* LINUX_VERSION_CODE */
24 #include <linux/module.h>
25 
26 #include "lib/thread.h" /* M0_THREAD_INIT */
27 #include "ut/ut.h" /* m0_ut_add */
28 #include "module/instance.h" /* m0 */
29 #include "ut/module.h" /* m0_ut_module */
30 
31 /*
32  * We are using Apache license for complete motr code but for MODULE_LICENSE
33  * marker there is no provision to mention Apache for this marker. But as this
34  * marker is necessary to remove the warnings, keeping this blank to make
35  * compiler happy.
36  */
38 
39 static char *tests;
40 module_param(tests, charp, S_IRUGO);
41 MODULE_PARM_DESC(tests, " list of tests to run in format"
42  " 'suite[:test][,suite[:test]]'");
43 
44 static char *exclude;
45 module_param(exclude, charp, S_IRUGO);
46 MODULE_PARM_DESC(exclude, " list of tests to exclude in format"
47  " 'suite[:test][,suite[:test]]'");
48 
49 /* sort test suites in alphabetic order */
50 extern struct m0_ut_suite m0_klibm0_ut; /* test lib first */
51 extern struct m0_ut_suite addb2_base_ut;
52 extern struct m0_ut_suite addb2_consumer_ut;
53 extern struct m0_ut_suite addb2_hist_ut;
54 extern struct m0_ut_suite addb2_sys_ut;
55 extern struct m0_ut_suite be_ut;
56 extern struct m0_ut_suite buffer_pool_ut;
57 extern struct m0_ut_suite bulkio_client_ut;
58 extern struct m0_ut_suite m0_net_bulk_if_ut;
59 extern struct m0_ut_suite m0_net_bulk_mem_ut;
60 extern struct m0_ut_suite m0_net_lnet_ut;
61 extern struct m0_ut_suite m0_net_test_ut;
62 extern struct m0_ut_suite m0_net_tm_prov_ut;
63 extern struct m0_ut_suite conn_ut;
64 extern struct m0_ut_suite dtm_dtx_ut;
65 extern struct m0_ut_suite dtm_nucleus_ut;
66 extern struct m0_ut_suite dtm_transmit_ut;
68 extern struct m0_ut_suite failure_domains_ut;
69 extern struct m0_ut_suite file_io_ut;
70 extern struct m0_ut_suite fom_timedwait_ut;
71 extern struct m0_ut_suite frm_ut;
72 extern struct m0_ut_suite ha_ut;
73 extern struct m0_ut_suite layout_ut;
74 extern struct m0_ut_suite ms_fom_ut;
75 extern struct m0_ut_suite packet_encdec_ut;
76 extern struct m0_ut_suite parity_math_ssse3_ut;
77 extern struct m0_ut_suite reqh_service_ut;
78 extern struct m0_ut_suite rpc_mc_ut;
79 extern struct m0_ut_suite rm_ut;
80 extern struct m0_ut_suite session_ut;
81 extern struct m0_ut_suite sm_ut;
82 extern struct m0_ut_suite stob_ut;
83 extern struct m0_ut_suite xcode_ut;
84 extern struct m0_ut_suite di_ut;
85 
86 static struct m0_thread ut_thread;
87 
88 static void tests_add(struct m0_ut_module *m)
89 {
90  /*
91  * set last argument to 'false' to disable test,
92  * it will automatically print a warning to console
93  */
94 
95  /* sort test suites in alphabetic order */
96  m0_ut_add(m, &m0_klibm0_ut, true); /* test lib first */
97  m0_ut_add(m, &addb2_base_ut, true);
98  m0_ut_add(m, &addb2_consumer_ut, true);
99  m0_ut_add(m, &addb2_hist_ut, true);
100  m0_ut_add(m, &addb2_sys_ut, true);
101  m0_ut_add(m, &di_ut, true);
102  m0_ut_add(m, &file_io_ut, true);
103  m0_ut_add(m, &be_ut, true);
104  m0_ut_add(m, &buffer_pool_ut, true);
105  m0_ut_add(m, &bulkio_client_ut, true);
106  m0_ut_add(m, &m0_net_bulk_if_ut, true);
107  m0_ut_add(m, &m0_net_bulk_mem_ut, true);
108  m0_ut_add(m, &m0_net_lnet_ut, true);
109  m0_ut_add(m, &m0_net_test_ut, true);
110  m0_ut_add(m, &m0_net_tm_prov_ut, true);
111 
112  m0_ut_add(m, &conn_ut, true);
113  m0_ut_add(m, &dtm_nucleus_ut, true);
114  m0_ut_add(m, &dtm_transmit_ut, true);
115  m0_ut_add(m, &dtm_dtx_ut, true);
117  m0_ut_add(m, &failure_domains_ut, true);
118  m0_ut_add(m, &fom_timedwait_ut, true);
119  m0_ut_add(m, &frm_ut, true);
120  m0_ut_add(m, &ha_ut, true);
121  m0_ut_add(m, &layout_ut, true);
122  m0_ut_add(m, &ms_fom_ut, true);
123  m0_ut_add(m, &packet_encdec_ut, true);
124  m0_ut_add(m, &reqh_service_ut, true);
125  m0_ut_add(m, &rm_ut, true);
126  m0_ut_add(m, &rpc_mc_ut, true);
127  m0_ut_add(m, &session_ut, true);
128  m0_ut_add(m, &sm_ut, true);
129  m0_ut_add(m, &stob_ut, true);
130  m0_ut_add(m, &xcode_ut, true);
131 }
132 
133 static void run_kernel_ut(int _)
134 {
135  printk(KERN_INFO "Motr Kernel Unit Test\n");
136  m0_ut_run();
137 }
138 
139 static int __init m0_ut_module_init(void)
140 {
141  static struct m0 instance;
142  struct m0_ut_module *ut;
143  int rc;
144 
149 
150  if (tests != NULL && exclude != NULL)
151  return EINVAL; /* only one of the lists should be provided */
152 
153  ut->ut_exclude = (exclude != NULL);
154  ut->ut_tests = ut->ut_exclude ? exclude : tests;
155 
156  tests_add(ut);
157 
158  rc = m0_ut_init(&instance);
159  if (rc != 0)
160  /*
161  * We still need to raise m0 instance to M0_LEVEL_INST_ONCE,
162  * otherwise an attempt to unload m0kut kernel module will
163  * result in kernel panic.
164  */
166  rc = M0_THREAD_INIT(&ut_thread, int, NULL, &run_kernel_ut, 0, "m0kut");
167  M0_ASSERT(rc == 0);
168  return rc;
169 }
170 
171 static void __exit m0_ut_module_fini(void)
172 {
175  m0_ut_fini();
176 }
177 
180 
181 /*
182  * Local variables:
183  * c-indentation-style: "K&R"
184  * c-basic-offset: 8
185  * tab-width: 8
186  * fill-column: 80
187  * scroll-step: 1
188  * End:
189  */
struct m0_ut_suite m0_net_tm_prov_ut
static char * exclude
Definition: m0ut_main.c:44
const char * ut_tests
Definition: module.h:50
struct m0_ut_suite sm_ut
Definition: sm.c:643
MODULE_LICENSE()
struct m0_ut_suite packet_encdec_ut
Definition: packet.c:259
struct m0_ut_suite be_ut
Definition: main.c:156
struct m0_ut_suite dtm_nucleus_ut
Definition: nucleus.c:376
struct m0_ut_suite frm_ut
Definition: formation2.c:659
struct m0_ut_suite dtm_transmit_ut
Definition: transmit.c:731
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
int m0_thread_join(struct m0_thread *q)
Definition: kthread.c:169
struct m0_ut_suite di_ut
Definition: di.c:134
struct m0_ut_suite file_io_ut
Definition: file.c:1259
M0_INTERNAL void m0_instance_setup(struct m0 *instance)
Definition: instance.c:110
struct m0_ut_suite bulkio_client_ut
#define M0_THREAD_INIT(thread, TYPE, init, func, arg, namefmt,...)
Definition: thread.h:139
struct m0_ut_suite m0_klibm0_ut
Definition: main.c:57
struct m0_ut_suite parity_math_ssse3_ut
module_param(tests, charp, S_IRUGO)
Definition: ut.h:77
struct m0_ut_suite buffer_pool_ut
struct m0_module *(* mt_create)(struct m0 *instance)
Definition: module.h:199
static void __exit m0_ut_module_fini(void)
Definition: m0ut_main.c:171
struct m0_ut_suite ms_fom_ut
Definition: ms_fom_ut.c:402
struct m0_ut_suite m0_net_bulk_mem_ut
Definition: bulk_mem_ut.c:819
struct m0_ut_suite addb2_consumer_ut
Definition: consumer.c:391
static struct m0_thread ut_thread
Definition: m0ut_main.c:86
M0_INTERNAL void m0_ut_fini(void)
Definition: ut.c:95
struct m0_ut_suite session_ut
Definition: session.c:322
struct m0_ut_suite conn_ut
Definition: conn.c:318
MODULE_PARM_DESC(tests, " list of tests to run in format" " 'suite[:test][,suite[:test]]'")
module_init(motr_init)
M0_INTERNAL int m0_ut_init(struct m0 *instance)
Definition: ut.c:64
#define M0_ASSERT(cond)
M0_THREAD_ENTER
Definition: dir.c:336
bool ut_exclude
Definition: module.h:55
struct m0_ut_suite xcode_ut
Definition: xcode.c:1273
struct m0_ut_suite m0_net_lnet_ut
Definition: lnet_ut.c:2231
Definition: instance.h:80
struct m0_ut_suite dtm_dtx_ut
Definition: dtx.c:450
struct m0_ut_suite m0_net_bulk_if_ut
Definition: bulk_if.c:1229
static int __init m0_ut_module_init(void)
Definition: m0ut_main.c:139
const struct m0_module_type m0_ut_module_type
Definition: module.c:37
module_exit(motr_exit)
struct m0_ut_suite addb2_base_ut
Definition: base.c:431
struct m0_ut_suite m0_net_test_ut
Definition: main.c:60
struct m0_ut_suite failure_domains_ut
Definition: fd.c:541
struct m0_ut_suite ha_ut
Definition: main.c:49
static void tests_add(struct m0_ut_module *m)
Definition: m0ut_main.c:88
void * i_moddata[M0_MODULE_NR]
Definition: instance.h:94
struct m0_ut_suite stob_ut
Definition: main.c:47
struct m0_ut_suite addb2_sys_ut
Definition: sys.c:271
struct m0_ut_suite addb2_hist_ut
Definition: histogram.c:105
static char * tests
Definition: m0ut_main.c:39
M0_INTERNAL void m0_ut_add(struct m0_ut_module *m, struct m0_ut_suite *ts, bool enable)
Definition: ut.c:101
static void run_kernel_ut(int _)
Definition: m0ut_main.c:133
static struct m0 instance
Definition: main.c:78
struct m0_ut_suite reqh_service_ut
Definition: service.c:117
struct m0_ut_suite failure_domains_tree_ut
Definition: fd_tree.c:182
M0_INTERNAL int m0_ut_run(void)
Definition: ut.c:520
struct m0_ut_suite rpc_mc_ut
Definition: rpc_machine.c:222
struct m0_ut_suite rm_ut
Definition: rmut.c:458
struct m0_module i_self
Definition: instance.h:88
int32_t rc
Definition: trigger_fop.h:47
struct m0_ut_suite fom_timedwait_ut
struct m0_ut_suite layout_ut
Definition: layout.c:3763
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131