Asterisk - The Open Source Telephony Project GIT-master-55f4e6d
Functions | Variables
test_endpoints.c File Reference

Test endpoints. More...

#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/endpoints.h"
#include "asterisk/module.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/test.h"
Include dependency graph for test_endpoints.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
 AST_TEST_DEFINE (create)
 
 AST_TEST_DEFINE (defaults)
 
 AST_TEST_DEFINE (setters)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Endpoint testing" , .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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const char * test_category = "/core/endpoints/"
 

Detailed Description

Test endpoints.

Author
David M. Lee, II <dlee@digium.com> 

Definition in file test_endpoints.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 157 of file test_endpoints.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 157 of file test_endpoints.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 157 of file test_endpoints.c.

◆ AST_TEST_DEFINE() [1/3]

AST_TEST_DEFINE ( create  )

Definition at line 43 of file test_endpoints.c.

44{
46
47 switch (cmd) {
48 case TEST_INIT:
49 info->name = __func__;
50 info->category = test_category;
51 info->summary = "Test endpoint creation";
52 info->description = "Test endpoint creation";
53 return AST_TEST_NOT_RUN;
54 case TEST_EXECUTE:
55 break;
56 }
57
58 ast_test_validate(test, NULL == ast_endpoint_create(NULL, NULL));
59 ast_test_validate(test, NULL == ast_endpoint_create("", ""));
60 ast_test_validate(test, NULL == ast_endpoint_create("TEST", ""));
61 ast_test_validate(test, NULL == ast_endpoint_create("", "test_res"));
62
63 uut = ast_endpoint_create("TEST", "test_res");
64 ast_test_validate(test, NULL != uut);
65
66 ast_test_validate(test,
67 0 == strcmp("TEST", ast_endpoint_get_tech(uut)));
68 ast_test_validate(test,
69 0 == strcmp("test_res", ast_endpoint_get_resource(uut)));
70
71 return AST_TEST_PASS;
72}
const char * ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
Gets the technology of the given endpoint.
void ast_endpoint_shutdown(struct ast_endpoint *endpoint)
Shutsdown an ast_endpoint.
const char * ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
Gets the resource name of the given endpoint.
struct ast_endpoint * ast_endpoint_create(const char *tech, const char *resource)
Create an endpoint struct.
def info(msg)
#define NULL
Definition: resample.c:96
@ TEST_INIT
Definition: test.h:200
@ TEST_EXECUTE
Definition: test.h:201
@ AST_TEST_PASS
Definition: test.h:195
@ AST_TEST_NOT_RUN
Definition: test.h:194
static const char * test_category
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ast_endpoint_create(), ast_endpoint_get_resource(), ast_endpoint_get_tech(), ast_endpoint_shutdown(), AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), NULL, RAII_VAR, test_category, TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [2/3]

AST_TEST_DEFINE ( defaults  )

Definition at line 75 of file test_endpoints.c.

76{
78 RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
79
80 switch (cmd) {
81 case TEST_INIT:
82 info->name = __func__;
83 info->category = test_category;
84 info->summary = "Test defaults for new endpoints";
85 info->description = "Test defaults for new endpoints";
86 return AST_TEST_NOT_RUN;
87 case TEST_EXECUTE:
88 break;
89 }
90
91 uut = ast_endpoint_create("TEST", "test_res");
92 ast_test_validate(test, NULL != uut);
93 snapshot = ast_endpoint_snapshot_create(uut);
94 ast_test_validate(test, NULL != snapshot);
95
96 ast_test_validate(test, 0 == strcmp("TEST/test_res", snapshot->id));
97 ast_test_validate(test, 0 == strcmp("TEST", snapshot->tech));
98 ast_test_validate(test, 0 == strcmp("test_res", snapshot->resource));
99 ast_test_validate(test, AST_ENDPOINT_UNKNOWN == snapshot->state);
100 ast_test_validate(test, -1 == snapshot->max_channels);
101 ast_test_validate(test, 0 == snapshot->num_channels);
102
103 return AST_TEST_PASS;
104}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
@ AST_ENDPOINT_UNKNOWN
Definition: endpoints.h:53
struct ast_endpoint_snapshot * ast_endpoint_snapshot_create(struct ast_endpoint *endpoint)
Create a snapshot of an endpoint.
A snapshot of an endpoint's state.

References ao2_cleanup, ast_endpoint_create(), ast_endpoint_shutdown(), ast_endpoint_snapshot_create(), AST_ENDPOINT_UNKNOWN, AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), NULL, RAII_VAR, test_category, TEST_EXECUTE, and TEST_INIT.

◆ AST_TEST_DEFINE() [3/3]

AST_TEST_DEFINE ( setters  )

Definition at line 106 of file test_endpoints.c.

107{
109 RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
110
111 switch (cmd) {
112 case TEST_INIT:
113 info->name = __func__;
114 info->category = test_category;
115 info->summary = "Test endpoint setters";
116 info->description = "Test endpoint setters";
117 return AST_TEST_NOT_RUN;
118 case TEST_EXECUTE:
119 break;
120 }
121
122 uut = ast_endpoint_create("TEST", "test_res");
123 ast_test_validate(test, NULL != uut);
124
127
128 snapshot = ast_endpoint_snapshot_create(uut);
129 ast_test_validate(test, NULL != snapshot);
130
131 ast_test_validate(test, AST_ENDPOINT_ONLINE == snapshot->state);
132 ast_test_validate(test, 314159 == snapshot->max_channels);
133
134 return AST_TEST_PASS;
135}
@ AST_ENDPOINT_ONLINE
Definition: endpoints.h:57
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
void ast_endpoint_set_max_channels(struct ast_endpoint *endpoint, int max_channels)
Updates the maximum number of channels an endpoint supports.

References ao2_cleanup, ast_endpoint_create(), AST_ENDPOINT_ONLINE, ast_endpoint_set_max_channels(), ast_endpoint_set_state(), ast_endpoint_shutdown(), ast_endpoint_snapshot_create(), AST_TEST_NOT_RUN, AST_TEST_PASS, sip_to_pjsip::info(), NULL, RAII_VAR, test_category, TEST_EXECUTE, and TEST_INIT.

◆ load_module()

static int load_module ( void  )
static

Definition at line 145 of file test_endpoints.c.

146{
147 AST_TEST_REGISTER(create);
148 AST_TEST_REGISTER(defaults);
149 AST_TEST_REGISTER(setters);
151}
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
#define AST_TEST_REGISTER(cb)
Definition: test.h:127

References AST_MODULE_LOAD_SUCCESS, and AST_TEST_REGISTER.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 137 of file test_endpoints.c.

138{
139 AST_TEST_UNREGISTER(create);
140 AST_TEST_UNREGISTER(defaults);
141 AST_TEST_UNREGISTER(setters);
142 return 0;
143}
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

References AST_TEST_UNREGISTER.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Endpoint testing" , .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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
static

Definition at line 157 of file test_endpoints.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 157 of file test_endpoints.c.

◆ test_category

const char* test_category = "/core/endpoints/"
static

Definition at line 41 of file test_endpoints.c.

Referenced by AST_TEST_DEFINE().