Index: apps/app_test.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_test.c,v retrieving revision 1.16 diff -u -r1.16 app_test.c --- apps/app_test.c 26 Oct 2005 19:48:14 -0000 1.16 +++ apps/app_test.c 28 Oct 2005 03:44:58 -0000 @@ -47,6 +47,10 @@ LOCAL_USER_DECL; +#define TEST_VERSION_NUMBER "8378*" + +#define HIGHEST_TEST '2' + static char *tdesc = "Interface Test Application"; static char *tests_descrip = @@ -56,7 +60,11 @@ static char *tests_synopsis = "Execute Interface Test Server"; static char *testc_descrip = - "TestClient(testid): Executes test client with given testid.\n" + "TestClient(testid[|testnumber]): Executes test client with given testid.\n" + "Different test can be selected by passing the testnumber, as follows:\n" + " 1: set of tests to try confirm that the connection is generally working\n" +/* " 2: test end-to-end clear, non-echocanned, digital channel for errors\n" + " such as slips\n\n" */ "\n" "Results stored in /var/log/asterisk/testreports/-client.txt"; static char *testc_app = "TestClient"; @@ -127,33 +135,322 @@ return res; } + +/* test1: + * + * Intended to be a basic functional test of the connection. + * We exchange some handshake dtmf, proving we can hear each other. + * Then we measure the "silent" channel, and then the channel with some tone playing +*/ + +static int test1_client(int res, struct ast_channel *chan, FILE *f) +{ + if (!res) { + /* Step 1: Wait for "1" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n"); + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS"); + if (res == '1') + res = 0; + else + res = -1; + } + if (!res) + res = ast_safe_sleep(chan, 1000); + + if (!res) { + /* Step 2: Send "2" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n"); + res = ast_dtmf_stream(chan, NULL, "2", 0); + fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 3: Wait one second */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n"); + res = ast_safe_sleep(chan, 1000); + fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 4: Measure noise */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n"); + res = measurenoise(chan, 5000, "TestClient"); + fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 5: Wait for "4" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n"); + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS"); + if (res == '4') + res = 0; + else + res = -1; + } + if (!res) { + /* Step 6: Transmit tone noise */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n"); + res = sendnoise(chan, 6000); + fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); + } + if (!res || (res == '5')) { + /* Step 7: Wait for "5" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n"); + if (!res) + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS"); + if (res == '5') + res = 0; + else + res = -1; + } + if (!res) { + /* Step 8: Wait one second */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n"); + res = ast_safe_sleep(chan, 1000); + fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 9: Measure noise */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n"); + res = measurenoise(chan, 4000, "TestClient"); + fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 10: Send "7" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n"); + res = ast_dtmf_stream(chan, NULL, "7", 0); + fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res =0; + } + if (!res) { + /* Step 11: Wait for "8" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n"); + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS"); + if (res == '8') + res = 0; + else + res = -1; + } + if (option_debug && !res ) { + /* Step 12: Hangup! */ + ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n"); + } + return res; +} + +static int test1_server(int res, struct ast_channel *chan, FILE *f) +{ + if (!res) { + /* Step 1: Send "1" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n"); + res = ast_dtmf_stream(chan, NULL, "1", 0); + fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 2: Wait for "2" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n"); + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS"); + if (res == '2') + res = 0; + else + res = -1; + } + if (!res) { + /* Step 3: Measure noise */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n"); + /* wait a sec for the channel to quieten */ + res = ast_safe_sleep(chan, 1000); + if (!res) + res = measurenoise(chan, 5000, "TestServer"); + fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 4: Send "4" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n"); + /* wait a sec to ensure dtmf doesn't get included in measurement on the other side */ + res = ast_safe_sleep(chan, 1000); + /* and then send the 4 (the client should be waiting for it) */ + if (!res) + res = ast_dtmf_stream(chan, NULL, "4", 0); + fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + + if (!res) { + /* Step 5: Wait one second */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n"); + res = ast_safe_sleep(chan, 1000); + fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + + if (!res) { + /* Step 6: Measure noise */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n"); + res = measurenoise(chan, 4000, "TestServer"); + fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); + if (res > 0) + res = 0; + } + + if (!res) { + /* Step 7: Send "5" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n"); + /* wait a sec to ensure dtmf doesn't get measured as part of tone */ + res = ast_safe_sleep(chan, 1000); + /* and then send the 5 (the client should be waiting for it) */ + if (!res) + res = ast_dtmf_stream(chan, NULL, "5", 0); + fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + + if (!res) { + /* Step 8: Transmit tone noise */ + if (option_debug) + ast_log(LOG_DEBUG, "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" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n"); + if (!res) + res = ast_waitfordigit(chan, 3000); + fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS"); + if (res == '7') + res = 0; + else + res = -1; + } + if (!res) + res = ast_safe_sleep(chan, 1000); + if (!res) { + /* Step 10: Send "8" */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n"); + res = ast_dtmf_stream(chan, NULL, "8", 0); + fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS"); + if (res > 0) + res = 0; + } + if (!res) { + /* Step 11: Wait for hangup to arrive! */ + if (option_debug) + ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n"); + res = ast_safe_sleep(chan, 10000); + fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL"); + } + return res; +} + +/* test2: + * + * An extremely rigorous test of an end-to-end digital connection. + * We are looking for any slips or other anomalies. + * We send a known pattern from each end and check it arrives intact. + * The pattern is designed so missing or duplicated data can be spotted. + * This won't work on analogue channels, with echo cancellation or via + * compressed links of any kind. +*/ + +static int test2_client(int res, struct ast_channel *chan, FILE *f) +{ + return -1; +} + +static int test2_server(int res, struct ast_channel *chan, FILE *f) +{ + return -1; +} + + static int testclient_exec(struct ast_channel *chan, void *data) { struct localuser *u; int res = 0; - char *testid=data; + char testid[256], *testnumber, *stringp; char fn[80]; char serverver[80]; FILE *f; - + + /* Parse testid and the optional test number */ + strncpy(testid, (char *)data, sizeof(testid)-1); + stringp = testid; + strsep(&stringp, "|"); + testnumber = strsep(&stringp, "|"); + + /* Default the test number */ + if (ast_strlen_zero(testnumber)) + testnumber = "1"; + /* Check for test id */ if (ast_strlen_zero(testid)) { ast_log(LOG_WARNING, "TestClient requires an argument - the test id\n"); return -1; } + /* Check we know the test number */ + if (strlen(testnumber) != 1 || (*testnumber < '1') || (*testnumber > HIGHEST_TEST)) { + ast_log(LOG_WARNING, "TestClient only knows test numbers from 1 to 2\n"); + return -1; + } LOCAL_USER_ADD(u); 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); + if (!res) { + res = ast_dtmf_stream(chan, NULL, TEST_VERSION_NUMBER, 0); + res = ast_dtmf_stream(chan, NULL, testnumber, 0); + res = ast_dtmf_stream(chan, NULL, "#", 0); + } if (option_debug) - ast_log(LOG_DEBUG, "Transmit client version\n"); + ast_log(LOG_DEBUG, "Transmit client version and test number\n"); /* Read server version */ if (option_debug) @@ -164,19 +461,42 @@ res = 0; if (option_debug) ast_log(LOG_DEBUG, "server version: %s\n", serverver); - + + /* Check server supports the test we want to do */ + if (!res) { + stringp = strchr(serverver, '*'); + if (stringp) { + if (*++stringp != *testnumber) { + ast_log(LOG_WARNING, "TestClient: server doesn't know test \'%s\'\n", testnumber); + LOCAL_USER_REMOVE(u); + return -1; + } + } + else { + ast_log(LOG_WARNING, "TestClient couldn't find server test number in \'%s\'\n", serverver); + LOCAL_USER_REMOVE(u); + return -1; + } + } + else { + ast_log(LOG_WARNING, "TestClient failed to read server version\n"); + LOCAL_USER_REMOVE(u); + return -1; + } + 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); if (!res) res = ast_dtmf_stream(chan, NULL, "#", 0); if (option_debug) - ast_log(LOG_DEBUG, "send test identifier: %s\n", testid); + ast_log(LOG_DEBUG, "sent test identifier: %s\n", testid); if ((res >=0) && (!ast_strlen_zero(testid))) { /* Make the directory to hold the test results in case it's not there */ @@ -187,124 +507,23 @@ setlinebuf(f); fprintf(f, "CLIENTCHAN: %s\n", chan->name); fprintf(f, "CLIENTTEST ID: %s\n", testid); + fprintf(f, "CLIENTTESTNUM: %s\n", testnumber); fprintf(f, "ANSWER: PASS\n"); - res = 0; - - if (!res) { - /* Step 1: Wait for "1" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n"); - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS"); - if (res == '1') - res = 0; - else - res = -1; - } - if (!res) - res = ast_safe_sleep(chan, 1000); - if (!res) { - /* Step 2: Send "2" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n"); - res = ast_dtmf_stream(chan, NULL, "2", 0); - fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 3: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n"); - res = ast_safe_sleep(chan, 1000); - fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 4: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n"); - res = measurenoise(chan, 5000, "TestClient"); - fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 5: Wait for "4" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n"); - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS"); - if (res == '4') - res = 0; - else - res = -1; - } - if (!res) { - /* Step 6: Transmit tone noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n"); - res = sendnoise(chan, 6000); - fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); - } - if (!res || (res == '5')) { - /* Step 7: Wait for "5" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n"); - if (!res) - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS"); - if (res == '5') - res = 0; - else - res = -1; - } - if (!res) { - /* Step 8: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n"); - res = ast_safe_sleep(chan, 1000); - fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 9: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n"); - res = measurenoise(chan, 4000, "TestClient"); - fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 10: Send "7" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n"); - res = ast_dtmf_stream(chan, NULL, "7", 0); - fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res =0; - } - if (!res) { - /* Step 11: Wait for "8" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n"); - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS"); - if (res == '8') - res = 0; - else - res = -1; - } - if (option_debug && !res ) { - /* Step 12: Hangup! */ - ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n"); - } + res = ast_safe_sleep(chan, 1000); res = 0; + /* and call the appropriate test */ + switch (*testnumber) { + case '1': + res = test1_client(res, chan, f); + break; + case '2': + res = test2_client(res, chan, f); + break; + } + if (option_debug) ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n"); + fprintf(f, "-- END TEST--\n"); fclose(f); res = -1; @@ -323,28 +542,63 @@ struct localuser *u; int res = 0; char testid[80]=""; + char clientversion[80]=""; + char *testnumber; char fn[80]; FILE *f; LOCAL_USER_ADD(u); + if (chan->_state != AST_STATE_UP) res = ast_answer(chan); + /* Read version */ if (option_debug) ast_log(LOG_DEBUG, "Read client version\n"); if (!res) - res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); + res = ast_app_getdata(chan, NULL, clientversion, sizeof(clientversion) - 1, 0); if (res > 0) res = 0; - if (option_debug) { - ast_log(LOG_DEBUG, "client version: %s\n", testid); - ast_log(LOG_DEBUG, "Transmit server version\n"); + if (option_debug) + ast_log(LOG_DEBUG, "client version: %s\n", clientversion); + + /* Check we know the version. If we do, reply matching it, if we don't, send back * */ + testnumber = strchr(clientversion, '*'); + if (testnumber) { + ++testnumber; + if (strlen(testnumber) != 1 || (*testnumber < '1') || (*testnumber > HIGHEST_TEST)) { + ast_log(LOG_WARNING, "TestServer: we don\'t know requested test \'%s\'\n", testnumber); + testnumber = "*"; + } + else { + ast_log(LOG_WARNING, "TestServer: client requested test \'%s\'\n", testnumber); + } + } + else { + ast_log(LOG_WARNING, "TestServer couldn\'t find desired test number in \'%s\'\n", clientversion); + testnumber = "*"; } + + + ast_log(LOG_DEBUG, "Transmit server version\n"); res = ast_safe_sleep(chan, 1000); - if (!res) - res = ast_dtmf_stream(chan, NULL, "8378*1#", 0); + if (!res) { + ast_log(LOG_DEBUG, "testserver replying with %s%s#\n", TEST_VERSION_NUMBER, testnumber); + res = ast_dtmf_stream(chan, NULL, TEST_VERSION_NUMBER, 0); + res = ast_dtmf_stream(chan, NULL, testnumber, 0); + res = ast_dtmf_stream(chan, NULL, "#", 0); + } if (res > 0) res = 0; + /* stop if we don't know the test */ + if (*testnumber == '*') { + ast_log(LOG_DEBUG, "TestServer: stopping cos I don't know the test they want\n"); + /* but make sure all is sent */ + res = ast_safe_sleep(chan, 1000); + LOCAL_USER_REMOVE(u); + return -1; + } + if (!res) res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); if (option_debug) @@ -362,117 +616,19 @@ setlinebuf(f); fprintf(f, "SERVERCHAN: %s\n", chan->name); fprintf(f, "SERVERTEST ID: %s\n", testid); + fprintf(f, "SERVERTESTNUM: %s\n", testnumber); fprintf(f, "ANSWER: PASS\n"); ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid); - res = ast_safe_sleep(chan, 1000); - if (!res) { - /* Step 1: Send "1" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n"); - res = ast_dtmf_stream(chan, NULL, "1", 0); - fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 2: Wait for "2" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n"); - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS"); - if (res == '2') - res = 0; - else - res = -1; - } - if (!res) { - /* Step 3: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n"); - res = measurenoise(chan, 6000, "TestServer"); - fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 4: Send "4" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n"); - res = ast_dtmf_stream(chan, NULL, "4", 0); - fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - - if (!res) { - /* Step 5: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n"); - res = ast_safe_sleep(chan, 1000); - fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - - if (!res) { - /* Step 6: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n"); - res = measurenoise(chan, 4000, "TestServer"); - fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); - if (res > 0) - res = 0; + res = ast_safe_sleep(chan, 1000); res = 0; + /* call the appropriate test */ + switch (*testnumber) { + case '1': + res = test1_server(res, chan, f); + break; + case '2': + res = test2_server(res, chan, f); + break; } - - if (!res) { - /* Step 7: Send "5" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n"); - res = ast_dtmf_stream(chan, NULL, "5", 0); - fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - - if (!res) { - /* Step 8: Transmit tone noise */ - if (option_debug) - ast_log(LOG_DEBUG, "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" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n"); - if (!res) - res = ast_waitfordigit(chan, 3000); - fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS"); - if (res == '7') - res = 0; - else - res = -1; - } - if (!res) - res = ast_safe_sleep(chan, 1000); - if (!res) { - /* Step 10: Send "8" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n"); - res = ast_dtmf_stream(chan, NULL, "8", 0); - fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS"); - if (res > 0) - res = 0; - } - if (!res) { - /* Step 11: Wait for hangup to arrive! */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n"); - res = ast_safe_sleep(chan, 10000); - fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL"); - } - ast_log(LOG_NOTICE, "-- TEST COMPLETE--\n"); fprintf(f, "-- END TEST--\n"); fclose(f); @@ -496,7 +652,7 @@ STANDARD_HANGUP_LOCALUSERS; - return res; + return res; } int load_module(void)