35 #include "../res/res_aeap/general.h"
36 #include "../res/res_aeap/transaction.h"
38 #define CATEGORY "/res/aeap/transaction/"
40 #define AEAP_TRANSACTION_ID "foo"
49 static void *end_transaction(
void *data)
52 struct timespec delay = { 1, 0 };
53 int *passed = aeap_transaction_user_obj(data);
55 while (nanosleep(&delay, &delay));
58 aeap_transaction_end(data, 0);
63 static enum ast_test_result_state exec(
struct ast_test *
test,
66 pthread_t thread_id = AST_PTHREADT_NULL;
69 enum ast_test_result_state res = AST_TEST_FAIL;
72 tsxs = aeap_transactions_create();
74 ast_test_status_update(test,
"Failed to create transactions object\n");
79 params->
obj = &passed;
81 tsx = aeap_transaction_create_and_add(tsxs, AEAP_TRANSACTION_ID, params, NULL);
83 ast_test_status_update(test,
"Failed to create transaction object\n");
87 if (ast_pthread_create(&thread_id, NULL, end_transaction,
ao2_bump(tsx))) {
88 ast_test_status_update(test,
"Failed to create response thread\n");
93 if (aeap_transaction_start(tsx)) {
94 ast_test_status_update(test,
"Failed to start transaction request\n");
104 if (thread_id != AST_PTHREADT_NULL) {
105 pthread_cancel(thread_id);
106 pthread_join(thread_id, NULL);
109 aeap_transaction_end(tsx, 0);
123 info->name = __func__;
124 info->explicit_only = 0;
126 info->summary =
"test creating a basic AEAP transaction request";
127 info->description = info->summary;
128 return AST_TEST_NOT_RUN;
133 return exec(test, ¶ms);
140 .on_timeout = handle_timeout,
145 info->name = __func__;
146 info->explicit_only = 0;
148 info->summary =
"test creating a AEAP transaction request that times out";
149 info->description = info->summary;
150 return AST_TEST_NOT_RUN;
155 return exec(test, ¶ms);
158 static int load_module(
void)
160 AST_TEST_REGISTER(transaction_exec);
161 AST_TEST_REGISTER(transaction_exec_timeout);
166 static int unload_module(
void)
168 AST_TEST_UNREGISTER(transaction_exec_timeout);
169 AST_TEST_UNREGISTER(transaction_exec);
174 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"Asterisk External Application Protocol Transaction Tests",
175 .support_level = AST_MODULE_SUPPORT_CORE,
177 .unload = unload_module,
178 .requires =
"res_aeap",
Asterisk External Application Protocol API.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
Asterisk External Application Protocol Message API.
Parameters to be used when sending a transaction based message.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Asterisk external application base message.
#define AST_TEST_DEFINE(hdr)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.