Bring the dead pjsip-test up to date with latest pjsip

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@555 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/test-pjsip/test.c b/pjsip/src/test-pjsip/test.c
index f3d4833..b870733 100644
--- a/pjsip/src/test-pjsip/test.c
+++ b/pjsip/src/test-pjsip/test.c
@@ -125,15 +125,33 @@
 	goto on_return;
     }
 
+#if INCLUDE_URI_TEST
     DO_TEST(uri_test());
+#endif
+
+#if INCLUDE_MSG_TEST
     DO_TEST(msg_test());
     DO_TEST(msg_err_test());
+#endif
+
+#if INCLUDE_TXDATA_TEST
     DO_TEST(txdata_test());
+#endif
+
+#if INCLUDE_UDP_TEST
     DO_TEST(transport_udp_test());
+#endif
+
+#if INCLUDE_LOOP_TEST
     DO_TEST(transport_loop_test());
+#endif
+
+#if INCLUDE_TSX_TEST
     DO_TEST(tsx_basic_test());
     DO_TEST(tsx_uac_test());
     DO_TEST(tsx_uas_test());
+#endif
+
 
 on_return:
 
diff --git a/pjsip/src/test-pjsip/test.h b/pjsip/src/test-pjsip/test.h
index 7c549a3..f2b6b91 100644
--- a/pjsip/src/test-pjsip/test.h
+++ b/pjsip/src/test-pjsip/test.h
@@ -26,6 +26,22 @@
 #define TEST_UDP_PORT	    15060
 #define TEST_UDP_PORT_STR   "15060"
 
+
+#define INCLUDE_MESSAGING_GROUP	    1
+#define INCLUDE_TRANSPORT_GROUP	    1
+#define INCLUDE_TSX_GROUP	    1
+
+
+
+#define INCLUDE_URI_TEST	INCLUDE_MESSAGING_GROUP
+#define INCLUDE_MSG_TEST	INCLUDE_MESSAGING_GROUP
+#define INCLUDE_TXDATA_TEST	INCLUDE_MESSAGING_GROUP
+#define INCLUDE_UDP_TEST	INCLUDE_TRANSPORT_GROUP
+#define INCLUDE_LOOP_TEST	INCLUDE_TRANSPORT_GROUP
+#define INCLUDE_TSX_TEST	INCLUDE_TSX_GROUP
+
+
+
 /* The tests */
 int uri_test(void);
 int msg_test(void);
diff --git a/pjsip/src/test-pjsip/tsx_uac_test.c b/pjsip/src/test-pjsip/tsx_uac_test.c
index 262e5ce..d2717fe 100644
--- a/pjsip/src/test-pjsip/tsx_uac_test.c
+++ b/pjsip/src/test-pjsip/tsx_uac_test.c
@@ -946,11 +946,11 @@
     status = pjsip_tsx_send_msg(tsx, NULL);
     // Ignore send result. Some tests do deliberately triggers error
     // when sending message.
-    //if (status != PJ_SUCCESS) {
-    //	app_perror("   Error: unable to send request", status);
-    //  pjsip_tx_data_dec_ref(tdata);
-    //	return -120;
-    //}
+    if (status != PJ_SUCCESS) {
+	// app_perror("   Error: unable to send request", status);
+        pjsip_tx_data_dec_ref(tdata);
+	// return -120;
+    }
 
 
     /* Set test completion time. */
diff --git a/pjsip/src/test-pjsip/tsx_uas_test.c b/pjsip/src/test-pjsip/tsx_uas_test.c
index 632950f..3ff2e18 100644
--- a/pjsip/src/test-pjsip/tsx_uas_test.c
+++ b/pjsip/src/test-pjsip/tsx_uas_test.c
@@ -444,11 +444,16 @@
 	/*
 	 * TEST4_BRANCH_ID tests receiving retransmissions in TRYING state.
 	 */
-	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+	if (tsx->state == PJSIP_TSX_STATE_TRYING) {
+	    /* Request is received. */
+	} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
 
 	    /* Check that status code is status_code. */
 	    if (tsx->status_code != TEST4_STATUS_CODE) {
-		PJ_LOG(3,(THIS_FILE, "    error: incorrect status code"));
+		PJ_LOG(3,(THIS_FILE, 
+			  "    error: incorrect status code %d "
+			  "(expecting %d)", tsx->status_code,
+			  TEST4_STATUS_CODE));
 		test_complete = -120;
 	    }
 	    
@@ -460,7 +465,8 @@
 
 	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) 
 	{
-	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state"));
+	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state %s (122)",
+		      pjsip_tsx_state_str(tsx->state)));
 	    test_complete = -122;
 
 	}
@@ -471,7 +477,10 @@
 	/*
 	 * TEST5_BRANCH_ID tests receiving retransmissions in PROCEEDING state
 	 */
-	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+	if (tsx->state == PJSIP_TSX_STATE_TRYING) {
+	    /* Request is received. */
+
+	} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
 
 	    /* Check that status code is status_code. */
 	    if (tsx->status_code != TEST5_STATUS_CODE) {
@@ -494,7 +503,8 @@
 	    }
 
 	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED) {
-	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state"));
+	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state %s (133)",
+		      pjsip_tsx_state_str(tsx->state)));
 	    test_complete = -133;
 
 	}
@@ -504,7 +514,10 @@
 	/*
 	 * TEST6_BRANCH_ID tests receiving retransmissions in COMPLETED state
 	 */
-	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+	if (tsx->state == PJSIP_TSX_STATE_TRYING) {
+	    /* Request is received. */
+
+	} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
 
 	    /* Check that status code is status_code. */
 	    if (tsx->status_code != TEST6_STATUS_CODE) {
@@ -522,7 +535,8 @@
 		   tsx->state != PJSIP_TSX_STATE_COMPLETED &&
 		   tsx->state != PJSIP_TSX_STATE_DESTROYED) 
 	{
-	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state"));
+	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state %s (142)",
+		      pjsip_tsx_state_str(tsx->state)));
 	    test_complete = -142;
 
 	}
@@ -543,7 +557,10 @@
 	else
 	    code = TEST8_STATUS_CODE;
 
-	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+	if (tsx->state == PJSIP_TSX_STATE_TRYING) {
+	    /* Request is received. */
+
+	} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
 
 	    if (test_complete == 0)
 		test_complete = 1;
@@ -576,7 +593,7 @@
 
 	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED)  {
 
-	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state"));
+	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state (154)"));
 	    test_complete = -154;
 
 	}
@@ -589,7 +606,10 @@
 	 * must cease when ACK is received.
 	 */
 
-	if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+	if (tsx->state == PJSIP_TSX_STATE_TRYING) {
+	    /* Request is received. */
+
+	} else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
 
 	    if (test_complete == 0)
 		test_complete = 1;
@@ -637,7 +657,7 @@
 
 	} else if (tsx->state != PJSIP_TSX_STATE_DESTROYED)  {
 
-	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state"));
+	    PJ_LOG(3,(THIS_FILE, "    error: unexpected state (166)"));
 	    test_complete = -166;
 
 	}
@@ -745,7 +765,7 @@
 	    status = pjsip_tsx_create_uas(&tsx_user, rdata, &tsx);
 	    if (status != PJ_SUCCESS) {
 		app_perror("    error: unable to create transaction", status);
-		test_complete = -120;
+		test_complete = -116;
 		return PJ_TRUE;
 	    }
 	    pjsip_tsx_recv_msg(tsx, rdata);
@@ -1271,7 +1291,7 @@
 {
     int status;
 
-    PJ_LOG(3,(THIS_FILE,"  test1: basic sending 2xx final response"));
+    PJ_LOG(3,(THIS_FILE,"  test3: basic sending 2xx final response"));
 
     status = perform_test("sip:129.0.0.1;transport=loop-dgram",
 		          "sip:129.0.0.1;transport=loop-dgram",