aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_test.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-26 21:18:39 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-26 21:18:39 +0000
commit8bb400b9ec267c2210a915a1d091b4e5f0f795cd (patch)
tree8ff23682630e6da46553644ff450b3d18a5d1e6d /apps/app_test.c
parentf20891ac5bac3ec16f67e0d4455a20eb0e967de9 (diff)
Merged revisions 184389 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r184389 | dvossel | 2009-03-26 16:09:37 -0500 (Thu, 26 Mar 2009) | 14 lines Merged revisions 184388 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r184388 | dvossel | 2009-03-26 16:07:32 -0500 (Thu, 26 Mar 2009) | 8 lines pri loop TestClient/TestServer fails: server SEND DTMF 8 app_test was failing when sending the last DTMF digit, 8, because of the 100ms pause issued after DTMF is sent. During this pause the other side would hang up causing the test to look like it failed. Now the other side waits a second before hanging up. (closes issue #12442) Reported by: tzafrir ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@184394 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_test.c')
-rw-r--r--apps/app_test.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/apps/app_test.c b/apps/app_test.c
index e873777e4..c9a876253 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -109,7 +109,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
return (noise / samples);
}
-static int sendnoise(struct ast_channel *chan, int ms)
+static int sendnoise(struct ast_channel *chan, int ms)
{
int res;
res = ast_tonepair_start(chan, 1537, 2195, ms, 8192);
@@ -117,7 +117,7 @@ static int sendnoise(struct ast_channel *chan, int ms)
res = ast_waitfordigit(chan, ms);
ast_tonepair_stop(chan);
}
- return res;
+ return res;
}
static int testclient_exec(struct ast_channel *chan, void *data)
@@ -127,41 +127,41 @@ static int testclient_exec(struct ast_channel *chan, void *data)
char fn[80];
char serverver[80];
FILE *f;
-
+
/* Check for test id */
if (ast_strlen_zero(testid)) {
ast_log(LOG_WARNING, "TestClient requires an argument - the test id\n");
return -1;
}
-
+
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
-
+
/* Wait a few just to be sure things get started */
res = ast_safe_sleep(chan, 3000);
/* Transmit client version */
if (!res)
res = ast_dtmf_stream(chan, NULL, "8378*1#", 0, 0);
ast_debug(1, "Transmit client version\n");
-
+
/* Read server version */
ast_debug(1, "Read server version\n");
- if (!res)
+ if (!res)
res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0);
if (res > 0)
res = 0;
ast_debug(1, "server version: %s\n", serverver);
-
+
if (res > 0)
res = 0;
if (!res)
res = ast_safe_sleep(chan, 1000);
/* Send test id */
- if (!res)
- res = ast_dtmf_stream(chan, NULL, testid, 0, 0);
- if (!res)
- res = ast_dtmf_stream(chan, NULL, "#", 0, 0);
+ if (!res)
+ res = ast_dtmf_stream(chan, NULL, testid, 0, 0);
+ if (!res)
+ res = ast_dtmf_stream(chan, NULL, "#", 0, 0);
ast_debug(1, "send test identifier: %s\n", testid);
if ((res >=0) && (!ast_strlen_zero(testid))) {
@@ -175,7 +175,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
fprintf(f, "CLIENTTEST ID: %s\n", testid);
fprintf(f, "ANSWER: PASS\n");
res = 0;
-
+
if (!res) {
/* Step 1: Wait for "1" */
ast_debug(1, "TestClient: 2. Wait DTMF 1\n");
@@ -186,8 +186,9 @@ static int testclient_exec(struct ast_channel *chan, void *data)
else
res = -1;
}
- if (!res)
+ if (!res) {
res = ast_safe_sleep(chan, 1000);
+ }
if (!res) {
/* Step 2: Send "2" */
ast_debug(1, "TestClient: 2. Send DTMF 2\n");
@@ -203,7 +204,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
res = 0;
- }
+ }
if (!res) {
/* Step 4: Measure noise */
ast_debug(1, "TestClient: 4. Measure noise\n");
@@ -249,7 +250,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Step 9: Measure noise */
- ast_debug(1, "TestClient: 6. Measure tone\n");
+ ast_debug(1, "TestClient: 9. Measure tone\n");
res = measurenoise(chan, 4000, "TestClient");
fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res);
if (res > 0)
@@ -257,7 +258,7 @@ static int testclient_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Step 10: Send "7" */
- ast_debug(1, "TestClient: 7. Send DTMF 7\n");
+ ast_debug(1, "TestClient: 10. Send DTMF 7\n");
res = ast_dtmf_stream(chan, NULL, "7", 0, 0);
fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS");
if (res > 0)
@@ -274,6 +275,9 @@ static int testclient_exec(struct ast_channel *chan, void *data)
res = -1;
}
if (!res) {
+ res = ast_safe_sleep(chan, 1000);
+ }
+ if (!res) {
/* Step 12: Hangup! */
ast_debug(1, "TestClient: 12. Hangup\n");
}
@@ -301,7 +305,7 @@ static int testserver_exec(struct ast_channel *chan, void *data)
res = ast_answer(chan);
/* Read version */
ast_debug(1, "Read client version\n");
- if (!res)
+ if (!res)
res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
if (res > 0)
res = 0;
@@ -315,8 +319,8 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (res > 0)
res = 0;
- if (!res)
- res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
+ if (!res)
+ res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0);
ast_debug(1, "read test identifier: %s\n", testid);
/* Check for sneakyness */
if (strchr(testid, '/'))
@@ -368,7 +372,6 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (res > 0)
res = 0;
}
-
if (!res) {
/* Step 5: Wait one second */
ast_debug(1, "TestServer: 5. Wait one second\n");
@@ -377,7 +380,6 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (res > 0)
res = 0;
}
-
if (!res) {
/* Step 6: Measure noise */
ast_debug(1, "TestServer: 6. Measure tone\n");
@@ -386,7 +388,6 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (res > 0)
res = 0;
}
-
if (!res) {
/* Step 7: Send "5" */
ast_debug(1, "TestServer: 7. Send DTMF 5\n");
@@ -395,14 +396,13 @@ static int testserver_exec(struct ast_channel *chan, void *data)
if (res > 0)
res = 0;
}
-
if (!res) {
/* Step 8: Transmit tone noise */
ast_debug(1, "TestServer: 8. Transmit tone\n");
res = sendnoise(chan, 6000);
fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS");
}
-
+
if (!res || (res == '7')) {
/* Step 9: Wait for "7" */
ast_debug(1, "TestServer: 9. Wait DTMF 7\n");
@@ -414,8 +414,9 @@ static int testserver_exec(struct ast_channel *chan, void *data)
else
res = -1;
}
- if (!res)
+ if (!res) {
res = ast_safe_sleep(chan, 1000);
+ }
if (!res) {
/* Step 10: Send "8" */
ast_debug(1, "TestServer: 10. Send DTMF 8\n");
@@ -451,7 +452,7 @@ static int unload_module(void)
res = ast_unregister_application(testc_app);
res |= ast_unregister_application(tests_app);
- return res;
+ return res;
}
static int load_module(void)