43 #define CATEGORY "/main/optional_api/"
51 enum was_called was_called_result;
53 ast_optional_fn test_optional_ref;
55 static void test_optional_stub(
void)
57 was_called_result = STUB;
60 static void test_optional_impl(
void)
62 was_called_result = IMPL;
65 static void test_optional(
void)
67 was_called_result = NONE;
68 if (test_optional_ref) {
73 #define SYMNAME "test_option"
77 enum ast_test_result_state res;
81 info->name = __func__;
83 info->summary =
"Test optional API publishing.";
84 info->description =
"Test optional API publishing.";
85 return AST_TEST_NOT_RUN;
91 test_optional_ref = 0;
93 ast_optional_api_provide(SYMNAME, test_optional_impl);
95 ast_optional_api_use(SYMNAME, &test_optional_ref, test_optional_stub,
100 if (was_called_result != IMPL) {
101 ast_test_status_update(
test,
"Expected %d, was %u",
102 IMPL, was_called_result);
109 ast_optional_api_unuse(SYMNAME, &test_optional_ref, AST_MODULE);
110 ast_optional_api_unprovide(SYMNAME, test_optional_impl);
116 enum ast_test_result_state res;
120 info->name = __func__;
122 info->summary =
"Test optional API publishing.";
123 info->description =
"Test optional API publishing.";
124 return AST_TEST_NOT_RUN;
130 test_optional_ref = 0;
132 ast_optional_api_use(SYMNAME, &test_optional_ref, test_optional_stub,
136 if (was_called_result != STUB) {
137 ast_test_status_update(
test,
"Expected %d, was %u",
138 STUB, was_called_result);
142 ast_optional_api_provide(SYMNAME, test_optional_impl);
145 if (was_called_result != IMPL) {
146 ast_test_status_update(
test,
"Expected %d, was %u",
147 IMPL, was_called_result);
148 ast_optional_api_unprovide(SYMNAME, test_optional_impl);
152 ast_optional_api_unprovide(SYMNAME, test_optional_impl);
155 if (was_called_result != STUB) {
156 ast_test_status_update(
test,
"Expected %d, was %u",
157 STUB, was_called_result);
158 ast_optional_api_unprovide(SYMNAME, test_optional_impl);
165 ast_optional_api_unuse(SYMNAME, &test_optional_ref, AST_MODULE);
169 static int unload_module(
void)
171 AST_TEST_UNREGISTER(test_provide_first);
172 AST_TEST_UNREGISTER(test_provide_last);
176 static int load_module(
void)
178 AST_TEST_REGISTER(test_provide_first);
179 AST_TEST_REGISTER(test_provide_last);
184 .support_level = AST_MODULE_SUPPORT_CORE,
186 .unload = unload_module,
Asterisk main include file. File version handling, generic pbx functions.
Optional API function macros.
#define AST_TEST_DEFINE(hdr)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.