Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Functions | Variables
test_scope_trace.c File Reference

Test for Scope Trace. More...

#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/logger.h"
Include dependency graph for test_scope_trace.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 (scope_test)
 
static int load_module (void)
 
static const char * str_appender (struct ast_str **buf, char *a)
 
static int test_scope_enter_function (void)
 
static void test_scope_trace (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Scope Trace Test" , .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_infoast_module_info = &__mod_info
 

Detailed Description

Test for Scope Trace.

Author
George Joseph <gjoseph@digium.com> 

tests for Scope Trace

Definition in file test_scope_trace.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 126 of file test_scope_trace.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 126 of file test_scope_trace.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 126 of file test_scope_trace.c.

◆ AST_TEST_DEFINE()

AST_TEST_DEFINE ( scope_test  )

Definition at line 72 of file test_scope_trace.c.

73{
74 SCOPE_ENTER(1, "top %s function\n", "scope_test");
75
76 ast_trace(1, "%s\n", "test outer");
77
78 switch (cmd) {
79 case TEST_INIT:
80 {
81 SCOPE_ENTER(1, "TEST_INIT\n");
82 info->name = "scope_test";
83 info->category = "/main/logging/";
84 info->summary = "Scope Trace Tests";
85 info->description = "Scope Trace Tests";
86 /* need to exit the case scope */
87 SCOPE_EXIT("TEST_INIT\n");
88 /* need to exit the function */
90 }
91 case TEST_EXECUTE:
92 {
93 SCOPE_ENTER(1, "TEST_EXECUTE\n");
94 ast_trace(1, "%s\n", "test execute");
95 SCOPE_EXIT_EXPR(break, "TEST_EXECUTE\n");
96 }
97 default:
98 ast_test_status_update(test, "Shouldn't have gotten here\n");
99 return AST_TEST_FAIL;
100 }
101
102 if (1) {
103 SCOPE_TRACE(1, "IF block\n");
105 }
106
107 ast_trace(1);
108 ast_trace(1, "test no variables\n");
109 ast_trace(1, "%s\n", "test variable");
110
112}
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_TRACE(__level,...)
#define SCOPE_ENTER(level,...)
#define SCOPE_EXIT_EXPR(__expr,...)
#define SCOPE_EXIT(...)
#define ast_trace(level,...)
def info(msg)
@ TEST_INIT
Definition: test.h:200
@ TEST_EXECUTE
Definition: test.h:201
#define ast_test_status_update(a, b, c...)
Definition: test.h:129
@ AST_TEST_PASS
Definition: test.h:195
@ AST_TEST_FAIL
Definition: test.h:196
@ AST_TEST_NOT_RUN
Definition: test.h:194
static int test_scope_enter_function(void)

References AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_trace, sip_to_pjsip::info(), SCOPE_ENTER, SCOPE_EXIT, SCOPE_EXIT_EXPR, SCOPE_EXIT_RTN_VALUE, SCOPE_TRACE, TEST_EXECUTE, TEST_INIT, and test_scope_enter_function().

◆ load_module()

static int load_module ( void  )
static

Definition at line 120 of file test_scope_trace.c.

121{
122 AST_TEST_REGISTER(scope_test);
124}
@ 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.

◆ str_appender()

static const char * str_appender ( struct ast_str **  buf,
char *  a 
)
static

Definition at line 42 of file test_scope_trace.c.

43{
44 ast_str_append(buf, 0, "<append %s>", a);
45 return ast_str_buffer(*buf);
46}
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
static struct test_val a

References a, ast_str_append(), ast_str_buffer(), and buf.

Referenced by test_scope_enter_function().

◆ test_scope_enter_function()

static int test_scope_enter_function ( void  )
static

Definition at line 54 of file test_scope_trace.c.

55{
56 SCOPE_ENTER(1, "%s %s %s %s %s %s %s\n",
57 ast_str_tmp(12, str_appender(&STR_TMP, "str1")),
58 ast_str_tmp(12, str_appender(&STR_TMP, "str2")),
59 ast_str_tmp(32, str_appender(&STR_TMP, "AAAAAAAAAAAAAAAAAAAAAAAA")),
60 ast_str_tmp(12, str_appender(&STR_TMP, "B")),
61 "ccccccccccccc",
62 ast_str_tmp(12, str_appender(&STR_TMP, "DDDDD")),
63 ast_str_tmp(12, str_appender(&STR_TMP, "ww"))
64 );
65
67
68 SCOPE_EXIT_RTN_VALUE(AST_TEST_PASS, "test no variables\n");
69}
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition: strings.h:1189
static const char * str_appender(struct ast_str **buf, char *a)
static void test_scope_trace(void)

References ast_str_tmp, AST_TEST_PASS, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, str_appender(), and test_scope_trace().

Referenced by AST_TEST_DEFINE().

◆ test_scope_trace()

static void test_scope_trace ( void  )
static

Definition at line 48 of file test_scope_trace.c.

49{
50 SCOPE_ENTER(1, "subfunction\n");
51 SCOPE_EXIT_RTN("got out\n");
52}
#define SCOPE_EXIT_RTN(...)

References SCOPE_ENTER, and SCOPE_EXIT_RTN.

Referenced by test_scope_enter_function().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 114 of file test_scope_trace.c.

115{
116 AST_TEST_UNREGISTER(scope_test);
117 return 0;
118}
#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_LOAD_ORDER , .description = "Scope Trace Test" , .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

Definition at line 126 of file test_scope_trace.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 126 of file test_scope_trace.c.