Ticket #543: added TCP call in pjsua unit test

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@2013 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip-apps/src/test-pjsua/inc_cfg.py b/pjsip-apps/src/test-pjsua/inc_cfg.py
index cf5f611..a800fe5 100644
--- a/pjsip-apps/src/test-pjsua/inc_cfg.py
+++ b/pjsip-apps/src/test-pjsua/inc_cfg.py
@@ -18,6 +18,8 @@
 

 # Call config class

 class CallConfig:

+	# additional parameter to be added to target URI

+	uri_param = ""

 	def __init__(self, title, callee_cfg, caller_cfg):

 		self.title = title

 		self.callee_cfg = callee_cfg

diff --git a/pjsip-apps/src/test-pjsua/inc_param.py b/pjsip-apps/src/test-pjsua/inc_param.py
index e897d14..7fa2371 100644
--- a/pjsip-apps/src/test-pjsua/inc_param.py
+++ b/pjsip-apps/src/test-pjsua/inc_param.py
@@ -31,7 +31,7 @@
 # Test parameter class

 class Test:

 	title = ""

-	# params is list containing PjsuaParam objects

+	# params is list containing Pjsua objects

 	run = []

 	# list of Expect instances, to be filled at run-time by

         # the test program	

diff --git a/pjsip-apps/src/test-pjsua/mod_call.py b/pjsip-apps/src/test-pjsua/mod_call.py
index b047f07..07f5a0e 100644
--- a/pjsip-apps/src/test-pjsua/mod_call.py
+++ b/pjsip-apps/src/test-pjsua/mod_call.py
@@ -35,7 +35,7 @@
 

 	# Caller making call

 	caller.send("m")

-	caller.send("sip:localhost:" + port1)

+	caller.send("sip:localhost:" + port1 + cfg_file.config.uri_param)

 	caller.expect(const.STATE_CALLING)

 	

 	# Callee answers with 200/OK

diff --git a/pjsip-apps/src/test-pjsua/run.py b/pjsip-apps/src/test-pjsua/run.py
index 16d23ca..4a7c0d3 100644
--- a/pjsip-apps/src/test-pjsua/run.py
+++ b/pjsip-apps/src/test-pjsua/run.py
@@ -47,20 +47,23 @@
 		while True:

 			line = self.proc.stdout.readline()

 		  	if line == "":

-				raise TestError("Premature EOF")

+				raise TestError(self.name + ": Premature EOF")

 			# Print the line if echo is ON

 			if self.echo:

 				print self.name + ": " + line,

 			# Trap assertion error

 			if self.ra.search(line) != None:

-				raise TestError(line)

+				if raise_on_error:

+					raise TestError(self.name + ": " + line)

+				else:

+					return None

 			# Count stdout refresh text. 

 			if self.rr.search(line) != None:

 				refresh_cnt = refresh_cnt+1

 				if refresh_cnt >= 6:

 					self.trace("Timed-out!")

 					if raise_on_error:

-						raise TestError("Timeout expecting pattern: " + pattern)

+						raise TestError(self.name + ": Timeout expecting pattern: " + pattern)

 					else:

 						return None		# timeout

 			# Search for expected text

@@ -80,7 +83,7 @@
 	time.sleep(1)

 	for p in t.process:

 		p.send("q")

-		p.expect(const.DESTROYED)

+		p.expect(const.DESTROYED, False)

 		p.wait()

 	print "Test completed with error: " + errmsg

 	sys.exit(1)

@@ -117,6 +120,7 @@
 		p.expect(const.PROMPT)

 		p.send("echo 1")

 		p.send("echo 1")

+		p.expect("echo 1")

 		# add running instance

 		script.test.process.append(p)

 		# run initial script

@@ -143,7 +147,7 @@
 for p in script.test.process:

 	p.send("q")

 	time.sleep(0.5)

-	p.expect(const.DESTROYED)

+	p.expect(const.DESTROYED, False)

 	p.wait()

 

 # Done

diff --git a/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py b/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py
new file mode 100644
index 0000000..62bdee1
--- /dev/null
+++ b/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py
@@ -0,0 +1,11 @@
+# $Id:$
+#
+import inc_cfg
+
+# Simple call
+config = inc_cfg.CallConfig(
+		title = "TCP transport",
+		callee_cfg = inc_cfg.Config(arg="--null-audio --no-udp"),
+		caller_cfg = inc_cfg.Config(arg="--null-audio --no-udp")
+		)
+config.uri_param = ";transport=tcp"