Motr  M0
ut.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT
24 #include "lib/trace.h"
25 
26 #include "ut/ut.h"
27 #include "ut/ut_internal.h"
28 #include "ut/module.h" /* m0_ut_module */
29 #include "module/instance.h" /* m0 */
30 #include "lib/errno.h" /* ENOENT */
31 #include "lib/finject.h" /* m0_fi_init */
32 #include "lib/finject_internal.h" /* m0_fi_states_get */
33 #include "lib/string.h" /* m0_streq */
34 #include "lib/memory.h" /* M0_ALLOC_PTR */
35 
41 /*
42  * syslog(8) will trim leading spaces of each kernel log line, so we need to use
43  * a non-space character at the beginning of each line to preserve formatting
44  */
45 #ifdef __KERNEL__
46 #define LOG_PREFIX "."
47 #else
48 #define LOG_PREFIX
49 #endif
50 
51 static int test_suites_enable(const struct m0_ut_module *m);
52 
53 struct ut_entry {
55  const char *ue_suite_name;
56  const char *ue_test_name;
57 };
58 
59 static struct m0_ut_module *ut_module(void)
60 {
61  return m0_get()->i_moddata[M0_MODULE_UT];
62 }
63 
64 M0_INTERNAL int m0_ut_init(struct m0 *instance)
65 {
66  /*
67  * We cannot use ut_module() here: m0_get() is not available,
68  * because m0 instance have not reached M0_LEVEL_INST_ONCE yet.
69  */
71  struct m0_ut_suite *ts;
72  int i;
73  int rc;
74 
76  if (rc != 0)
77  return rc;
78  /*
79  * Ensure that the loop below is able to create the required
80  * number of dependencies.
81  */
82  M0_ASSERT(ARRAY_SIZE(m->ut_module.m_dep) >= m->ut_suites_nr);
83  for (i = 0; i < m->ut_suites_nr; ++i) {
84  ts = m->ut_suites[i];
85  if (!ts->ts_enabled)
86  continue;
90  }
92 }
93 M0_EXPORTED(m0_ut_init);
94 
95 M0_INTERNAL void m0_ut_fini(void)
96 {
98 }
99 M0_EXPORTED(m0_ut_fini);
100 
101 M0_INTERNAL void m0_ut_add(struct m0_ut_module *m, struct m0_ut_suite *ts,
102  bool enable)
103 {
104  M0_PRE(IS_IN_ARRAY(m->ut_suites_nr, m->ut_suites));
105  m->ut_suites[m->ut_suites_nr++] = ts;
106  ts->ts_masked = !enable;
107 }
108 
109 static struct m0_ut_suite *
110 suite_find(const struct m0_ut_module *m, const char *name)
111 {
112  int i;
113 
114  if (name == NULL)
115  return NULL;
116 
117  for (i = 0; i < m->ut_suites_nr; ++i)
118  if (m0_streq(m->ut_suites[i]->ts_name, name))
119  return m->ut_suites[i];
120  return NULL;
121 }
122 
123 static struct m0_ut *get_test_by_name(const struct m0_ut_module *m,
124  const char *s_name, const char *t_name)
125 {
126  struct m0_ut_suite *s;
127  struct m0_ut *t;
128 
129  if (t_name == NULL)
130  return NULL;
131 
132  s = suite_find(m, s_name);
133  if (s != NULL)
134  for (t = s->ts_tests; t->t_name != NULL; ++t)
135  if (m0_streq(t->t_name, t_name))
136  return t;
137  return NULL;
138 }
139 
140 static void set_enabled_flag_for(const struct m0_ut_module *m,
141  const char *s_name, const char *t_name,
142  bool value)
143 {
144  struct m0_ut_suite *s;
145  struct m0_ut *t;
146 
147  M0_PRE(s_name != NULL);
148 
149  s = suite_find(m, s_name);
150  M0_ASSERT(s != NULL); /* ensured by test_list_populate() */
151  s->ts_enabled = value;
152 
153  if (t_name == NULL) {
154  for (t = s->ts_tests; t->t_name != NULL; ++t)
155  t->t_enabled = value;
156  } else {
157  /*
158  * re-enable test suite if value is 'false', because in this
159  * case we disable particular tests, not a whole suite
160  */
161  s->ts_enabled = s->ts_enabled || !value;
162  t = get_test_by_name(m, s_name, t_name);
163  M0_ASSERT(t != NULL); /* ensured by test_list_populate() */
164  t->t_enabled = value;
165  }
166 }
167 
168 static bool
169 exists(const struct m0_ut_module *m, const char *s_name, const char *t_name)
170 {
171  struct m0_ut_suite *s;
172  struct m0_ut *t;
173 
174  s = suite_find(m, s_name);
175  if (s == NULL) {
176  M0_LOG(M0_FATAL, "Unit-test suite '%s' not found!", s_name);
177  return false;
178  }
179 
180  /* if checking only suite existence */
181  if (t_name == NULL)
182  return true;
183 
184  /* got here? then need to check test existence */
185  t = get_test_by_name(m, s_name, t_name);
186  if (t == NULL) {
187  M0_LOG(M0_FATAL, "Unit-test '%s:%s' not found!", s_name, t_name);
188  return false;
189  }
190  return true;
191 }
192 
193 static int test_add(struct m0_list *list, const char *suite, const char *test,
194  const struct m0_ut_module *m)
195 {
196  struct ut_entry *e;
197  int rc = -ENOMEM;
198 
199  M0_PRE(suite != NULL);
200 
201  M0_ALLOC_PTR(e);
202  if (e == NULL)
203  return -ENOMEM;
204 
205  e->ue_suite_name = m0_strdup(suite);
206  if (e->ue_suite_name == NULL)
207  goto err;
208 
209  if (test != NULL) {
211  if (e->ue_test_name == NULL)
212  goto err;
213  }
214 
215  if (exists(m, e->ue_suite_name, e->ue_test_name)) {
218  return 0;
219  }
220  rc = -ENOENT;
221 err:
222  m0_free(e);
223  return rc;
224 }
225 
233 static int test_list_populate(struct m0_list *list, const char *str,
234  const struct m0_ut_module *m)
235 {
236  char *s;
237  char *p;
238  char *token;
239  char *subtoken;
240  int rc = 0;
241 
242  M0_PRE(str != NULL);
243 
244  s = m0_strdup(str);
245  if (s == NULL)
246  return -ENOMEM;
247  p = s;
248 
249  while ((token = strsep(&p, ",")) != NULL) {
250  subtoken = strchr(token, ':');
251  if (subtoken != NULL)
252  *subtoken++ = '\0';
253 
254  rc = test_add(list, token, subtoken, m);
255  if (rc != 0)
256  break;
257  }
258  m0_free(s);
259  return rc;
260 }
261 
262 static void test_list_destroy(struct m0_list *list)
263 {
265  m0_list_del(&e->ue_linkage);
266  m0_free((char *)e->ue_suite_name);
267  m0_free((char *)e->ue_test_name);
268  m0_free(e);
269  true);
271 }
272 
273 static int test_list_create(struct m0_list *list, const struct m0_ut_module *m)
274 {
275  int rc;
276 
277  M0_PRE(m->ut_tests != NULL && *m->ut_tests != '\0');
278 
279 #ifdef __KERNEL__
280  /*
281  * FI module is not initalised yet, but test_list_populate() calls
282  * m0_alloc, with uses M0_FI_ENABLED.
283  * M0_FI_ENABLED requires initialised FI.
284  */
285  m0_fi_init();
286 #endif
287 
289  rc = test_list_populate(list, m->ut_tests, m);
290  if (rc != 0)
292 
293 #ifdef __KERNEL__
294  m0_fi_fini();
295 #endif
296  return rc;
297 }
298 
299 static int test_suites_enable(const struct m0_ut_module *m)
300 {
301  struct m0_list disable_list;
302  struct m0_ut *t;
303 
304  bool flag;
305  int i;
306  int rc = 0;
307 
308  flag = (m->ut_tests == NULL || m->ut_exclude);
309 
310  for (i = 0; i < m->ut_suites_nr; ++i) {
311  m->ut_suites[i]->ts_enabled = flag;
312  for (t = m->ut_suites[i]->ts_tests; t->t_name != NULL; ++t)
313  t->t_enabled = flag;
314  }
315 
316  if (m->ut_tests != NULL) {
317  rc = test_list_create(&disable_list, m);
318  if (rc != 0)
319  return rc;
320 
321  m0_list_entry_forall(e, &disable_list, struct ut_entry, ue_linkage,
322  set_enabled_flag_for(m, e->ue_suite_name,
323  e->ue_test_name, !flag);
324  true);
325  test_list_destroy(&disable_list);
326  }
327 
328  return rc;
329 }
330 
331 static inline const char *skipspaces(const char *str)
332 {
333  while (isspace(*str))
334  ++str;
335  return str;
336 }
337 
338 /* Checks that all fault injections are disabled. */
339 static void check_all_fi_disabled(void)
340 {
341 #ifdef ENABLE_FAULT_INJECTION
342  const struct m0_fi_fpoint_state *fi_states;
343  const struct m0_fi_fpoint_state *state;
344  uint32_t fi_free_idx;
345  uint32_t i;
346 
347  /*
348  * Assume there is no concurrent access to the FI states at this point.
349  */
351  fi_free_idx = m0_fi_states_get_free_idx();
352  for (i = 0; i < fi_free_idx; ++i) {
353  state = &fi_states[i];
355  "Fault injection is not disabled: %s(), \"%s\"",
356  state->fps_id.fpi_func, state->fps_id.fpi_tag);
357  }
358 #endif /* ENABLE_FAULT_INJECTION */
359 }
360 
361 static void run_test(const struct m0_ut *test, size_t max_name_len)
362 {
363  static const char padding[256] = { [0 ... 254] = ' ', [255] = '\0' };
364 
365  size_t pad_len;
366  size_t name_len;
367  char mem[16];
368  uint64_t mem_before;
369  uint64_t mem_after;
370  uint64_t mem_used;
372  m0_time_t end;
374 
375  if (!test->t_enabled)
376  return;
377 
378  name_len = strlen(test->t_name);
379  if (test->t_owner != NULL) {
380  m0_console_printf(LOG_PREFIX " %s [%s] ",
381  test->t_name, test->t_owner);
382  name_len += strlen(test->t_owner) + 2; /* 2 for [] */
383  } else
384  m0_console_printf(LOG_PREFIX " %s ", test->t_name);
386  mem_before = m0_allocated_total();
387  start = m0_time_now();
388 
389  /* run the test */
390  test->t_proc();
391 
392  end = m0_time_now();
393  mem_after = m0_allocated_total();
394 
395  /* max_check is for case when max_name_len == 0 */
396  pad_len = max_check(name_len, max_name_len) - name_len;
397  pad_len = min_check(pad_len, ARRAY_SIZE(padding) - 1);
398  duration = m0_time_sub(end, start);
399  mem_used = mem_after - mem_before;
400 
401  m0_console_printf("%.*s%4" PRIu64 ".%02" PRIu64 " sec %sB\n",
402  (int)pad_len, padding, m0_time_seconds(duration),
404  m0_bcount_with_suffix(mem, ARRAY_SIZE(mem), mem_used));
406 }
407 
408 static int run_suite(const struct m0_ut_suite *suite, int max_name_len)
409 {
410  const struct m0_ut *test;
411 
412  char leak[16];
413  uint64_t alloc_before;
414  uint64_t alloc_after;
415  char mem[16];
416  uint64_t mem_before;
417  uint64_t mem_after;
418  uint64_t mem_used;
420  m0_time_t end;
422  int rc = 0;
423 
424  if (suite->ts_masked) {
425  if (suite->ts_enabled) {
426  m0_console_printf("#\n# %s <<<<<<<<<<<< -=!!! "
427  "DISABLED !!!=-\n#\n", suite->ts_name);
429  }
430  return 0;
431  }
432 
433  if (!suite->ts_enabled)
434  return 0;
435 
436  if (suite->ts_owners != NULL)
437  m0_console_printf("%s [%s]\n",
438  suite->ts_name, suite->ts_owners);
439  else
440  m0_console_printf("%s \n", suite->ts_name);
442 
443  alloc_before = m0_allocated();
444  mem_before = m0_allocated_total();
445  start = m0_time_now();
446 
447  if (suite->ts_init != NULL) {
448  rc = suite->ts_init();
449  if (rc != 0)
450  M0_ERR_INFO(rc, "Unit-test suite initialization failure.");
451  }
452 
453  for (test = suite->ts_tests; test->t_name != NULL; ++test) {
454 #ifndef __KERNEL__
455  M0_INTERNAL void m0_cs_gotsignal_reset(void);
456 
458 #endif
459  run_test(test, max_name_len);
460  }
461 
462  if (suite->ts_fini != NULL) {
463  rc = suite->ts_fini();
464  if (rc != 0)
465  M0_ERR_INFO(rc, "Unit-test suite finalization failure.");
466  }
467 
468  /*
469  * Check that fault injections don't move beyond the test suite
470  * boundaries. We don't want them to cause unexpected side effects to
471  * further tests.
472  */
474 
475  end = m0_time_now();
476  mem_after = m0_allocated_total();
477  alloc_after = m0_allocated();
478  /* It's possible that some earlier allocated memory was released. */
479  alloc_after = max64(alloc_after, alloc_before);
480  duration = m0_time_sub(end, start);
481  mem_used = mem_after - mem_before;
482 
483  m0_console_printf(LOG_PREFIX " [ time: %" PRIu64 ".%02" PRIu64 " sec,"
484  " mem: %sB, leaked: %sB ]\n", m0_time_seconds(duration),
487  mem_used)),
489  alloc_after - alloc_before)));
491  return rc;
492 }
493 
494 static int max_test_name_len(const struct m0_ut_suite **suites, unsigned nr)
495 {
496  const struct m0_ut *test;
497  unsigned i;
498  size_t max_len = 0;
499 
500  for (i = 0; i < nr; ++i) {
501  for (test = suites[i]->ts_tests; test->t_name != NULL; ++test)
502  max_len = max_check(strlen(test->t_name), max_len);
503  }
504  return max_len;
505 }
506 
507 static int tests_run_all(const struct m0_ut_module *m)
508 {
509  int i;
510  int rc;
511 
512  for (i = rc = 0; i < m->ut_suites_nr && rc == 0; ++i)
513  rc = run_suite(m->ut_suites[i],
514  max_test_name_len((const struct m0_ut_suite **)
515  m->ut_suites,
516  m->ut_suites_nr));
517  return rc;
518 }
519 
520 M0_INTERNAL int m0_ut_run(void)
521 {
522  char leak[16];
523  const char *leak_str;
524  uint64_t alloc_before;
525  uint64_t alloc_after;
526  char mem[16];
527  const char *mem_str;
528  uint64_t mem_before;
529  uint64_t mem_after;
532  int rc;
533  const struct m0_ut_module *m = ut_module();
534 
535  alloc_before = m0_allocated();
536  mem_before = m0_allocated_total();
537  start = m0_time_now();
538 
539  rc = tests_run_all(m);
540 
541  mem_after = m0_allocated_total();
542  alloc_after = m0_allocated();
545  mem, ARRAY_SIZE(mem),
546  mem_after - mem_before));
548  leak, ARRAY_SIZE(leak),
549  alloc_after - alloc_before));
550  if (rc == 0) {
551  m0_console_printf("\nTime: %" PRIu64 ".%02" PRIu64 " sec,"
552  " Mem: %sB, Leaked: %sB, Asserts: %" PRIu64
553  "\nUnit tests status: SUCCESS\n",
556  M0_TIME_ONE_MSEC / 10,
557  leak_str, mem_str,
558  m0_atomic64_get(&m->ut_asserts));
560  }
561  return rc;
562 }
563 M0_EXPORTED(m0_ut_run);
564 
565 M0_INTERNAL void m0_ut_list(bool with_tests, bool yaml_output)
566 {
567  const struct m0_ut_module *m = ut_module();
568  const struct m0_ut *t;
569  int i;
570 
571  if (yaml_output)
572  m0_console_printf("---\n");
573 
574  for (i = 0; i < m->ut_suites_nr; ++i) {
575  if (yaml_output) {
576  m0_console_printf("- %s:\n", m->ut_suites[i]->ts_name);
577  if (m->ut_suites[i]->ts_yaml_config_string != NULL)
578  m0_console_printf(" config: %s\n",
579  m->ut_suites[i]->ts_yaml_config_string);
580  } else {
581  m0_console_printf("%s\n", m->ut_suites[i]->ts_name);
582  }
583  if (with_tests) {
584  if (yaml_output)
585  m0_console_printf(" tests:\n");
586  for (t = m->ut_suites[i]->ts_tests; t->t_name != NULL; ++t)
587  m0_console_printf(yaml_output ? " - %s\n" :
588  " %s\n", t->t_name);
589  }
590  }
591 }
592 
593 static void ut_owners_print(const struct m0_ut_suite *suite)
594 {
595  const struct m0_ut *t;
596 
597  for (t = suite->ts_tests; t->t_name != NULL; ++t) {
598  if (t->t_owner != NULL)
599  m0_console_printf(" %s: %s\n", t->t_name, t->t_owner);
600  }
601 }
602 
603 M0_INTERNAL void m0_ut_list_owners(void)
604 {
605  const struct m0_ut_module *m = ut_module();
606  const struct m0_ut_suite *s;
607  const struct m0_ut *t;
608  int i;
609 
610  for (i = 0; i < m->ut_suites_nr; ++i) {
611  s = m->ut_suites[i];
612  if (s->ts_owners == NULL) {
613  for (t = s->ts_tests; t->t_name != NULL; ++t) {
614  if (t->t_owner != NULL) {
615  m0_console_printf("%s\n", s->ts_name);
617  break;
618  }
619  }
620  } else {
621  m0_console_printf("%s: %s\n", s->ts_name, s->ts_owners);
623  }
624  }
625 }
626 
627 M0_INTERNAL bool m0_ut_assertimpl(bool c, const char *str_c, const char *file,
628  int lno, const char *func)
629 {
630  static char buf[4096];
631 
632  m0_atomic64_inc(&ut_module()->ut_asserts);
633  if (!c) {
634  snprintf(buf, sizeof buf,
635  "Unit-test assertion failed: %s", str_c);
636  m0_panic(&(struct m0_panic_ctx){
637  .pc_expr = buf, .pc_func = func,
638  .pc_file = file, .pc_lineno = lno,
639  .pc_fmt = NULL });
640  }
641  return c;
642 }
643 M0_EXPORTED(m0_ut_assertimpl);
644 
645 M0_INTERNAL bool m0_ut_small_credits(void)
646 {
647  return ut_module()->ut_small_credits;
648 }
649 M0_EXPORTED(m0_ut_small_credits);
650 
651 #ifndef __KERNEL__
652 #include <stdlib.h> /* qsort */
653 
654 static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
655 {
656  return (*s0)->ts_order - (*s1)->ts_order;
657 }
658 
659 M0_INTERNAL void m0_ut_shuffle(unsigned seed)
660 {
661  struct m0_ut_module *m = ut_module();
662  unsigned i;
663 
664  M0_PRE(m->ut_suites_nr > 0);
665 
666  srand(seed);
667  for (i = 1; i < m->ut_suites_nr; ++i)
668  m->ut_suites[i]->ts_order = rand();
669  qsort(m->ut_suites + 1, m->ut_suites_nr - 1, sizeof m->ut_suites[0],
670  (void *)&cmp);
671 }
672 
673 M0_INTERNAL void m0_ut_start_from(const char *suite)
674 {
675  struct m0_ut_module *m = ut_module();
676  unsigned i;
677  int o;
678 
679  for (i = 0, o = 0; i < m->ut_suites_nr; ++i, ++o) {
680  if (m0_streq(m->ut_suites[i]->ts_name, suite))
681  o = -m->ut_suites_nr - 1;
682  m->ut_suites[i]->ts_order = o;
683  }
684  qsort(m->ut_suites, m->ut_suites_nr, sizeof m->ut_suites[0],
685  (void *)&cmp);
686 }
687 #endif
688 
689 struct m0_fid g_process_fid = M0_FID_TINIT('r', 1, 1);
690 
692 #undef M0_TRACE_SUBSYSTEM
693 
694 /*
695  * Local variables:
696  * c-indentation-style: "K&R"
697  * c-basic-offset: 8
698  * tab-width: 8
699  * fill-column: 80
700  * scroll-step: 1
701  * End:
702  */
static void m0_atomic64_inc(struct m0_atomic64 *a)
static struct m0_addb2_philter p
Definition: consumer.c:40
static size_t nr
Definition: dump.c:1505
#define M0_PRE(cond)
static bool exists(const struct m0_ut_module *m, const char *s_name, const char *t_name)
Definition: ut.c:169
static struct m0_ut_module * ut_module(void)
Definition: ut.c:59
static struct m0_list list
Definition: list.c:144
struct m0_fi_fpoint_id fps_id
#define m0_strdup(s)
Definition: string.h:43
const char * ue_suite_name
Definition: ut.c:55
#define NULL
Definition: misc.h:38
static struct m0_addb2_mach * m
Definition: consumer.c:38
static int test_list_create(struct m0_list *list, const struct m0_ut_module *m)
Definition: ut.c:273
#define LOG_PREFIX
Definition: ut.c:48
M0_INTERNAL void m0_list_init(struct m0_list *head)
Definition: list.c:29
struct m0_file file
Definition: di.c:36
uint64_t m0_time_t
Definition: time.h:37
#define M0_LOG(level,...)
Definition: trace.h:167
#define min_check(a, b)
Definition: arith.h:88
M0_INTERNAL size_t m0_allocated_total(void)
Definition: memory.c:221
void m0_panic(const struct m0_panic_ctx *ctx,...)
Definition: assert.c:40
void m0_console_printf(const char *fmt,...)
Definition: trace.c:801
const char * t_name
Definition: ut.h:66
M0_INTERNAL const struct m0_fi_fpoint_state * m0_fi_states_get(void)
Definition: finject.c:88
uint64_t m0_time_nanoseconds(const m0_time_t time)
Definition: time.c:89
#define max_check(a, b)
Definition: arith.h:95
static int max_test_name_len(const struct m0_ut_suite **suites, unsigned nr)
Definition: ut.c:494
static void test_list_destroy(struct m0_list *list)
Definition: ut.c:262
static int tests_run_all(const struct m0_ut_module *m)
Definition: ut.c:507
M0_INTERNAL void m0_list_fini(struct m0_list *head)
Definition: list.c:36
int const char const void * value
Definition: dir.c:325
M0_INTERNAL void m0_list_del(struct m0_list_link *old)
Definition: list.c:147
int(* ts_init)(void)
Definition: ut.h:112
bool ut_small_credits
Definition: module.h:60
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
static int void * buf
Definition: dir.c:1019
bool ts_masked
Definition: ut.h:97
Definition: ut.h:77
const char * ue_test_name
Definition: ut.c:56
static int test_add(struct m0_list *list, const char *suite, const char *test, const struct m0_ut_module *m)
Definition: ut.c:193
struct tpool_test test[]
Definition: thread_pool.c:45
Definition: sock.c:887
M0_INTERNAL size_t m0_allocated(void)
Definition: memory.c:215
static struct m0_ut_suite * suite_find(const struct m0_ut_module *m, const char *name)
Definition: ut.c:110
M0_INTERNAL int m0_fi_init(void)
Definition: finject_init.c:40
static void ut_owners_print(const struct m0_ut_suite *suite)
Definition: ut.c:593
M0_INTERNAL void m0_ut_fini(void)
Definition: ut.c:95
int i
Definition: dir.c:1033
const char * m0_bcount_with_suffix(char *buf, size_t size, m0_bcount_t c)
Definition: string.c:32
#define PRIu64
Definition: types.h:58
static int64_t max64(int64_t a, int64_t b)
Definition: arith.h:51
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
struct m0_ut ts_tests[M0_UT_SUITE_TESTS_MAX]
Definition: ut.h:119
const char * name
Definition: trace.c:110
static const char * skipspaces(const char *str)
Definition: ut.c:331
#define M0_FID_TINIT(type, container, key)
Definition: fid.h:90
M0_INTERNAL int m0_ut_init(struct m0 *instance)
Definition: ut.c:64
#define M0_ASSERT(cond)
M0_INTERNAL void m0_ut_start_from(const char *suite)
Definition: ut.c:673
static void duration(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:503
bool ts_enabled
Definition: ut.h:90
int(* ts_fini)(void)
Definition: ut.h:117
m0_time_t m0_time_now(void)
Definition: time.c:134
static struct m0_addb2_callback c
Definition: consumer.c:41
static struct m0_thread t[8]
Definition: service_ut.c:1230
#define m0_streq(a, b)
Definition: string.h:34
int rand(void)
static int test_suites_enable(const struct m0_ut_module *m)
Definition: ut.c:299
Definition: instance.h:80
static int cmp(const struct m0_ut_suite **s0, const struct m0_ut_suite **s1)
Definition: ut.c:654
static int test_list_populate(struct m0_list *list, const char *str, const struct m0_ut_module *m)
Definition: ut.c:233
static int run_suite(const struct m0_ut_suite *suite, int max_name_len)
Definition: ut.c:408
static void token(struct ff2c_context *ctx, struct ff2c_term *term, struct ff2c_token *tok)
Definition: parser.c:66
#define m0_list_entry_forall(var, head, type, member,...)
Definition: list.h:313
static void check_all_fi_disabled(void)
Definition: ut.c:339
uint64_t m0_time_seconds(const m0_time_t time)
Definition: time.c:83
static int lno
Definition: list.h:72
const char * fpi_tag
static void set_enabled_flag_for(const struct m0_ut_module *m, const char *s_name, const char *t_name, bool value)
Definition: ut.c:140
static int64_t m0_atomic64_get(const struct m0_atomic64 *a)
const char * ts_name
Definition: ut.h:99
M0_INTERNAL void m0_ut_list_owners(void)
Definition: ut.c:603
M0_INTERNAL void m0_module_dep_add(struct m0_module *m0, int l0, struct m0_module *m1, int l1)
Definition: module.c:168
M0_INTERNAL uint32_t m0_fi_states_get_free_idx(void)
Definition: finject.c:94
M0_INTERNAL bool m0_ut_assertimpl(bool c, const char *str_c, const char *file, int lno, const char *func)
Definition: ut.c:627
void m0_console_flush(void)
Definition: ktrace.c:165
const char * ts_owners
Definition: ut.h:101
Definition: fid.h:38
static bool fi_state_enabled(const struct m0_fi_fpoint_state *state)
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
Definition: list.c:42
void * i_moddata[M0_MODULE_NR]
Definition: instance.h:94
Definition: ut.c:53
M0_INTERNAL void m0_ut_add(struct m0_ut_module *m, struct m0_ut_suite *ts, bool enable)
Definition: ut.c:101
m0_time_t m0_time_sub(const m0_time_t t1, const m0_time_t t2)
Definition: time.c:65
static bool flag
Definition: nucleus.c:266
static int start(struct m0_fom *fom)
Definition: trigger_fom.c:321
const char * fpi_func
#define IS_IN_ARRAY(idx, array)
Definition: misc.h:311
static struct m0 instance
Definition: main.c:78
M0_INTERNAL bool m0_ut_small_credits(void)
Definition: ut.c:645
static struct m0_ut * get_test_by_name(const struct m0_ut_module *m, const char *s_name, const char *t_name)
Definition: ut.c:123
M0_INTERNAL void m0_ut_suite_module_setup(struct m0_ut_suite *ts, struct m0 *instance)
Definition: module.c:90
#define M0_ASSERT_INFO(cond, fmt,...)
M0_INTERNAL int m0_ut_run(void)
Definition: ut.c:520
M0_INTERNAL void m0_ut_list(bool with_tests, bool yaml_output)
Definition: ut.c:565
M0_INTERNAL void m0_list_link_init(struct m0_list_link *link)
Definition: list.c:169
static const char padding[256]
Definition: st.c:276
M0_INTERNAL void m0_list_add_tail(struct m0_list *head, struct m0_list_link *new)
Definition: list.c:119
M0_INTERNAL void m0_fi_fini(void)
Definition: finject_init.c:47
struct m0_module i_self
Definition: instance.h:88
M0_INTERNAL void m0_ut_shuffle(unsigned seed)
Definition: ut.c:659
void m0_free(void *data)
Definition: memory.c:146
static struct m0_addb2_source * s
Definition: consumer.c:39
static void run_test(const struct m0_ut *test, size_t max_name_len)
Definition: ut.c:361
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
struct m0_fid g_process_fid
Definition: ut.c:689
Definition: ut.h:64
struct m0_module ts_module
Definition: ut.h:78
M0_INTERNAL void m0_module_fini(struct m0_module *module, int level)
Definition: module.c:142
M0_INTERNAL void m0_cs_gotsignal_reset(void)
Definition: setup.c:2421
M0_INTERNAL int m0_module_init(struct m0_module *module, int level)
Definition: module.c:131
struct m0_list_link ue_linkage
Definition: ut.c:54
struct m0_fi_fpoint_state fi_states[FI_STATES_ARRAY_SIZE]
Definition: finject.c:48