Applications to test connection and produce report in text file.
More...
Go to the source code of this file.
Applications to test connection and produce report in text file.
- Author
- Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
-
Russell Bryant russe.nosp@m.lb@c.nosp@m.lemso.nosp@m.n.ed.nosp@m.u
Definition in file app_test.c.
◆ AST_MODULE_INFO_STANDARD_EXTENDED()
AST_MODULE_INFO_STANDARD_EXTENDED |
( |
ASTERISK_GPL_KEY |
, |
|
|
"Interface Test Application" |
|
|
) |
| |
◆ load_module()
static int load_module |
( |
void |
| ) |
|
|
static |
◆ measurenoise()
static int measurenoise |
( |
struct ast_channel * |
chan, |
|
|
int |
ms, |
|
|
char * |
who |
|
) |
| |
|
static |
Definition at line 83 of file app_test.c.
References abs, ao2_bump, ao2_cleanup, ao2_ref, ast_channel_readformat(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_slin, AST_FRAME_VOICE, ast_frfree, ast_log, ast_read(), ast_set_read_format(), ast_tvdiff_ms(), ast_tvnow(), ast_waitfor(), ast_frame::data, ast_frame_subclass::format, ast_frame::frametype, LOG_NOTICE, ast_frame::ptr, ast_frame::samples, and ast_frame::subclass.
Referenced by testclient_exec(), and testserver_exec().
118 noise +=
abs(foo[x]);
139 ast_debug(1,
"%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
140 return (noise / samples);
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
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.
struct ast_frame_subclass subclass
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define ao2_ref(o, delta)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
struct ast_format * format
◆ sendnoise()
static int sendnoise |
( |
struct ast_channel * |
chan, |
|
|
int |
ms |
|
) |
| |
|
static |
◆ testclient_exec()
static int testclient_exec |
( |
struct ast_channel * |
chan, |
|
|
const char * |
data |
|
) |
| |
|
static |
Definition at line 154 of file app_test.c.
References ast_answer(), ast_app_getdata(), ast_channel_name(), ast_config_AST_LOG_DIR, ast_debug, ast_dtmf_stream(), ast_log, ast_mkdir(), ast_safe_sleep(), AST_STATE_UP, ast_strlen_zero, ast_waitfordigit(), LOG_NOTICE, LOG_WARNING, measurenoise(), NULL, and sendnoise().
Referenced by load_module().
157 const char *testid=data;
176 ast_debug(1,
"Transmit client version\n");
184 ast_debug(1,
"server version: %s\n", serverver);
196 ast_debug(1,
"send test identifier: %s\n", testid);
203 if ((f = fopen(fn,
"w+"))) {
206 fprintf(f,
"CLIENTTEST ID: %s\n", testid);
207 fprintf(f,
"ANSWER: PASS\n");
212 ast_debug(1,
"TestClient: 2. Wait DTMF 1\n");
214 fprintf(f,
"WAIT DTMF 1: %s\n", (res !=
'1') ?
"FAIL" :
"PASS");
225 ast_debug(1,
"TestClient: 2. Send DTMF 2\n");
227 fprintf(f,
"SEND DTMF 2: %s\n", (res < 0) ?
"FAIL" :
"PASS");
233 ast_debug(1,
"TestClient: 3. Wait one second\n");
235 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
241 ast_debug(1,
"TestClient: 4. Measure noise\n");
243 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
249 ast_debug(1,
"TestClient: 5. Wait DTMF 4\n");
251 fprintf(f,
"WAIT DTMF 4: %s\n", (res !=
'4') ?
"FAIL" :
"PASS");
259 ast_debug(1,
"TestClient: 6. Transmit tone\n");
261 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
263 if (!res || (res ==
'5')) {
265 ast_debug(1,
"TestClient: 7. Wait DTMF 5\n");
268 fprintf(f,
"WAIT DTMF 5: %s\n", (res !=
'5') ?
"FAIL" :
"PASS");
276 ast_debug(1,
"TestClient: 8. Wait one second\n");
278 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
284 ast_debug(1,
"TestClient: 9. Measure tone\n");
286 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
292 ast_debug(1,
"TestClient: 10. Send DTMF 7\n");
294 fprintf(f,
"SEND DTMF 7: %s\n", (res < 0) ?
"FAIL" :
"PASS");
300 ast_debug(1,
"TestClient: 11. Wait DTMF 8\n");
302 fprintf(f,
"WAIT DTMF 8: %s\n", (res !=
'8') ?
"FAIL" :
"PASS");
313 ast_debug(1,
"TestClient: 12. Hangup\n");
317 fprintf(f,
"-- END TEST--\n");
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
ast_channel_state
ast_channel states
#define ast_strlen_zero(foo)
#define ast_debug(level,...)
Log a DEBUG message.
const char * ast_config_AST_LOG_DIR
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
static int measurenoise(struct ast_channel *chan, int ms, char *who)
static int sendnoise(struct ast_channel *chan, int ms)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
◆ testserver_exec()
static int testserver_exec |
( |
struct ast_channel * |
chan, |
|
|
const char * |
data |
|
) |
| |
|
static |
Definition at line 329 of file app_test.c.
References ast_answer(), ast_app_getdata(), ast_channel_name(), ast_config_AST_LOG_DIR, ast_debug, ast_dtmf_stream(), ast_log, ast_mkdir(), ast_safe_sleep(), AST_STATE_UP, ast_strlen_zero, ast_waitfordigit(), LOG_NOTICE, measurenoise(), NULL, PATH_MAX, and sendnoise().
Referenced by load_module().
343 ast_debug(1,
"client version: %s\n", testid);
344 ast_debug(1,
"Transmit server version\n");
354 ast_debug(1,
"read test identifier: %s\n", testid);
356 if (strchr(testid,
'/'))
366 if ((f = fopen(fn,
"w+"))) {
369 fprintf(f,
"SERVERTEST ID: %s\n", testid);
370 fprintf(f,
"ANSWER: PASS\n");
371 ast_debug(1,
"Processing Test ID '%s'\n", testid);
375 ast_debug(1,
"TestServer: 1. Send DTMF 1\n");
377 fprintf(f,
"SEND DTMF 1: %s\n", (res < 0) ?
"FAIL" :
"PASS");
383 ast_debug(1,
"TestServer: 2. Wait DTMF 2\n");
385 fprintf(f,
"WAIT DTMF 2: %s\n", (res !=
'2') ?
"FAIL" :
"PASS");
393 ast_debug(1,
"TestServer: 3. Measure noise\n");
395 fprintf(f,
"MEASURENOISE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
401 ast_debug(1,
"TestServer: 4. Send DTMF 4\n");
403 fprintf(f,
"SEND DTMF 4: %s\n", (res < 0) ?
"FAIL" :
"PASS");
409 ast_debug(1,
"TestServer: 5. Wait one second\n");
411 fprintf(f,
"WAIT 1 SEC: %s\n", (res < 0) ?
"FAIL" :
"PASS");
417 ast_debug(1,
"TestServer: 6. Measure tone\n");
419 fprintf(f,
"MEASURETONE: %s (%d)\n", (res < 0) ?
"FAIL" :
"PASS", res);
425 ast_debug(1,
"TestServer: 7. Send DTMF 5\n");
427 fprintf(f,
"SEND DTMF 5: %s\n", (res < 0) ?
"FAIL" :
"PASS");
433 ast_debug(1,
"TestServer: 8. Transmit tone\n");
435 fprintf(f,
"SENDTONE: %s\n", (res < 0) ?
"FAIL" :
"PASS");
438 if (!res || (res ==
'7')) {
440 ast_debug(1,
"TestServer: 9. Wait DTMF 7\n");
443 fprintf(f,
"WAIT DTMF 7: %s\n", (res !=
'7') ?
"FAIL" :
"PASS");
454 ast_debug(1,
"TestServer: 10. Send DTMF 8\n");
456 fprintf(f,
"SEND DTMF 8: %s\n", (res < 0) ?
"FAIL" :
"PASS");
462 ast_debug(1,
"TestServer: 11. Waiting for hangup\n");
464 fprintf(f,
"WAIT HANGUP: %s\n", (res < 0) ?
"PASS" :
"FAIL");
468 fprintf(f,
"-- END TEST--\n");
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
ast_channel_state
ast_channel states
#define ast_strlen_zero(foo)
#define ast_debug(level,...)
Log a DEBUG message.
const char * ast_config_AST_LOG_DIR
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
static int measurenoise(struct ast_channel *chan, int ms, char *who)
static int sendnoise(struct ast_channel *chan, int ms)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
◆ unload_module()
static int unload_module |
( |
void |
| ) |
|
|
static |
◆ testc_app
char* testc_app = "TestClient" |
|
static |
◆ tests_app
char* tests_app = "TestServer" |
|
static |