55 for (x = 0; x < num_tests; x++) {
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" 88 for (test = 0; test <
ARRAY_LEN(tests); test++) {
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" 159 for (test = 0; test <
ARRAY_LEN(tests); test++) {
160 ast_cli(a->
fd,
"Test %u: %s.\n", test + 1, tests[test].
name);
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);
#define AST_CLI_DEFINE(fn, txt,...)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static int unload_module(void)
descriptor for a cli entry.
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static struct ast_cli_entry cli_logger[]
static char * handle_cli_queue_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_cli(int fd, const char *fmt,...)
#define ast_strlen_zero(foo)
static int load_module(void)
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
General Asterisk PBX channel definitions.
static char * handle_cli_dynamic_level_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_logger_set_queue_limit(int queue_limit)
Set the maximum number of messages allowed in the processing queue.
int ast_logger_register_level(const char *name)
Register a new logger level.
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
Core PBX routines and definitions.
static void output_tests(struct test *tests, size_t num_tests, int fd)
int ast_logger_get_queue_limit(void)
Get the maximum number of messages allowed in the processing queue.
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
static char * handle_cli_performance_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Standard Command Line Interface.
int error(const char *format,...)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static struct ast_test * test