Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
threadpool unit tests More...
#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/lock.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/test.h"
#include "asterisk/threadpool.h"
Go to the source code of this file.
Data Structures | |
struct | complex_task_data |
struct | simple_task_data |
struct | test_listener_data |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (threadpool_auto_increment) | |
AST_TEST_DEFINE (threadpool_initial_threads) | |
AST_TEST_DEFINE (threadpool_max_size) | |
AST_TEST_DEFINE (threadpool_more_destruction) | |
AST_TEST_DEFINE (threadpool_one_task_one_thread) | |
AST_TEST_DEFINE (threadpool_one_thread_multiple_tasks) | |
AST_TEST_DEFINE (threadpool_one_thread_one_task) | |
AST_TEST_DEFINE (threadpool_push) | |
AST_TEST_DEFINE (threadpool_reactivation) | |
AST_TEST_DEFINE (threadpool_serializer) | |
AST_TEST_DEFINE (threadpool_serializer_dupe) | |
AST_TEST_DEFINE (threadpool_task_distribution) | |
AST_TEST_DEFINE (threadpool_thread_creation) | |
AST_TEST_DEFINE (threadpool_thread_destruction) | |
AST_TEST_DEFINE (threadpool_thread_timeout) | |
AST_TEST_DEFINE (threadpool_thread_timeout_thrash) | |
static int | complex_task (void *data) |
static struct complex_task_data * | complex_task_data_alloc (void) |
static void | complex_task_data_free (struct complex_task_data *ctd) |
static int | has_complex_started (struct complex_task_data *ctd) |
static enum ast_test_result_state | listener_check (struct ast_test *test, struct ast_threadpool_listener *listener, int task_pushed, int was_empty, int num_tasks, int num_active, int num_idle, int empty_notice) |
static int | load_module (void) |
static void | poke_worker (struct complex_task_data *ctd) |
static int | simple_task (void *data) |
static struct simple_task_data * | simple_task_data_alloc (void) |
static void | simple_task_data_free (struct simple_task_data *std) |
static struct test_listener_data * | test_alloc (void) |
static void | test_emptied (struct ast_threadpool *pool, struct ast_threadpool_listener *listener) |
static void | test_shutdown (struct ast_threadpool_listener *listener) |
static void | test_state_changed (struct ast_threadpool *pool, struct ast_threadpool_listener *listener, int active_threads, int idle_threads) |
static void | test_task_pushed (struct ast_threadpool *pool, struct ast_threadpool_listener *listener, int was_empty) |
static int | unload_module (void) |
static enum ast_test_result_state | wait_for_completion (struct ast_test *test, struct simple_task_data *std) |
static enum ast_test_result_state | wait_for_complex_completion (struct complex_task_data *ctd) |
static int | wait_for_complex_start (struct complex_task_data *ctd) |
static enum ast_test_result_state | wait_for_empty_notice (struct ast_test *test, struct test_listener_data *tld) |
static void | wait_for_task_pushed (struct ast_threadpool_listener *listener) |
static enum ast_test_result_state | wait_until_thread_state (struct ast_test *test, struct test_listener_data *tld, int num_active, int num_idle) |
static enum ast_test_result_state | wait_until_thread_state_task_pushed (struct ast_test *test, struct test_listener_data *tld, int num_active, int num_idle, int num_tasks) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "threadpool test module" , .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 |
static const struct ast_threadpool_listener_callbacks | test_callbacks |
threadpool unit tests
Definition in file test_threadpool.c.
|
static |
Definition at line 1843 of file test_threadpool.c.
|
static |
Definition at line 1843 of file test_threadpool.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1843 of file test_threadpool.c.
AST_TEST_DEFINE | ( | threadpool_auto_increment | ) |
Definition at line 989 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), wait_for_empty_notice(), wait_until_thread_state(), and wait_until_thread_state_task_pushed().
AST_TEST_DEFINE | ( | threadpool_initial_threads | ) |
Definition at line 350 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), NULL, options, test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_max_size | ) |
Definition at line 1117 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_more_destruction | ) |
Definition at line 1514 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), complex_task(), complex_task_data_alloc(), complex_task_data_free(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, poke_worker(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_complex_completion(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_one_task_one_thread | ) |
Definition at line 679 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), wait_for_empty_notice(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_one_thread_multiple_tasks | ) |
Definition at line 848 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), wait_for_empty_notice(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_one_thread_one_task | ) |
Definition at line 763 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), wait_for_empty_notice(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_push | ) |
Definition at line 288 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, and wait_for_task_pushed().
AST_TEST_DEFINE | ( | threadpool_reactivation | ) |
Definition at line 1189 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), wait_for_empty_notice(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_serializer | ) |
Definition at line 1630 of file test_threadpool.c.
References ast_taskprocessor_push(), ast_taskprocessor_unreference(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_threadpool_create(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_serializer(), ast_threadpool_shutdown(), complex_task(), complex_task_data_alloc(), complex_task_data_free(), end, has_complex_started(), sip_to_pjsip::info(), NULL, options, poke_worker(), TEST_EXECUTE, TEST_INIT, wait_for_complex_completion(), and wait_for_complex_start().
AST_TEST_DEFINE | ( | threadpool_serializer_dupe | ) |
Definition at line 1747 of file test_threadpool.c.
References ast_taskprocessor_unreference(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_threadpool_create(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_serializer(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), NULL, options, TEST_EXECUTE, and TEST_INIT.
AST_TEST_DEFINE | ( | threadpool_task_distribution | ) |
Definition at line 1415 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), complex_task(), complex_task_data_alloc(), complex_task_data_free(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, poke_worker(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_complex_completion(), and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_thread_creation | ) |
Definition at line 402 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), NULL, options, test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_thread_destruction | ) |
Definition at line 457 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_thread_timeout | ) |
Definition at line 521 of file test_threadpool.c.
References ao2_cleanup, ast_free, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_set_size(), ast_threadpool_shutdown(), end, sip_to_pjsip::info(), listener(), listener_check(), NULL, options, test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, and wait_until_thread_state().
AST_TEST_DEFINE | ( | threadpool_thread_timeout_thrash | ) |
Definition at line 588 of file test_threadpool.c.
References ao2_cleanup, ast_cond_timedwait, ast_free, ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_NOT_RUN, ast_threadpool_create(), ast_threadpool_listener_alloc(), AST_THREADPOOL_OPTIONS_VERSION, ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), ast_tvnow(), test_listener_data::cond, end, sip_to_pjsip::info(), listener(), listener_check(), test_listener_data::lock, NULL, options, simple_task(), simple_task_data_alloc(), simple_task_data_free(), test_alloc(), test_callbacks, TEST_EXECUTE, TEST_INIT, wait_for_completion(), and wait_until_thread_state().
|
static |
Definition at line 1334 of file test_threadpool.c.
References ast_cond_signal, ast_cond_wait, complex_task_data::continue_task, lock, complex_task_data::lock, complex_task_data::notify_cond, SCOPED_MUTEX, complex_task_data::stall_cond, complex_task_data::task_executed, and complex_task_data::task_started.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1308 of file test_threadpool.c.
References ast_calloc, ast_cond_init, ast_mutex_init, complex_task_data::lock, complex_task_data::notify_cond, NULL, and complex_task_data::stall_cond.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1321 of file test_threadpool.c.
References ast_cond_destroy, ast_free, ast_mutex_destroy, complex_task_data::lock, complex_task_data::notify_cond, and complex_task_data::stall_cond.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1375 of file test_threadpool.c.
References ast_cond_timedwait, ast_tvnow(), end, lock, complex_task_data::lock, complex_task_data::notify_cond, SCOPED_MUTEX, and complex_task_data::task_started.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 241 of file test_threadpool.c.
References AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_threadpool_listener_get_user_data(), test_listener_data::empty_notice, listener(), test_listener_data::num_active, test_listener_data::num_idle, test_listener_data::num_tasks, test_listener_data::task_pushed, and test_listener_data::was_empty.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1822 of file test_threadpool.c.
References AST_MODULE_LOAD_SUCCESS.
|
static |
Definition at line 1350 of file test_threadpool.c.
References ast_cond_signal, complex_task_data::continue_task, lock, complex_task_data::lock, SCOPED_MUTEX, and complex_task_data::stall_cond.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 142 of file test_threadpool.c.
References ast_cond_signal, simple_task_data::cond, lock, simple_task_data::lock, SCOPED_MUTEX, and simple_task_data::task_executed.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 118 of file test_threadpool.c.
References ast_calloc, ast_cond_init, ast_mutex_init, simple_task_data::cond, simple_task_data::lock, and NULL.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 130 of file test_threadpool.c.
References ast_cond_destroy, ast_free, ast_mutex_destroy, simple_task_data::cond, and simple_task_data::lock.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 53 of file test_threadpool.c.
References ast_calloc, ast_cond_init, ast_mutex_init, test_listener_data::cond, test_listener_data::lock, and NULL.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 89 of file test_threadpool.c.
References ast_cond_signal, ast_threadpool_listener_get_user_data(), test_listener_data::cond, test_listener_data::empty_notice, listener(), lock, test_listener_data::lock, and SCOPED_MUTEX.
|
static |
Definition at line 98 of file test_threadpool.c.
References ast_cond_destroy, ast_mutex_destroy, ast_threadpool_listener_get_user_data(), test_listener_data::cond, listener(), and test_listener_data::lock.
|
static |
Definition at line 64 of file test_threadpool.c.
References ast_cond_signal, ast_log, ast_threadpool_listener_get_user_data(), test_listener_data::cond, listener(), lock, test_listener_data::lock, LOG_NOTICE, test_listener_data::num_active, test_listener_data::num_idle, and SCOPED_MUTEX.
|
static |
Definition at line 77 of file test_threadpool.c.
References ast_cond_signal, ast_threadpool_listener_get_user_data(), test_listener_data::cond, listener(), lock, test_listener_data::lock, test_listener_data::num_tasks, SCOPED_MUTEX, test_listener_data::task_pushed, and test_listener_data::was_empty.
|
static |
Definition at line 1801 of file test_threadpool.c.
|
static |
Definition at line 194 of file test_threadpool.c.
References ast_cond_timedwait, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_tvnow(), simple_task_data::cond, end, lock, simple_task_data::lock, SCOPED_MUTEX, and simple_task_data::task_executed.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1393 of file test_threadpool.c.
References ast_cond_timedwait, AST_TEST_FAIL, AST_TEST_PASS, ast_tvnow(), end, lock, complex_task_data::lock, complex_task_data::notify_cond, SCOPED_MUTEX, and complex_task_data::task_executed.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1357 of file test_threadpool.c.
References ast_cond_timedwait, ast_tvnow(), end, lock, complex_task_data::lock, complex_task_data::notify_cond, SCOPED_MUTEX, and complex_task_data::task_started.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 217 of file test_threadpool.c.
References ast_cond_timedwait, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_tvnow(), test_listener_data::cond, test_listener_data::empty_notice, end, lock, test_listener_data::lock, and SCOPED_MUTEX.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 177 of file test_threadpool.c.
References ast_cond_timedwait, ast_threadpool_listener_get_user_data(), ast_tvnow(), test_listener_data::cond, end, listener(), lock, test_listener_data::lock, SCOPED_MUTEX, and test_listener_data::task_pushed.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 151 of file test_threadpool.c.
References ast_cond_timedwait, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_tvnow(), test_listener_data::cond, end, lock, test_listener_data::lock, test_listener_data::num_active, test_listener_data::num_idle, and SCOPED_MUTEX.
Referenced by AST_TEST_DEFINE(), and wait_until_thread_state_task_pushed().
|
static |
Definition at line 954 of file test_threadpool.c.
References ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_PASS, ast_test_status_update, ast_tvnow(), test_listener_data::cond, end, test_listener_data::lock, test_listener_data::num_tasks, and wait_until_thread_state().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 1843 of file test_threadpool.c.
|
static |
Definition at line 1843 of file test_threadpool.c.
|
static |
Definition at line 105 of file test_threadpool.c.
Referenced by AST_TEST_DEFINE().