55    for (x = 0; x < num_tests; x++) {
 
   57        ast_cli(fd, 
"\tExpected Successes: %u\n", tests[x].x_success);
 
   58        ast_cli(fd, 
"\tExpected Failures: %u\n", tests[x].x_failure);
 
   59        ast_cli(fd, 
"\tUnexpected Successes: %u\n", tests[x].u_success);
 
   60        ast_cli(fd, 
"\tUnexpected Failures: %u\n", tests[x].u_failure);
 
   61        ast_cli(fd, 
"Test %u Result: %s\n", x + 1, (tests[x].u_success + tests[x].u_failure) ? 
"FAIL" : 
"PASS");
 
 
   70    struct test tests[] = {
 
   71        { .
name = 
"Simple register/message/unregister",
 
   73        { .name = 
"Register multiple levels",
 
   79        e->
command = 
"logger test dynamic";
 
   81            "Usage: logger test dynamic\n" 
   93                ast_cli(
a->fd, 
"Test: got level %u\n", level);
 
   98                ast_cli(
a->fd, 
"Test: Failed, could not register level 'test'.\n");
 
  104            char level_name[18][8];
 
  106            for (x = 0; x < 
ARRAY_LEN(level_name); x++) {
 
  107                sprintf(level_name[x], 
"level%02u", x);
 
  114                    level_name[x][0] = 
'\0';
 
  116                    ast_cli(
a->fd, 
"Test: registered '%s', got level %u\n", level_name[x], level);
 
  125            for (x = 0; x < 
ARRAY_LEN(level_name); x++) {
 
 
  143    struct test tests[] = {
 
  144        { .
name = 
"Log 10,000 messages",
 
  150        e->
command = 
"logger test performance";
 
  152            "Usage: logger test performance\n" 
  165                struct timeval start, 
end;
 
  168                ast_cli(
a->fd, 
"Test: got level %u\n", level);
 
  170                for (x = 0; x < 10000; x++) {
 
  175                ast_cli(
a->fd, 
"Test: 10,000 messages in %f seconds.\n", (
float) elapsed / 1000);
 
  179                ast_cli(
a->fd, 
"Test: Failed, could not register level 'perftest'.\n");
 
 
  194    int current_queue_limit;
 
  196    struct timeval start, 
end;
 
  198    char tmppath[] = 
"/tmp/asterisk_logger_queue.XXXXXX";
 
  203        e->
command = 
"logger test queue";
 
  205            "Usage: logger test queue\n" 
  212    fd = mkstemp(tmppath);
 
  214        ast_cli(
a->fd, 
"Test: Failed, could not create temporary log file '%s'.\n", tmppath);
 
  220        ast_cli(
a->fd, 
"Test: Failed, could not register level 'queuetest'.\n");
 
  223    ast_cli(
a->fd, 
"Test: got level %d for 'queuetest'.\n", level);
 
  226        ast_cli(
a->fd, 
"Test: Unable to create logger channel '%s'\n", tmppath);
 
  231    ast_cli(
a->fd, 
"Test: Current queue limit: %d.  Setting to 100 for test.\n", current_queue_limit);
 
  234    ast_cli(
a->fd, 
"Test: You should see SOME 'exceeded' and 'resumed' messages after the test " 
  235        "is completed.  How many is dependent on system resources.\n");
 
  238    for (x = 0; x < 10000; x++) {
 
  243    ast_cli(
a->fd, 
"Test: 10,000 messages in %f seconds.\n", (
float) elapsed / 1000);
 
  244    ast_cli(
a->fd, 
"Test: Completed.  Resetting queue limit to %d.\n", current_queue_limit);
 
 
void ast_cli_unregister_multiple(void)
Asterisk main include file. File version handling, generic pbx functions.
General Asterisk PBX channel definitions.
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Generic File Format Support. Should be included by clients of the file handling routines....
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_logger_get_queue_limit(void)
Get the maximum number of messages allowed in the processing queue.
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
int ast_logger_register_level(const char *name)
Register a new logger level.
void ast_logger_set_queue_limit(int queue_limit)
Set the maximum number of messages allowed in the processing queue.
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
Asterisk locking-related definitions:
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
descriptor for a cli entry.
static char * handle_cli_performance_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_dynamic_level_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void output_tests(struct test *tests, size_t num_tests, int fd)
static int load_module(void)
static int unload_module(void)
static char * handle_cli_queue_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct ast_cli_entry cli_logger[]
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int error(const char *format,...)