Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/astobj2.h"
Go to the source code of this file.
Data Structures | |
struct | test_obj |
Macros | |
#define | ITERATIONS 100000 |
#define | OBJS 73 |
Enumerations | |
enum | test_container_type { TEST_CONTAINER_LIST , TEST_CONTAINER_HASH , TEST_CONTAINER_RBTREE } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | all_but_one_cb (void *obj, void *arg, int flag) |
static | AO2_GLOBAL_OBJ_STATIC (astobj2_holder) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (astobj2_test_1) | |
AST_TEST_DEFINE (astobj2_test_2) | |
AST_TEST_DEFINE (astobj2_test_3) | |
AST_TEST_DEFINE (astobj2_test_4) | |
AST_TEST_DEFINE (astobj2_test_perf) | |
static int | astobj2_test_1_helper (int tst_num, enum test_container_type type, int use_sort, unsigned int lim, struct ast_test *test) |
static int | increment_cb (void *obj, void *arg, int flag) |
static int | insert_test_duplicates (struct ao2_container *container, int *destroy_counter, int number, const char *prefix, struct ast_test *test) |
static int | insert_test_vector (struct ao2_container *container, int *destroy_counter, const int *vector, int count, const char *prefix, struct ast_test *test) |
static int | load_module (void) |
static int | multiple_cb (void *obj, void *arg, int flag) |
static int | test_ao2_callback_traversal (int res, struct ao2_container *container, enum search_flags flags, ao2_callback_fn *cmp_fn, void *arg, const int *vector, int count, const char *prefix, struct ast_test *test) |
static int | test_ao2_find_w_no_flags (int res, struct ao2_container *look_in, int limit, struct ast_test *test) |
static int | test_ao2_find_w_OBJ_KEY (int res, struct ao2_container *look_in, int limit, struct ast_test *test) |
static int | test_ao2_find_w_OBJ_PARTIAL_KEY (int res, struct ao2_container *look_in, int limit, struct ast_test *test) |
static int | test_ao2_find_w_OBJ_POINTER (int res, struct ao2_container *look_in, int limit, struct ast_test *test) |
static int | test_ao2_iteration (int res, struct ao2_container *container, enum ao2_iterator_flags flags, const int *vector, int count, const char *prefix, struct ast_test *test) |
static int | test_cmp_cb (void *obj, void *arg, int flags) |
static const char * | test_container2str (enum test_container_type type) |
static int | test_container_clone (int res, struct ao2_container *orig, struct ast_test *test) |
static int | test_expected_duplicates (int res, struct ao2_container *container, enum search_flags flags, int number, const int *vector, int count, const char *prefix, struct ast_test *test) |
static int | test_hash_cb (const void *obj, const int flags) |
static struct ao2_container * | test_make_nonsorted (enum test_container_type type, int options) |
static struct ao2_container * | test_make_sorted (enum test_container_type type, int options) |
static void | test_obj_destructor (void *v_obj) |
static enum ast_test_result_state | test_performance (struct ast_test *test, enum test_container_type type, unsigned int copt) |
static int | test_sort_cb (const void *obj_left, const void *obj_right, int flags) |
static int | test_traversal_nonsorted (int res, int tst_num, enum test_container_type type, struct ast_test *test) |
static int | test_traversal_sorted (int res, int tst_num, enum test_container_type type, struct ast_test *test) |
static enum ast_test_result_state | testloop (struct ast_test *test, enum test_container_type type, int copt, int iterations) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "ASTOBJ2 Unit Tests" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
int | partial_key_match_range |
astobj2 test module
Definition in file test_astobj2.c.
#define ITERATIONS 100000 |
#define OBJS 73 |
enum test_container_type |
Enumerator | |
---|---|
TEST_CONTAINER_LIST | |
TEST_CONTAINER_HASH | |
TEST_CONTAINER_RBTREE |
Definition at line 41 of file test_astobj2.c.
|
static |
Definition at line 2072 of file test_astobj2.c.
|
static |
Definition at line 2072 of file test_astobj2.c.
|
static |
Definition at line 104 of file test_astobj2.c.
References CMP_MATCH, and test_obj::i.
Referenced by astobj2_test_1_helper().
|
static |
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 2072 of file test_astobj2.c.
AST_TEST_DEFINE | ( | astobj2_test_1 | ) |
Definition at line 646 of file test_astobj2.c.
References AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, astobj2_test_1_helper(), sip_to_pjsip::info(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | astobj2_test_2 | ) |
Definition at line 688 of file test_astobj2.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ao2_container_check(), ao2_container_count(), ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_link, ao2_ref, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, c, cleanup(), test_obj::destructor_count, test_obj::i, sip_to_pjsip::info(), NULL, OBJ_POINTER, test_cmp_cb(), TEST_EXECUTE, TEST_INIT, and test_obj_destructor().
AST_TEST_DEFINE | ( | astobj2_test_3 | ) |
Definition at line 825 of file test_astobj2.c.
References ao2_alloc, ao2_ref, ao2_t_global_obj_ref, ao2_t_global_obj_release, ao2_t_global_obj_replace, ao2_t_global_obj_replace_unref, ao2_t_ref, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, cleanup(), test_obj::destructor_count, test_obj::i, sip_to_pjsip::info(), NULL, TEST_EXECUTE, TEST_INIT, and test_obj_destructor().
AST_TEST_DEFINE | ( | astobj2_test_4 | ) |
Definition at line 1896 of file test_astobj2.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, TEST_EXECUTE, TEST_INIT, test_traversal_nonsorted(), and test_traversal_sorted().
AST_TEST_DEFINE | ( | astobj2_test_perf | ) |
The number of iteration of testloop to be performed.
Definition at line 2011 of file test_astobj2.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), ITERATIONS, TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, TEST_EXECUTE, TEST_INIT, and testloop().
|
static |
Definition at line 419 of file test_astobj2.c.
References all_but_one_cb(), AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_check(), ao2_container_count(), ao2_container_dump(), ao2_container_stats(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_link, ao2_t_alloc, ao2_t_callback, ao2_t_container_alloc_hash, ao2_t_container_alloc_list, ao2_t_container_alloc_rbtree, ao2_t_iterator_next, ao2_t_link, ao2_t_ref, ao2_t_unlink, ast_random(), ast_test_debug, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, cleanup(), test_obj::destructor_count, test_obj::i, increment_cb(), multiple_cb(), NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, test_ao2_find_w_no_flags(), test_ao2_find_w_OBJ_KEY(), test_ao2_find_w_OBJ_PARTIAL_KEY(), test_ao2_find_w_OBJ_POINTER(), test_cmp_cb(), test_container2str(), test_container_clone(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_hash_cb(), test_obj_destructor(), test_sort_cb(), and type.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 96 of file test_astobj2.c.
References test_obj::i.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 1090 of file test_astobj2.c.
References ao2_alloc, ao2_container_check(), ao2_find, ao2_link, ao2_t_ref, ast_test_status_update, container, test_obj::destructor_count, test_obj::dup_number, test_obj::i, NULL, OBJ_KEY, prefix, and test_obj_destructor().
Referenced by test_traversal_sorted().
|
static |
Definition at line 1038 of file test_astobj2.c.
References ao2_alloc, ao2_container_check(), ao2_container_count(), ao2_link, ao2_t_ref, ast_test_status_update, container, test_obj::destructor_count, test_obj::i, prefix, and test_obj_destructor().
Referenced by test_traversal_nonsorted(), and test_traversal_sorted().
|
static |
Definition at line 2062 of file test_astobj2.c.
References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.
|
static |
Definition at line 111 of file test_astobj2.c.
References CMP_MATCH, and test_obj::i.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 1230 of file test_astobj2.c.
References ao2_callback, ao2_iterator_destroy(), ao2_iterator_next, ao2_ref, AST_TEST_FAIL, ast_test_status_update, container, test_obj::i, OBJ_MULTIPLE, and prefix.
Referenced by test_traversal_nonsorted(), and test_traversal_sorted().
|
static |
Definition at line 276 of file test_astobj2.c.
References ao2_find, ao2_t_ref, ast_random(), AST_TEST_FAIL, ast_test_status_update, and test_obj::i.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 354 of file test_astobj2.c.
References ao2_find, ao2_t_ref, ast_random(), AST_TEST_FAIL, ast_test_status_update, test_obj::i, and OBJ_KEY.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 391 of file test_astobj2.c.
References ao2_find, ao2_t_ref, ast_random(), AST_TEST_FAIL, ast_test_status_update, test_obj::i, OBJ_PARTIAL_KEY, and partial_key_match_range.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 315 of file test_astobj2.c.
References ao2_find, ao2_t_ref, ast_random(), AST_TEST_FAIL, ast_test_status_update, test_obj::i, and OBJ_POINTER.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 1169 of file test_astobj2.c.
References ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, AST_TEST_FAIL, ast_test_status_update, container, test_obj::i, and prefix.
Referenced by test_traversal_nonsorted(), and test_traversal_sorted().
|
static |
Definition at line 119 of file test_astobj2.c.
References CMP_MATCH, test_obj::i, OBJ_KEY, OBJ_PARTIAL_KEY, and partial_key_match_range.
Referenced by AST_TEST_DEFINE(), astobj2_test_1_helper(), test_make_nonsorted(), test_make_sorted(), test_performance(), test_traversal_nonsorted(), and test_traversal_sorted().
|
static |
Definition at line 56 of file test_astobj2.c.
References TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, and type.
Referenced by astobj2_test_1_helper(), test_traversal_nonsorted(), test_traversal_sorted(), and testloop().
|
static |
Definition at line 214 of file test_astobj2.c.
References ao2_container_check(), ao2_container_clone, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_match_by_addr(), ao2_t_callback, ao2_t_iterator_next, ao2_t_ref, AST_TEST_FAIL, ast_test_status_update, OBJ_POINTER, and OBJ_UNLINK.
Referenced by astobj2_test_1_helper().
|
static |
Definition at line 1287 of file test_astobj2.c.
References ao2_find, ao2_iterator_destroy(), ao2_iterator_next, ao2_ref, AST_TEST_FAIL, ast_test_status_update, container, test_obj::dup_number, test_obj::i, OBJ_KEY, OBJ_MULTIPLE, and prefix.
Referenced by test_traversal_sorted().
|
static |
Definition at line 139 of file test_astobj2.c.
References test_obj::i, OBJ_KEY, and OBJ_PARTIAL_KEY.
Referenced by astobj2_test_1_helper(), test_make_nonsorted(), test_make_sorted(), and test_performance().
|
static |
Definition at line 965 of file test_astobj2.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ao2_container_alloc_list, container, NULL, options, test_cmp_cb(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_hash_cb(), and type.
Referenced by test_traversal_nonsorted().
|
static |
Definition at line 998 of file test_astobj2.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_t_container_alloc_hash, ao2_t_container_alloc_list, ao2_t_container_alloc_rbtree, container, NULL, options, test_cmp_cb(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_hash_cb(), test_sort_cb(), and type.
Referenced by test_traversal_sorted().
|
static |
Definition at line 87 of file test_astobj2.c.
References test_obj::destructor_count.
Referenced by AST_TEST_DEFINE(), astobj2_test_1_helper(), insert_test_duplicates(), insert_test_vector(), and test_performance().
|
static |
The number of objects inserted and searched for in the container under test.
Definition at line 1923 of file test_astobj2.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_cleanup, ao2_container_alloc_hash, ao2_container_alloc_list, ao2_container_alloc_rbtree, ao2_find, ao2_link, ao2_ref, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, test_obj::i, NULL, OBJ_KEY, OBJS, test_cmp_cb(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_hash_cb(), test_obj_destructor(), test_sort_cb(), and type.
Referenced by testloop().
|
static |
Definition at line 158 of file test_astobj2.c.
References test_obj::i, OBJ_KEY, OBJ_PARTIAL_KEY, and partial_key_match_range.
Referenced by astobj2_test_1_helper(), test_make_sorted(), and test_performance().
|
static |
Container object insertion vector.
Container object insertion vector reversed.
Definition at line 1346 of file test_astobj2.c.
References AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN, AO2_ITERATOR_DESCENDING, ao2_t_ref, ARRAY_LEN, AST_TEST_FAIL, ast_test_status_update, insert_test_vector(), NULL, OBJ_ORDER_ASCENDING, OBJ_ORDER_DESCENDING, OBJ_PARTIAL_KEY, partial_key_match_range, test_ao2_callback_traversal(), test_ao2_iteration(), test_cmp_cb(), test_container2str(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_make_nonsorted(), and type.
Referenced by AST_TEST_DEFINE().
|
static |
Container object insertion vector.
Container forward traversal/iteration.
Container backward traversal/iteration.
Definition at line 1552 of file test_astobj2.c.
References AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN, ao2_container_dump(), ao2_container_stats(), AO2_ITERATOR_DESCENDING, ao2_t_ref, ARRAY_LEN, ast_test_debug, AST_TEST_FAIL, ast_test_status_update, insert_test_duplicates(), insert_test_vector(), NULL, OBJ_ORDER_ASCENDING, OBJ_ORDER_DESCENDING, OBJ_PARTIAL_KEY, partial_key_match_range, test_ao2_callback_traversal(), test_ao2_iteration(), test_cmp_cb(), test_container2str(), TEST_CONTAINER_HASH, TEST_CONTAINER_LIST, TEST_CONTAINER_RBTREE, test_expected_duplicates(), test_make_sorted(), and type.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1990 of file test_astobj2.c.
References AST_TEST_PASS, ast_test_status_update, ast_tvdiff_ms(), ast_tvnow(), test_obj::i, test_container2str(), test_performance(), and type.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 2052 of file test_astobj2.c.
References AST_TEST_UNREGISTER.
|
static |
Definition at line 2072 of file test_astobj2.c.
|
static |
Definition at line 2072 of file test_astobj2.c.
int partial_key_match_range |
Partial search key +/- matching range.
Definition at line 85 of file test_astobj2.c.
Referenced by test_ao2_find_w_OBJ_PARTIAL_KEY(), test_cmp_cb(), test_sort_cb(), test_traversal_nonsorted(), and test_traversal_sorted().