Asterisk - The Open Source Telephony Project
18.5.0
|
Skeleton Test. More...
#include "asterisk.h"
#include <sys/stat.h>
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/paths.h"
#include "asterisk/channel.h"
#include "asterisk/app.h"
#include "asterisk/format_cache.h"
Go to the source code of this file.
Macros | |
#define | TOTAL_SNAPSHOTS 4 |
#define | VM_API_FORWARD_MESSAGE(from_mailbox, from_context, from_folder, to_mailbox, to_context, to_folder, number_of_messages, message_numbers_in, delete_old) |
#define | VM_API_FORWARD_MESSAGE_OFF_NOMINAL(from_mailbox, from_context, from_folder, to_mailbox, to_context, to_folder, number_of_messages, message_numbers_in, delete_old) |
#define | VM_API_INT_VERIFY(expected, actual) |
#define | VM_API_MOVE_MESSAGE(mailbox, context, number_of_messages, source, message_numbers_in, dest) |
#define | VM_API_MOVE_MESSAGE_OFF_NOMINAL(mailbox, context, number_of_messages, source, message_numbers_in, dest) |
#define | VM_API_PLAYBACK_MESSAGE(channel, mailbox, context, folder, message, callback_fn) |
#define | VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(channel, mailbox, context, folder, message, callback_fn) |
#define | VM_API_REMOVE_MESSAGE(mailbox, context, number_of_messages, folder, message_numbers_in) |
#define | VM_API_REMOVE_MESSAGE_OFF_NOMINAL(mailbox, context, number_of_messages, folder, message_numbers_in) |
#define | VM_API_SNAPSHOT_CREATE(mailbox, context, folder, desc, sort, old_and_inbox) |
#define | VM_API_SNAPSHOT_MSG_VERIFY(expected, actual, expected_folder, expected_index) |
#define | VM_API_SNAPSHOT_OFF_NOMINAL_TEST(mailbox, context, folder, desc, sort, old_and_inbox) |
#define | VM_API_SNAPSHOT_TEST_CLEANUP |
#define | VM_API_STRING_FIELD_VERIFY(expected, actual) |
#define | VM_API_TEST_CLEANUP test_vm_api_test_teardown() |
#define | VM_API_TEST_SETUP |
#define | VOICEMAIL_DIR_MODE 0777 |
#define | VOICEMAIL_FILE_MODE 0666 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
AST_TEST_DEFINE (voicemail_api_nominal_snapshot) | |
AST_TEST_DEFINE (voicemail_api_off_nominal_snapshot) | |
AST_TEST_DEFINE (voicemail_api_nominal_move) | |
AST_TEST_DEFINE (voicemail_api_off_nominal_move) | |
AST_TEST_DEFINE (voicemail_api_nominal_remove) | |
AST_TEST_DEFINE (voicemail_api_off_nominal_remove) | |
AST_TEST_DEFINE (voicemail_api_nominal_forward) | |
AST_TEST_DEFINE (voicemail_api_off_nominal_forward) | |
AST_TEST_DEFINE (voicemail_api_nominal_msg_playback) | |
AST_TEST_DEFINE (voicemail_api_off_nominal_msg_playback) | |
static int | get_folder_by_name (const char *folder) |
static int | load_module (void) |
static void | message_playback_callback_fn (struct ast_channel *chan, const char *file, int duration) |
static struct ast_channel * | test_vm_api_create_mock_channel (void) |
static struct ast_vm_msg_snapshot * | test_vm_api_create_mock_snapshot (const char *context, const char *exten, const char *callerid) |
static int | test_vm_api_create_voicemail_files (const char *context, const char *mailbox, struct ast_vm_msg_snapshot *snapshot) |
static int | test_vm_api_create_voicemail_folder (const char *folder_path) |
static void | test_vm_api_destroy_mailbox_voicemails (const char *mailbox, struct ast_vm_mailbox_snapshot *mailbox_snapshot) |
static void | test_vm_api_destroy_mock_snapshot (struct ast_vm_msg_snapshot *snapshot) |
static struct ast_frame * | test_vm_api_mock_channel_read (struct ast_channel *chan) |
static int | test_vm_api_mock_channel_write (struct ast_channel *chan, struct ast_frame *frame) |
static void | test_vm_api_remove_all_messages (void) |
static void | test_vm_api_remove_voicemail (struct ast_vm_msg_snapshot *snapshot) |
static int | test_vm_api_test_setup (void) |
static void | test_vm_api_test_teardown (void) |
static void | test_vm_api_update_test_snapshots (struct ast_vm_mailbox_snapshot *mailbox_snapshot) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Core Voicemail API 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 int | global_entered_playback_callback = 0 |
static const char *const | mailbox_folders [] |
static const struct ast_channel_tech | mock_channel_tech |
static struct ast_vm_msg_snapshot * | test_snapshots [TOTAL_SNAPSHOTS] |
Skeleton Test.
Tests for the publicly exposed Voicemail API
Definition in file test_voicemail_api.c.
#define TOTAL_SNAPSHOTS 4 |
Definition at line 66 of file test_voicemail_api.c.
Referenced by test_vm_api_test_setup(), test_vm_api_test_teardown(), and test_vm_api_update_test_snapshots().
#define VM_API_FORWARD_MESSAGE | ( | from_mailbox, | |
from_context, | |||
from_folder, | |||
to_mailbox, | |||
to_context, | |||
to_folder, | |||
number_of_messages, | |||
message_numbers_in, | |||
delete_old | |||
) |
Definition at line 263 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_FORWARD_MESSAGE_OFF_NOMINAL | ( | from_mailbox, | |
from_context, | |||
from_folder, | |||
to_mailbox, | |||
to_context, | |||
to_folder, | |||
number_of_messages, | |||
message_numbers_in, | |||
delete_old | |||
) |
Definition at line 276 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_INT_VERIFY | ( | expected, | |
actual | |||
) |
Definition at line 129 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_MOVE_MESSAGE | ( | mailbox, | |
context, | |||
number_of_messages, | |||
source, | |||
message_numbers_in, | |||
dest | |||
) |
Definition at line 211 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_MOVE_MESSAGE_OFF_NOMINAL | ( | mailbox, | |
context, | |||
number_of_messages, | |||
source, | |||
message_numbers_in, | |||
dest | |||
) |
Definition at line 223 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
Definition at line 292 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL | ( | channel, | |
mailbox, | |||
context, | |||
folder, | |||
message, | |||
callback_fn | |||
) |
Definition at line 307 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
Definition at line 235 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_REMOVE_MESSAGE_OFF_NOMINAL | ( | mailbox, | |
context, | |||
number_of_messages, | |||
folder, | |||
message_numbers_in | |||
) |
Definition at line 251 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
Definition at line 183 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_SNAPSHOT_MSG_VERIFY | ( | expected, | |
actual, | |||
expected_folder, | |||
expected_index | |||
) |
Definition at line 143 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
Definition at line 198 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_SNAPSHOT_TEST_CLEANUP |
Definition at line 103 of file test_voicemail_api.c.
#define VM_API_STRING_FIELD_VERIFY | ( | expected, | |
actual | |||
) |
Definition at line 116 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_TEST_CLEANUP test_vm_api_test_teardown() |
Definition at line 95 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VM_API_TEST_SETUP |
Definition at line 73 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE().
#define VOICEMAIL_DIR_MODE 0777 |
Definition at line 52 of file test_voicemail_api.c.
Referenced by test_vm_api_create_voicemail_folder().
#define VOICEMAIL_FILE_MODE 0666 |
Definition at line 60 of file test_voicemail_api.c.
Referenced by test_vm_api_create_voicemail_files().
|
static |
Definition at line 1579 of file test_voicemail_api.c.
|
static |
Definition at line 1579 of file test_voicemail_api.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1579 of file test_voicemail_api.c.
AST_TEST_DEFINE | ( | voicemail_api_nominal_snapshot | ) |
Definition at line 840 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_ID, AST_VM_SNAPSHOT_SORT_BY_TIME, sip_to_pjsip::info(), NULL, TEST_EXECUTE, TEST_INIT, ast_vm_mailbox_snapshot::total_msg_num, VM_API_INT_VERIFY, VM_API_SNAPSHOT_CREATE, VM_API_SNAPSHOT_MSG_VERIFY, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_off_nominal_snapshot | ) |
Definition at line 924 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, AST_VM_SNAPSHOT_SORT_BY_TIME, sip_to_pjsip::info(), NULL, TEST_EXECUTE, TEST_INIT, VM_API_SNAPSHOT_OFF_NOMINAL_TEST, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_nominal_move | ) |
Definition at line 966 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_TIME, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, test_vm_api_update_test_snapshots(), VM_API_INT_VERIFY, VM_API_MOVE_MESSAGE, VM_API_SNAPSHOT_CREATE, VM_API_STRING_FIELD_VERIFY, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_off_nominal_move | ) |
Definition at line 1037 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, VM_API_MOVE_MESSAGE_OFF_NOMINAL, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_nominal_remove | ) |
Definition at line 1113 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, VM_API_REMOVE_MESSAGE, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_off_nominal_remove | ) |
Definition at line 1155 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, VM_API_REMOVE_MESSAGE_OFF_NOMINAL, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_nominal_forward | ) |
Definition at line 1220 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_TIME, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, ast_vm_mailbox_snapshot::total_msg_num, VM_API_FORWARD_MESSAGE, VM_API_INT_VERIFY, VM_API_SNAPSHOT_CREATE, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_off_nominal_forward | ) |
Definition at line 1328 of file test_voicemail_api.c.
References AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, VM_API_FORWARD_MESSAGE_OFF_NOMINAL, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_nominal_msg_playback | ) |
Definition at line 1413 of file test_voicemail_api.c.
References ast_hangup(), ast_log, AST_LOG_ERROR, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_TIME, global_entered_playback_callback, sip_to_pjsip::info(), message_playback_callback_fn(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, test_vm_api_create_mock_channel(), ast_vm_mailbox_snapshot::total_msg_num, VM_API_INT_VERIFY, VM_API_PLAYBACK_MESSAGE, VM_API_SNAPSHOT_CREATE, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
AST_TEST_DEFINE | ( | voicemail_api_off_nominal_msg_playback | ) |
Definition at line 1472 of file test_voicemail_api.c.
References ast_hangup(), ast_log, AST_LOG_ERROR, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, sip_to_pjsip::info(), ast_vm_msg_snapshot::msg_id, NULL, TEST_EXECUTE, TEST_INIT, test_vm_api_create_mock_channel(), VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL, VM_API_TEST_CLEANUP, and VM_API_TEST_SETUP.
|
static |
|
static |
Definition at line 1554 of file test_voicemail_api.c.
References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.
|
static |
Definition at line 775 of file test_voicemail_api.c.
References ast_log, AST_LOG_WARNING, ast_strlen_zero, and global_entered_playback_callback.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 818 of file test_voicemail_api.c.
References ast_channel_alloc, ast_channel_nativeformats(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_tech_set(), ast_channel_unlock, ast_channel_writeformat(), ast_format_cap_append, ast_format_gsm, AST_STATE_DOWN, and NULL.
Referenced by AST_TEST_DEFINE().
|
static |
Definition at line 377 of file test_voicemail_api.c.
References ast_calloc, ast_free, AST_MAX_CONTEXT, AST_MAX_EXTENSION, ast_str_hash(), ast_string_field_init, ast_string_field_set, ast_vm_msg_snapshot::callerid, ast_vm_msg_snapshot::msg_id, and NULL.
Referenced by test_vm_api_test_setup().
|
static |
Definition at line 445 of file test_voicemail_api.c.
References ast_config_AST_DATA_DIR, ast_config_AST_SPOOL_DIR, AST_LOCK_FAILURE, ast_lock_path(), ast_log, AST_LOG_ERROR, ast_unlock_path(), ast_vm_msg_snapshot::callerchan, ast_vm_msg_snapshot::callerid, ast_vm_msg_snapshot::duration, errno, ast_vm_msg_snapshot::exten, ast_vm_msg_snapshot::flag, ast_vm_msg_snapshot::folder_name, ast_vm_msg_snapshot::msg_id, ast_vm_msg_snapshot::msg_number, ast_vm_msg_snapshot::origdate, ast_vm_msg_snapshot::origtime, PATH_MAX, test_vm_api_create_voicemail_folder(), and VOICEMAIL_FILE_MODE.
Referenced by test_vm_api_test_setup().
|
static |
Definition at line 419 of file test_voicemail_api.c.
References ast_log, AST_LOG_ERROR, ast_mkdir(), and VOICEMAIL_DIR_MODE.
Referenced by test_vm_api_create_voicemail_files().
|
static |
Definition at line 572 of file test_voicemail_api.c.
References AST_LIST_TRAVERSE, ast_string_field_set, exten, ast_vm_msg_snapshot::msg, ast_vm_mailbox_snapshot::snapshots, and test_vm_api_remove_voicemail().
Referenced by test_vm_api_remove_all_messages().
|
static |
Definition at line 402 of file test_voicemail_api.c.
References ast_free, and ast_string_field_free_memory.
Referenced by test_vm_api_test_setup(), and test_vm_api_test_teardown().
|
static |
|
static |
Definition at line 788 of file test_voicemail_api.c.
|
static |
Definition at line 589 of file test_voicemail_api.c.
References ast_log, AST_LOG_WARNING, ast_vm_mailbox_snapshot_create(), ast_vm_mailbox_snapshot_destroy(), AST_VM_SNAPSHOT_SORT_BY_ID, NULL, and test_vm_api_destroy_mailbox_voicemails().
Referenced by test_vm_api_test_setup(), and test_vm_api_test_teardown().
|
static |
Definition at line 537 of file test_voicemail_api.c.
References ast_config_AST_SPOOL_DIR, ast_vm_msg_snapshot::exten, ast_vm_msg_snapshot::folder_name, ast_vm_msg_snapshot::msg_number, and PATH_MAX.
Referenced by test_vm_api_destroy_mailbox_voicemails(), and test_vm_api_test_teardown().
|
static |
Definition at line 626 of file test_voicemail_api.c.
References ast_log, AST_LOG_ERROR, ast_string_field_set, ast_vm_test_create_user(), ast_vm_msg_snapshot::callerchan, ast_vm_msg_snapshot::duration, exten, ast_vm_msg_snapshot::folder_name, ast_vm_msg_snapshot::msg_number, NULL, ast_vm_msg_snapshot::origdate, ast_vm_msg_snapshot::origtime, test_vm_api_create_mock_snapshot(), test_vm_api_create_voicemail_files(), test_vm_api_destroy_mock_snapshot(), test_vm_api_remove_all_messages(), and TOTAL_SNAPSHOTS.
|
static |
Definition at line 716 of file test_voicemail_api.c.
References ast_vm_test_destroy_user(), NULL, test_vm_api_destroy_mock_snapshot(), test_vm_api_remove_all_messages(), test_vm_api_remove_voicemail(), and TOTAL_SNAPSHOTS.
|
static |
Definition at line 740 of file test_voicemail_api.c.
References AST_LIST_TRAVERSE, ast_string_field_set, ast_vm_msg_snapshot::callerchan, ast_vm_msg_snapshot::callerid, ast_vm_msg_snapshot::duration, exten, ast_vm_msg_snapshot::exten, ast_vm_msg_snapshot::flag, ast_vm_msg_snapshot::folder_name, ast_vm_msg_snapshot::msg, ast_vm_msg_snapshot::msg_id, ast_vm_msg_snapshot::msg_number, ast_vm_msg_snapshot::origdate, ast_vm_msg_snapshot::origtime, ast_vm_mailbox_snapshot::snapshots, and TOTAL_SNAPSHOTS.
Referenced by AST_TEST_DEFINE().
|
static |
|
static |
Definition at line 1579 of file test_voicemail_api.c.
|
static |
Definition at line 1579 of file test_voicemail_api.c.
|
static |
Definition at line 347 of file test_voicemail_api.c.
Referenced by AST_TEST_DEFINE(), and message_playback_callback_fn().
|
static |
Definition at line 322 of file test_voicemail_api.c.
Referenced by get_folder_by_name().
|
static |
Definition at line 806 of file test_voicemail_api.c.
|
static |
Definition at line 341 of file test_voicemail_api.c.