diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-06-16 13:04:44 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-06-16 13:04:44 +0000 |
commit | 67de577315598ed2b274592283110a67a4219a70 (patch) | |
tree | 70252f81c721cc590db822de704607fc56abcb41 /pjsip-apps/src/test-pjsua | |
parent | 9c5b754daa934f2d80b2333c4eb0ec90965a391d (diff) |
More ticket #543: updated automated tests to run on Unix
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2028 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/test-pjsua')
-rw-r--r-- | pjsip-apps/src/test-pjsua/run.py | 45 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/runall.py | 21 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py | 2 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/scripts-pres/200_publish.py | 10 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/scripts-run/100_simple.py | 4 | ||||
-rw-r--r-- | pjsip-apps/src/test-pjsua/scripts-run/200_register.py | 4 |
6 files changed, 72 insertions, 14 deletions
diff --git a/pjsip-apps/src/test-pjsua/run.py b/pjsip-apps/src/test-pjsua/run.py index ecc872f5..0b374def 100644 --- a/pjsip-apps/src/test-pjsua/run.py +++ b/pjsip-apps/src/test-pjsua/run.py @@ -1,14 +1,46 @@ -# $Id:$ +# $Id$ import sys import imp import re +import os import subprocess +import random import time import inc_const as const -# Defaults -G_EXE="..\\..\\bin\\pjsua_vc6d.exe" +# Get the pjsua executable name +if sys.platform.find("win32")!=-1: + e = "../../bin/pjsua_vc6d.exe" + st1 = os.stat(e) + if st1 != None: + G_EXE = e + e = "../../bin/pjsua_vc6d.exe" + st2 = os.stat(e) + if st2 != None and st2.st_mtime > st1.st_mtime: + G_EXE = e + st1 = st2 + if G_EXE=="": + print "Unable to find valid pjsua. Please build pjsip first" + sys.exit(1) + G_INUNIX = False +else: + f = open("../../../build.mak", "r") + while True: + line = f.readline() + if not line: + break + if line.find("TARGET_NAME")!=-1: + print line + G_EXE="../../bin/pjsua-" + line.split(":= ")[1] + break + if G_EXE=="": + print "Unable to find ../../../build.mak. Please build pjsip first" + sys.exit(1) + G_INUNIX = True + + +G_EXE = G_EXE.rstrip("\n\r \t") ################################### # TestError exception @@ -35,7 +67,7 @@ class Expect: self.trace_enabled = inst_param.trace_enabled fullcmd = G_EXE + " " + inst_param.arg + " --stdout-refresh=5 --stdout-refresh-text=" + const.STDOUT_REFRESH self.trace("Popen " + fullcmd) - self.proc = subprocess.Popen(fullcmd, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) + self.proc = subprocess.Popen(fullcmd, shell=G_INUNIX, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) def send(self, cmd): self.trace("send " + cmd) self.proc.stdin.writelines(cmd + "\n") @@ -108,6 +140,9 @@ if len(sys.argv)!=3: # Import the test script script = imp.load_source("script", sys.argv[1]) +# Init random seed +random.seed() + # Validate if script.test == None: print "Error: no test defined" @@ -119,6 +154,8 @@ if len(script.test.inst_params) == 0: # Instantiate pjsuas print "====== Running " + script.test.title + " ======" +print "Using " + G_EXE + " as pjsua executable" + for inst_param in script.test.inst_params: try: # Create pjsua's Expect instance from the param diff --git a/pjsip-apps/src/test-pjsua/runall.py b/pjsip-apps/src/test-pjsua/runall.py index 41656345..dc1119da 100644 --- a/pjsip-apps/src/test-pjsua/runall.py +++ b/pjsip-apps/src/test-pjsua/runall.py @@ -2,6 +2,10 @@ import os import sys +# Usage: +# runall.py [test-to-resume] + + # Initialize test list tests = [] @@ -28,8 +32,25 @@ for f in os.listdir("scripts-pres"): for pat in excluded_tests: tests = [t for t in tests if t.find(pat)==-1] +# Resume test? +resume_script="" +if len(sys.argv) > 1: + if sys.argv[1][0]=='-' or sys.argv[1][0]=='/': + print "Usage:" + print " runall.py [RESUME]" + print "where" + print " RESUME is string/substring to specify where to resume tests." + print " If this argument is omited, tests will start from the beginning." + sys.exit(0) + resume_script=sys.argv[1] + + # Now run the tests for t in tests: + if resume_script!="" and t.find(resume_script)==-1: + print "Skipping " + t +".." + continue + resume_script="" cmdline = "python run.py " + t print "Running " + cmdline ret = os.system(cmdline + " > output.log") diff --git a/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py b/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py index 52b5f358..3414f17c 100644 --- a/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py +++ b/pjsip-apps/src/test-pjsua/scripts-call/200_tcp.py @@ -6,7 +6,7 @@ from inc_cfg import * test_param = TestParam( "TCP transport", [ - InstanceParam("callee", "--null-audio --no-udp", uri_param=";transport=tcp --max-calls=1"), + InstanceParam("callee", "--null-audio --no-udp --max-calls=1", uri_param=";transport=tcp"), InstanceParam("caller", "--null-audio --no-udp --max-calls=1") ] ) diff --git a/pjsip-apps/src/test-pjsua/scripts-pres/200_publish.py b/pjsip-apps/src/test-pjsua/scripts-pres/200_publish.py index f73ffa5d..50308a58 100644 --- a/pjsip-apps/src/test-pjsua/scripts-pres/200_publish.py +++ b/pjsip-apps/src/test-pjsua/scripts-pres/200_publish.py @@ -1,4 +1,4 @@ -# $Id:$ +# $Id$ # from inc_cfg import * @@ -8,24 +8,24 @@ test_param = TestParam( [ InstanceParam( "ua1", "--null-audio"+ - " --id=<sip:test1@pjsip.org>"+ + " --id=\"<sip:test1@pjsip.org>\""+ " --registrar=sip:sip.pjsip.org" + " --username=test1" + " --password=test1" + " --realm=*" + - " --proxy=sip:sip.pjsip.org;lr" + + " --proxy=\"sip:sip.pjsip.org;lr\"" + " --publish", uri="<sip:test1@pjsip.org>", have_reg=True, have_publish=True), InstanceParam( "ua2", "--null-audio"+ - " --id=<sip:test2@pjsip.org>"+ + " --id=\"<sip:test2@pjsip.org>\""+ " --registrar=sip:sip.pjsip.org" + " --username=test2" + " --password=test2" + " --realm=*" + - " --proxy=sip:sip.pjsip.org;lr" + + " --proxy=\"sip:sip.pjsip.org;lr\"" + " --publish", uri="<sip:test2@pjsip.org>", have_reg=True, diff --git a/pjsip-apps/src/test-pjsua/scripts-run/100_simple.py b/pjsip-apps/src/test-pjsua/scripts-run/100_simple.py index f1e13cfc..7ab96efc 100644 --- a/pjsip-apps/src/test-pjsua/scripts-run/100_simple.py +++ b/pjsip-apps/src/test-pjsua/scripts-run/100_simple.py @@ -1,4 +1,4 @@ -# $Id:$ +# $Id$ # # Just about the simple pjsua command line parameter, which should # never fail in any circumstances @@ -7,7 +7,7 @@ from inc_cfg import * test_param = TestParam( "Basic run", [ - InstanceParam("pjsua", "--null-audio --local-port 0 --rtp-port 0") + InstanceParam("pjsua", "--null-audio --rtp-port 0") ] ) diff --git a/pjsip-apps/src/test-pjsua/scripts-run/200_register.py b/pjsip-apps/src/test-pjsua/scripts-run/200_register.py index 34f837c8..3f4338d1 100644 --- a/pjsip-apps/src/test-pjsua/scripts-run/200_register.py +++ b/pjsip-apps/src/test-pjsua/scripts-run/200_register.py @@ -1,4 +1,4 @@ -# $Id:$ +# $Id$ # from inc_cfg import * @@ -8,7 +8,7 @@ test_param = TestParam( [ InstanceParam( "client", "--null-audio"+ - " --id=<sip:test1@pjsip.org>"+ + " --id=\"<sip:test1@pjsip.org>\""+ " --registrar=sip:sip.pjsip.org" + " --username=test1" + " --password=test1" + |