Changeset 563 for pjproject/trunk/pjsip/src/test-pjsip/tsx_uas_test.c
- Timestamp:
- Jun 28, 2006 4:46:49 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/test-pjsip/tsx_uas_test.c
r555 r563 36 36 ** Test that non-INVITE transaction returns 2xx response to the correct 37 37 ** transport and correctly terminates the transaction. 38 ** This also checks that transaction is destroyed immediately after 39 ** it sends final response when reliable transport is used. 38 40 ** 39 41 ** TEST2_BRANCH_ID … … 54 56 ** TEST6_BRANCH_ID 55 57 ** As above, in COMPLETED state, with first sending provisional response. 58 ** (Only applicable for non-reliable transports). 56 59 ** 57 60 ** TEST7_BRANCH_ID … … 66 69 ** until it's terminated by user). 67 70 ** Transaction also MUST terminate in T4 seconds. 71 ** (Only applicable for non-reliable transports). 68 72 ** 69 73 ** TEST11_BRANCH_ID … … 129 133 130 134 135 static char TARGET_URI[128]; 136 static char FROM_URI[128]; 137 static struct tsx_test_param *test_param; 138 static unsigned tp_flag; 139 140 131 141 #define TEST_TIMEOUT_ERROR -30 132 142 #define MAX_ALLOWED_DIFF 150 … … 522 532 /* Check that status code is status_code. */ 523 533 if (tsx->status_code != TEST6_STATUS_CODE) { 524 PJ_LOG(3,(THIS_FILE, " error: incorrect status code")); 534 PJ_LOG(3,(THIS_FILE, " error: incorrect status code %d " 535 "(expecting %d)", tsx->status_code, 536 TEST6_STATUS_CODE)); 525 537 test_complete = -140; 526 538 } … … 576 588 PJ_LOG(3,(THIS_FILE, " error: incorrect prev_state")); 577 589 test_complete = -151; 590 } 591 592 /* Check the number of retransmissions */ 593 if (tp_flag & PJSIP_TRANSPORT_RELIABLE) { 594 595 if (tsx->retransmit_count != 0) { 596 PJ_LOG(3,(THIS_FILE, " error: should not retransmit")); 597 test_complete = -1510; 598 } 599 600 } else { 601 602 if (tsx->retransmit_count != 10) { 603 PJ_LOG(3,(THIS_FILE, 604 " error: incorrect retransmit count %d " 605 "(expecting 10)", 606 tsx->retransmit_count)); 607 test_complete = -1510; 608 } 609 578 610 } 579 611 … … 815 847 pjsip_transaction *tsx; 816 848 849 PJ_LOG(4,(THIS_FILE, " received request (probably retransmission)")); 850 817 851 status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx); 818 852 if (status != PJ_SUCCESS) { … … 831 865 832 866 } else if (pj_strcmp2(&branch_param, TEST6_BRANCH_ID) == 0) { 867 PJ_LOG(4,(THIS_FILE, " sending provisional response")); 833 868 send_response(rdata, tsx, TEST6_PROVISIONAL_CODE); 869 PJ_LOG(4,(THIS_FILE, " sending final response")); 834 870 send_response(rdata, tsx, TEST6_STATUS_CODE); 835 871 } … … 838 874 /* Verify the response received. */ 839 875 876 PJ_LOG(4,(THIS_FILE, " received response number %d", recv_count)); 877 840 878 ++recv_count; 841 879 … … 870 908 case 3: 871 909 if (code != TEST6_STATUS_CODE) { 872 PJ_LOG(3,(THIS_FILE, " error: invalid code!")); 910 PJ_LOG(3,(THIS_FILE, " error: invalid code %d " 911 "(expecting %d)", code, TEST6_STATUS_CODE)); 873 912 test_complete = -136; 874 913 } … … 1184 1223 1185 1224 /* (Re)Send the request. */ 1225 PJ_LOG(4,(THIS_FILE, " (re)sending request %d", sent_cnt)); 1226 1186 1227 status = pjsip_endpt_send_request_stateless(endpt, tdata, 0, 0); 1187 1228 if (status != PJ_SUCCESS) { … … 1256 1297 static int tsx_basic_final_response_test(void) 1257 1298 { 1299 unsigned duration; 1258 1300 int status; 1259 1301 1260 1302 PJ_LOG(3,(THIS_FILE," test1: basic sending 2xx final response")); 1261 1303 1262 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1263 "sip:129.0.0.1;transport=loop-dgram", 1264 TEST1_BRANCH_ID, 1265 33, /* Test duration must be greater than 32 secs */ 1266 &pjsip_options_method, 1, 0, 0); 1304 /* Test duration must be greater than 32 secs if unreliable transport 1305 * is used. 1306 */ 1307 duration = (tp_flag & PJSIP_TRANSPORT_RELIABLE) ? 1 : 33; 1308 1309 status = perform_test(TARGET_URI, FROM_URI, TEST1_BRANCH_ID, 1310 duration, &pjsip_options_method, 1, 0, 0); 1267 1311 if (status != 0) 1268 1312 return status; … … 1270 1314 PJ_LOG(3,(THIS_FILE," test2: basic sending non-2xx final response")); 1271 1315 1272 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1273 "sip:129.0.0.1;transport=loop-dgram", 1274 TEST2_BRANCH_ID, 1275 33, /* Test duration must be greater than 32 secs */ 1276 &pjsip_options_method, 1, 0, 0); 1316 status = perform_test(TARGET_URI, FROM_URI, TEST2_BRANCH_ID, 1317 duration, &pjsip_options_method, 1, 0, 0); 1277 1318 if (status != 0) 1278 1319 return status; … … 1290 1331 static int tsx_basic_provisional_response_test(void) 1291 1332 { 1333 unsigned duration; 1292 1334 int status; 1293 1335 1294 1336 PJ_LOG(3,(THIS_FILE," test3: basic sending 2xx final response")); 1295 1337 1296 status = perform_test("sip:129.0.0.1;transport=loop-dgram",1297 "sip:129.0.0.1;transport=loop-dgram", 1298 TEST3_BRANCH_ID, 1299 35,1338 duration = (tp_flag & PJSIP_TRANSPORT_RELIABLE) ? 1 : 33; 1339 duration += 2; 1340 1341 status = perform_test(TARGET_URI, FROM_URI, TEST3_BRANCH_ID, duration, 1300 1342 &pjsip_options_method, 1, 0, 0); 1301 1343 … … 1321 1363 PJ_LOG(3,(THIS_FILE," %s", title)); 1322 1364 1323 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1324 "sip:129.0.0.1;transport=loop-dgram", 1325 branch_id, 1326 5, 1365 status = perform_test(TARGET_URI, FROM_URI, branch_id, 5, 1327 1366 &pjsip_options_method, 1328 1367 request_cnt, 1000, 1); … … 1358 1397 " test7: INVITE non-2xx final response retransmission")); 1359 1398 1360 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1361 "sip:129.0.0.1;transport=loop-dgram", 1362 TEST7_BRANCH_ID, 1399 status = perform_test(TARGET_URI, FROM_URI, TEST7_BRANCH_ID, 1363 1400 33, /* Test duration must be greater than 32 secs */ 1364 1401 &pjsip_invite_method, 1, 0, 0); … … 1369 1406 " test8: INVITE 2xx final response retransmission")); 1370 1407 1371 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1372 "sip:129.0.0.1;transport=loop-dgram", 1373 TEST8_BRANCH_ID, 1408 status = perform_test(TARGET_URI, FROM_URI, TEST8_BRANCH_ID, 1374 1409 33, /* Test duration must be greater than 32 secs */ 1375 1410 &pjsip_invite_method, 1, 0, 0); … … 1395 1430 " test9: receiving ACK for non-2xx final response")); 1396 1431 1397 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1398 "sip:129.0.0.1;transport=loop-dgram", 1399 TEST9_BRANCH_ID, 1432 status = perform_test(TARGET_URI, FROM_URI, TEST9_BRANCH_ID, 1400 1433 20, /* allow 5 retransmissions */ 1401 1434 &pjsip_invite_method, 1, 0, 0); … … 1444 1477 pjsip_loop_set_delay(loop, tests[i].transport_delay); 1445 1478 1446 status = perform_test("sip:129.0.0.1;transport=loop-dgram", 1447 "sip:129.0.0.1;transport=loop-dgram", 1448 tests[i].branch_id, 1449 0, 1450 &pjsip_invite_method, 1, 0, 1); 1479 status = perform_test(TARGET_URI, FROM_URI, tests[i].branch_id, 1480 0, &pjsip_invite_method, 1, 0, 1); 1451 1481 if (status && status != TEST_TIMEOUT_ERROR) 1452 1482 return status; … … 1495 1525 ***************************************************************************** 1496 1526 */ 1497 int tsx_uas_test( void)1527 int tsx_uas_test(struct tsx_test_param *param) 1498 1528 { 1499 1529 pj_sockaddr_in addr; 1500 1530 pj_status_t status; 1531 1532 test_param = param; 1533 tp_flag = pjsip_transport_get_flag_from_type(param->type); 1534 1535 pj_ansi_sprintf(TARGET_URI, "sip:bob@127.0.0.1:%d;transport=%s", 1536 param->port, param->tp_type); 1537 pj_ansi_sprintf(FROM_URI, "sip:alice@127.0.0.1:%d;transport=%s", 1538 param->port, param->tp_type); 1501 1539 1502 1540 /* Check if loop transport is configured. */ … … 1505 1543 if (status != PJ_SUCCESS) { 1506 1544 PJ_LOG(3,(THIS_FILE, " Error: loop transport is not configured!")); 1507 return -1; 1508 } 1509 1545 return -10; 1546 } 1510 1547 /* Register modules. */ 1511 1548 status = pjsip_endpt_register_module(endpt, &tsx_user); … … 1551 1588 return status; 1552 1589 1553 /* TEST6_BRANCH_ID: retransmit last response in PROCEEDING state 1590 /* TEST6_BRANCH_ID: retransmit last response in COMPLETED state 1591 * This only applies to non-reliable transports, 1592 * since UAS transaction is destroyed as soon 1593 * as final response is sent for reliable transports. 1554 1594 */ 1555 status = tsx_retransmit_last_response_test(TEST6_TITLE, 1556 TEST6_BRANCH_ID, 1557 TEST6_REQUEST_COUNT, 1558 TEST6_STATUS_CODE); 1559 if (status != 0) 1560 return status; 1595 if ((tp_flag & PJSIP_TRANSPORT_RELIABLE) == 0) { 1596 status = tsx_retransmit_last_response_test(TEST6_TITLE, 1597 TEST6_BRANCH_ID, 1598 TEST6_REQUEST_COUNT, 1599 TEST6_STATUS_CODE); 1600 if (status != 0) 1601 return status; 1602 } 1561 1603 1562 1604 /* TEST7_BRANCH_ID: INVITE non-2xx final response retransmission test 1563 1605 * TEST8_BRANCH_ID: INVITE 2xx final response retransmission test 1564 1606 */ 1565 1566 1607 status = tsx_final_response_retransmission_test(); 1567 1608 if (status != 0) … … 1570 1611 /* TEST9_BRANCH_ID: retransmission of non-2xx INVITE final response must 1571 1612 * cease when ACK is received 1613 * Only applicable for non-reliable transports. 1572 1614 */ 1573 status = tsx_ack_test(); 1574 if (status != 0) 1575 return status; 1615 if ((tp_flag & PJSIP_TRANSPORT_RELIABLE) == 0) { 1616 status = tsx_ack_test(); 1617 if (status != 0) 1618 return status; 1619 } 1620 1576 1621 1577 1622 /* TEST10_BRANCH_ID: test transport failure in TRYING state. … … 1580 1625 * TEST13_BRANCH_ID: test transport failure in CONFIRMED state. 1581 1626 */ 1582 status = tsx_transport_failure_test(); 1583 if (status != 0) 1584 return status; 1585 1586 1587 pjsip_transport_dec_ref(loop); 1627 /* Only valid for loop-dgram */ 1628 if (param->type == PJSIP_TRANSPORT_LOOP_DGRAM) { 1629 status = tsx_transport_failure_test(); 1630 if (status != 0) 1631 return status; 1632 } 1633 1634 1635 /* Register modules. */ 1636 status = pjsip_endpt_unregister_module(endpt, &tsx_user); 1637 if (status != PJ_SUCCESS) { 1638 app_perror(" Error: unable to unregister module", status); 1639 return -8; 1640 } 1641 status = pjsip_endpt_unregister_module(endpt, &msg_sender); 1642 if (status != PJ_SUCCESS) { 1643 app_perror(" Error: unable to unregister module", status); 1644 return -9; 1645 } 1646 1647 1648 if (loop) 1649 pjsip_transport_dec_ref(loop); 1650 1588 1651 return 0; 1589 1590 1652 } 1591 1653
Note: See TracChangeset
for help on using the changeset viewer.