Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include "asterisk/test.h"
#include "asterisk/module.h"
#include "asterisk/dns_core.h"
#include "asterisk/dns_resolver.h"
#include "asterisk/dns_recurring.h"
#include "asterisk/dns_internal.h"
Go to the source code of this file.
Data Structures | |
struct | recurring_data |
Macros | |
#define | DNS_ANSWER "Yes sirree" |
#define | DNS_ANSWER_SIZE strlen(DNS_ANSWER) |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (recurring_query) | |
AST_TEST_DEFINE (recurring_query_cancel_between) | |
AST_TEST_DEFINE (recurring_query_cancel_during) | |
AST_TEST_DEFINE (recurring_query_off_nominal) | |
static void | async_callback (const struct ast_dns_query *query) |
static int | fail_resolve (struct ast_dns_query *query) |
static int | load_module (void) |
static int | recurring_cancel (struct ast_dns_query *query) |
Resolver's cancel() method. More... | |
static struct recurring_data * | recurring_data_alloc (void) |
static void | recurring_data_destructor (void *obj) |
static int | recurring_resolve (struct ast_dns_query *query) |
Resolver's resolve() method. More... | |
static void * | resolution_thread (void *dns_query) |
Thread that performs asynchronous resolution. More... | |
static void | stub_callback (const struct ast_dns_query *query) |
static int | stub_cancel (struct ast_dns_query *query) |
static int | unload_module (void) |
static int | wait_for_resolution (struct ast_test *test, struct recurring_data *rdata, int expected_lapse, int num_resolves, int num_completed, int canceled) |
Wait for a successful resolution to complete. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Recurring DNS query 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 |
static struct ast_dns_resolver | recurring_resolver |
#define DNS_ANSWER "Yes sirree" |
Definition at line 80 of file test_dns_recurring.c.
#define DNS_ANSWER_SIZE strlen(DNS_ANSWER) |
Definition at line 81 of file test_dns_recurring.c.
|
static |
Definition at line 647 of file test_dns_recurring.c.
|
static |
Definition at line 647 of file test_dns_recurring.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 647 of file test_dns_recurring.c.
AST_TEST_DEFINE | ( | recurring_query | ) |
Definition at line 269 of file test_dns_recurring.c.
References ao2_cleanup, ast_dns_resolve_recurring(), ast_dns_resolve_recurring_cancel(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, async_callback(), cleanup(), sip_to_pjsip::info(), NULL, RAII_VAR, recurring_data_alloc(), recurring_resolver, TEST_EXECUTE, TEST_INIT, and wait_for_resolution().
AST_TEST_DEFINE | ( | recurring_query_cancel_between | ) |
Definition at line 449 of file test_dns_recurring.c.
References ao2_cleanup, ast_cond_timedwait, ast_dns_resolve_recurring(), ast_dns_resolve_recurring_cancel(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_tsnow(), async_callback(), cleanup(), sip_to_pjsip::info(), NULL, RAII_VAR, recurring_data_alloc(), recurring_resolver, TEST_EXECUTE, TEST_INIT, and wait_for_resolution().
AST_TEST_DEFINE | ( | recurring_query_cancel_during | ) |
Definition at line 529 of file test_dns_recurring.c.
References ao2_cleanup, ast_cond_timedwait, ast_cond_wait, ast_dns_resolve_recurring(), ast_dns_resolve_recurring_cancel(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), ast_mutex_lock, ast_mutex_unlock, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_tsnow(), async_callback(), cleanup(), sip_to_pjsip::info(), NULL, RAII_VAR, recurring_data_alloc(), recurring_resolver, TEST_EXECUTE, TEST_INIT, and wait_for_resolution().
AST_TEST_DEFINE | ( | recurring_query_off_nominal | ) |
Definition at line 368 of file test_dns_recurring.c.
References ao2_ref, ARRAY_LEN, ast_dns_resolve_recurring(), ast_dns_resolve_recurring_cancel(), ast_dns_resolver_register(), ast_dns_resolver_unregister(), AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, fail_resolve(), sip_to_pjsip::info(), name, ast_dns_resolver::name, NULL, recurring_resolver, stub_callback(), stub_cancel(), TEST_EXECUTE, and TEST_INIT.
|
static |
Definition at line 257 of file test_dns_recurring.c.
References ast_assert, ast_cond_signal, ast_dns_query_get_data(), ast_mutex_lock, ast_mutex_unlock, recurring_data::cond, recurring_data::lock, NULL, and recurring_data::query_complete.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 353 of file test_dns_recurring.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 637 of file test_dns_recurring.c.
References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.
|
static |
Resolver's cancel() method.
query | The query to cancel |
Definition at line 172 of file test_dns_recurring.c.
References ast_cond_signal, ast_dns_query_get_data(), ast_mutex_lock, ast_mutex_unlock, recurring_data::canceled, recurring_data::cond, recurring_data::lock, and ast_dns_query_recurring::user_data.
|
static |
Definition at line 65 of file test_dns_recurring.c.
References ao2_alloc, ast_cond_init, ast_mutex_init, recurring_data::cond, recurring_data::lock, NULL, and recurring_data_destructor().
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 57 of file test_dns_recurring.c.
References ast_cond_destroy, ast_mutex_destroy, recurring_data::cond, and recurring_data::lock.
Referenced by recurring_data_alloc().
|
static |
Resolver's resolve() method.
query | The query that is to be resolved |
0 | Successfully created thread to perform the resolution |
non-zero | Failed to create resolution thread |
Definition at line 155 of file test_dns_recurring.c.
References ao2_bump, ast_assert, ast_dns_query_get_data(), ast_pthread_create_detached, NULL, resolution_thread(), recurring_data::resolves, and ast_dns_query_recurring::user_data.
|
static |
Thread that performs asynchronous resolution.
This thread uses the query's user data to determine how to perform the resolution. The query may either be canceled or it may be completed with records.
dns_query | The ast_dns_query that is being performed |
Definition at line 93 of file test_dns_recurring.c.
References ao2_ref, ast_assert, ast_cond_signal, ast_cond_wait, ast_dns_query_get_data(), ast_dns_resolver_add_record(), ast_dns_resolver_completed(), ast_dns_resolver_set_result(), ast_mutex_lock, ast_mutex_unlock, recurring_data::cancel_expected, recurring_data::cancel_ready, recurring_data::canceled, recurring_data::complete_resolutions, recurring_data::cond, DNS_ANSWER, DNS_ANSWER_SIZE, recurring_data::lock, NULL, recurring_data::ttl1, recurring_data::ttl2, and ast_dns_query_recurring::user_data.
Referenced by recurring_resolve().
|
static |
Definition at line 363 of file test_dns_recurring.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 358 of file test_dns_recurring.c.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 627 of file test_dns_recurring.c.
References AST_TEST_UNREGISTER.
|
static |
Wait for a successful resolution to complete.
This is called whenever a successful DNS resolution occurs. This function serves to ensure that parameters are as we expect them to be.
test | The test being executed |
rdata | DNS query user data |
expected_lapse | The amount of time we expect to wait for the query to complete |
num_resolves | The number of DNS resolutions that have been executed |
num_completed | The number of DNS resolutions we expect to have completed successfully |
canceled | Whether the query is expected to have been canceled |
Definition at line 205 of file test_dns_recurring.c.
References ast_cond_timedwait, ast_mutex_lock, ast_mutex_unlock, ast_test_status_update, ast_tsnow(), recurring_data::canceled, recurring_data::complete_resolutions, recurring_data::cond, end, recurring_data::lock, recurring_data::query_complete, and recurring_data::resolves.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 647 of file test_dns_recurring.c.
|
static |
Definition at line 647 of file test_dns_recurring.c.
|
static |
Definition at line 185 of file test_dns_recurring.c.
Referenced by AST_TEST_DEFINE().