Motr
M0
|
Common unit test library. More...
Data Structures | |
struct | m0_ut_moddep |
struct | m0_ut_module |
struct | m0_ut_threads_descr |
struct | ut_entry |
struct | m0_ut |
struct | m0_ut_suite |
struct | m0_ut_redirect |
Macros | |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT |
#define | M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_UT |
#define | M0_UT_PATH(name) M0_SRC_PATH("ut/" name) |
#define | M0_UT_CONF_PROFILE "<0x7000000000000001:0>" |
#define | M0_UT_CONF_PROFILE_BAD "<0x7000000000000000:999>" /* non-existent */ |
#define | M0_UT_CONF_PROCESS "<0x7200000000000001:5>" |
#define | M0_UT_THREADS_DEFINE(name, thread_func) |
#define | M0_UT_THREADS_START(name, thread_nr, param_array) |
#define | M0_UT_THREADS_STOP(name) m0_ut_threads_stop(&ut_threads_descr_##name) |
#define | LOG_PREFIX |
#define | M0_UT_ASSERT(a) m0_ut_assertimpl((a), #a, __FILE__, __LINE__, __func__) |
#define | M0_UT_ENTER(...) |
#define | M0_UT_LOG(...) |
#define | M0_UT_RETURN(...) |
Enumerations | |
enum | { M0_UT_SUITES_MAX = 1024 } |
enum | { M0_LEVEL_UT_PREPARE, M0_LEVEL_UT_KLUDGE, M0_LEVEL_UT_READY } |
enum | { M0_LEVEL_UT_SUITE_READY } |
enum | { M0_UT_SUITE_TESTS_MAX = 128 } |
Functions | |
M0_INTERNAL void | m0_ut_backend_init (struct m0_be_ut_backend *be, struct m0_be_ut_seg *seg) |
M0_INTERNAL void | m0_ut_backend_fini (struct m0_be_ut_backend *be, struct m0_be_ut_seg *seg) |
M0_INTERNAL void | m0_ut_be_tx_begin (struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be, struct m0_be_tx_credit *cred) |
M0_INTERNAL void | m0_ut_be_tx_begin2 (struct m0_be_tx *tx, struct m0_be_ut_backend *ut_be, struct m0_be_tx_credit *cred, m0_bcount_t payload_cred) |
M0_INTERNAL void | m0_ut_be_tx_end (struct m0_be_tx *tx) |
M0_INTERNAL void | m0_ut_random_shuffle (uint64_t *arr, uint64_t nr, uint64_t *seed) |
M0_INTERNAL void | m0_ut_random_arr_with_sum (uint64_t *arr, uint64_t nr, uint64_t sum, uint64_t *seed) |
static struct m0_module * | ut_module_create (struct m0 *instance) |
static int | level_ut_enter (struct m0_module *module) |
static void | level_ut_leave (struct m0_module *module) |
M0_INTERNAL void | m0_ut_suite_module_setup (struct m0_ut_suite *ts, struct m0 *instance) |
M0_INTERNAL void | m0_ut_threads_start (struct m0_ut_threads_descr *descr, int thread_nr, void *param_array, size_t param_size) |
M0_INTERNAL void | m0_ut_threads_stop (struct m0_ut_threads_descr *descr) |
static int | test_suites_enable (const struct m0_ut_module *m) |
static struct m0_ut_module * | ut_module (void) |
M0_INTERNAL int | m0_ut_init (struct m0 *instance) |
M0_INTERNAL void | m0_ut_fini (void) |
M0_INTERNAL void | m0_ut_add (struct m0_ut_module *m, struct m0_ut_suite *ts, bool enable) |
static struct m0_ut_suite * | suite_find (const struct m0_ut_module *m, const char *name) |
static struct m0_ut * | get_test_by_name (const struct m0_ut_module *m, const char *s_name, const char *t_name) |
static void | set_enabled_flag_for (const struct m0_ut_module *m, const char *s_name, const char *t_name, bool value) |
static bool | exists (const struct m0_ut_module *m, const char *s_name, const char *t_name) |
static int | test_add (struct m0_list *list, const char *suite, const char *test, const struct m0_ut_module *m) |
static int | test_list_populate (struct m0_list *list, const char *str, const struct m0_ut_module *m) |
static void | test_list_destroy (struct m0_list *list) |
static int | test_list_create (struct m0_list *list, const struct m0_ut_module *m) |
static const char * | skipspaces (const char *str) |
static void | check_all_fi_disabled (void) |
static void | run_test (const struct m0_ut *test, size_t max_name_len) |
static int | run_suite (const struct m0_ut_suite *suite, int max_name_len) |
static int | max_test_name_len (const struct m0_ut_suite **suites, unsigned nr) |
static int | tests_run_all (const struct m0_ut_module *m) |
M0_INTERNAL int | m0_ut_run (void) |
M0_INTERNAL void | m0_ut_list (bool with_tests, bool yaml_output) |
static void | ut_owners_print (const struct m0_ut_suite *suite) |
M0_INTERNAL void | m0_ut_list_owners (void) |
M0_INTERNAL bool | m0_ut_assertimpl (bool c, const char *str_c, const char *file, int lno, const char *func) |
M0_INTERNAL bool | m0_ut_small_credits (void) |
static int | cmp (const struct m0_ut_suite **s0, const struct m0_ut_suite **s1) |
M0_INTERNAL void | m0_ut_shuffle (unsigned seed) |
M0_INTERNAL void | m0_ut_start_from (const char *suite) |
M0_INTERNAL int | m0_ut_enable_fault_point (const char *str) |
M0_INTERNAL int | m0_ut_enable_fault_points_from_file (const char *file_name) |
M0_INTERNAL void | m0_stream_redirect (FILE *stream, const char *path, struct m0_ut_redirect *redir) |
M0_INTERNAL void | m0_stream_restore (const struct m0_ut_redirect *redir) |
M0_INTERNAL bool | m0_error_mesg_match (FILE *fp, const char *mesg) |
int | m0_ut_sandbox_init (const char *dir) |
void | m0_ut_sandbox_fini (const char *dir, bool keep) |
Variables | |
const struct m0_module_type | m0_ut_module_type |
static const struct m0_modlev | levels_ut [] |
static const struct m0_modlev | levels_ut_suite [] |
const struct m0_module_type | m0_ut_module_type |
struct m0_fid | g_process_fid = M0_FID_TINIT('r', 1, 1) |
M0_EXTERN struct m0_fid | g_process_fid |
Common unit test library.
Multithreaded UT helpers.
The intent of this library is to include all code, which could be potentially useful for several UTs and thus can be shared, avoiding duplication of similar code.
BE helper functions that unit tests of other (non-BE) Motr subsystems are allowed to use.
The API declared in be/ut/helper.h is supposed to be used by BE unit tests only. The UTs of other subsystems should not #include that file (though they do, hee hee hee).
#define M0_UT_ASSERT | ( | a | ) | m0_ut_assertimpl((a), #a, __FILE__, __LINE__, __func__) |
#define M0_UT_CONF_PROFILE_BAD "<0x7000000000000000:999>" /* non-existent */ |
#define M0_UT_PATH | ( | name | ) | M0_SRC_PATH("ut/" name) |
#define M0_UT_THREADS_DEFINE | ( | name, | |
thread_func | |||
) |
#define M0_UT_THREADS_START | ( | name, | |
thread_nr, | |||
param_array | |||
) |
#define M0_UT_THREADS_STOP | ( | name | ) | m0_ut_threads_stop(&ut_threads_descr_##name) |
anonymous enum |
Levels of m0_ut_module.
anonymous enum |
Levels of m0_ut_suite module.
Enumerator | |
---|---|
M0_LEVEL_UT_SUITE_READY |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
M0_INTERNAL bool m0_error_mesg_match | ( | FILE * | fp, |
const char * | mesg | ||
) |
M0_INTERNAL void m0_stream_redirect | ( | FILE * | stream, |
const char * | path, | ||
struct m0_ut_redirect * | redir | ||
) |
M0_INTERNAL void m0_stream_restore | ( | const struct m0_ut_redirect * | redir | ) |
Restores standard stream from file descriptor and stream position, which were saved earlier by m0_stream_redirect().
Definition at line 107 of file ut.c.
M0_INTERNAL void m0_ut_add | ( | struct m0_ut_module * | m, |
struct m0_ut_suite * | ts, | ||
bool | enable | ||
) |
M0_INTERNAL bool m0_ut_assertimpl | ( | bool | c, |
const char * | str_c, | ||
const char * | file, | ||
int | lno, | ||
const char * | func | ||
) |
Implements UT assert logic in the kernel.
c | the result of the boolean condition, evaluated by caller |
lno | line number of the assertion, eg LINE |
str_c | string representation of the condition, c |
file | path of the file, eg FILE |
func | name of the function which triggered assertion, eg func |
panic | flag, which controls whether this function should call m0_panic() or just print error message and continue |
Definition at line 627 of file ut.c.
M0_INTERNAL void m0_ut_backend_fini | ( | struct m0_be_ut_backend * | be, |
struct m0_be_ut_seg * | seg | ||
) |
M0_INTERNAL void m0_ut_backend_init | ( | struct m0_be_ut_backend * | be, |
struct m0_be_ut_seg * | seg | ||
) |
M0_INTERNAL void m0_ut_be_tx_begin | ( | struct m0_be_tx * | tx, |
struct m0_be_ut_backend * | ut_be, | ||
struct m0_be_tx_credit * | cred | ||
) |
M0_INTERNAL void m0_ut_be_tx_begin2 | ( | struct m0_be_tx * | tx, |
struct m0_be_ut_backend * | ut_be, | ||
struct m0_be_tx_credit * | cred, | ||
m0_bcount_t | payload_cred | ||
) |
M0_INTERNAL void m0_ut_be_tx_end | ( | struct m0_be_tx * | tx | ) |
M0_INTERNAL int m0_ut_enable_fault_point | ( | const char * | str | ) |
Parses fault point definitions from command line argument and enables them.
The input string should be in format:
func:tag:type[:integer[:integer]][,func:tag:type[:integer[:integer]]]
M0_INTERNAL int m0_ut_enable_fault_points_from_file | ( | const char * | file_name | ) |
Parses fault point definitions from a yaml file and enables them.
Each FP is described by a yaml mapping with the following keys:
func - a name of the target function, which contains fault point tag - a fault point tag type - a fault point type, possible values are: always, oneshot, random, off_n_on_m p - data for 'random' fault point n - data for 'off_n_on_m' fault point m - data for 'off_n_on_m' fault point
An example of yaml file:
* --- * * - func: test_func1 * tag: test_tag1 * type: random * p: 50 * * - func: test_func2 * tag: test_tag2 * type: oneshot * * # yaml mappings could be specified in a short form as well * - { func: test_func3, tag: test_tag3, type: off_n_on_m, n: 3, m: 1 } * *
void m0_ut_fini | ( | void | ) |
int m0_ut_init | ( | struct m0 * | instance | ) |
M0_INTERNAL void m0_ut_list | ( | bool | with_tests, |
bool | yaml_output | ||
) |
M0_INTERNAL void m0_ut_list_owners | ( | void | ) |
M0_INTERNAL void m0_ut_random_arr_with_sum | ( | uint64_t * | arr, |
uint64_t | nr, | ||
uint64_t | sum, | ||
uint64_t * | seed | ||
) |
M0_INTERNAL void m0_ut_random_shuffle | ( | uint64_t * | arr, |
uint64_t | nr, | ||
uint64_t * | seed | ||
) |
M0_INTERNAL int m0_ut_run | ( | void | ) |
void m0_ut_sandbox_fini | ( | const char * | dir, |
bool | keep | ||
) |
int m0_ut_sandbox_init | ( | const char * | dir | ) |
M0_INTERNAL void m0_ut_shuffle | ( | unsigned | seed | ) |
M0_INTERNAL bool m0_ut_small_credits | ( | void | ) |
M0_INTERNAL void m0_ut_start_from | ( | const char * | suite | ) |
M0_INTERNAL void m0_ut_suite_module_setup | ( | struct m0_ut_suite * | ts, |
struct m0 * | instance | ||
) |
M0_INTERNAL void m0_ut_threads_start | ( | struct m0_ut_threads_descr * | descr, |
int | thread_nr, | ||
void * | param_array, | ||
size_t | param_size | ||
) |
M0_INTERNAL void m0_ut_threads_stop | ( | struct m0_ut_threads_descr * | descr | ) |
|
static |
|
static |
|
static |
|
static |
|
inlinestatic |
|
static |
|
static |
|
static |
|
static |
|
static |
Populates a list of ut_entry elements by parsing input string, which should conform with the format 'suite[:test][,suite[:test]]'.
str | input string. |
list | initialised and empty m0_list. |
Definition at line 233 of file ut.c.
|
static |
|
static |
|
static |
|
static |
struct m0_fid g_process_fid = M0_FID_TINIT('r', 1, 1) |
|
static |
|
static |
const struct m0_module_type m0_ut_module_type |
const struct m0_module_type m0_ut_module_type |