Changeset 3120


Ignore:
Timestamp:
Mar 23, 2010 2:03:30 PM (14 years ago)
Author:
bennylp
Message:

Ticket #1041:

  • initial work for GNU targets
Location:
pjproject/trunk/tests
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/tests/pjsua/runall.py

    r2398 r3120  
    5858    tests = [t for t in tests if t.find(pat)==-1] 
    5959 
    60 # List the tests only? 
    61 if len(sys.argv)==2 and sys.argv[1]=="--list": 
    62     for t in tests: 
    63         print t 
    64     sys.exit(0) 
    6560 
    66 # Resume test? 
    6761resume_script="" 
    68 if len(sys.argv) > 1: 
    69     if sys.argv[1]=='-r' or sys.argv[1]=='--resume': 
    70         resume_script=sys.argv[2] 
    71     if sys.argv[1]=='/h' or sys.argv[1]=='-h' or sys.argv[1]=='--help' or sys.argv[1]=='/help': 
    72         print "Usage:" 
    73         print "  runall.py [OPTIONS] [run.py-OPTIONS]" 
    74         print "Options:" 
    75         print "  --resume,-r RESUME" 
    76         print "      RESUME is string/substring to specify where to resume tests." 
    77         print "      If this argument is omited, tests will start from the beginning." 
    78         print "  run.py-OPTIONS are applicable here" 
    79         sys.exit(0) 
     62shell_cmd="" 
     63 
     64# Parse arguments 
     65sys.argv.pop(0) 
     66while len(sys.argv): 
     67        if sys.argv[0]=='/h' or sys.argv[0]=='-h' or sys.argv[0]=='--help' or sys.argv[0]=='/help': 
     68                sys.argv.pop(0) 
     69                print "Usage:" 
     70                print "  runall.py [OPTIONS] [run.py-OPTIONS]" 
     71                print "OPTIONS:" 
     72                print " --list" 
     73                print "     List the tests" 
     74                print "  --list-xml" 
     75                print "     List the tests as XML format suitable for ccdash" 
     76                print "  --resume,-r RESUME" 
     77                print "      RESUME is string/substring to specify where to resume tests." 
     78                print "      If this argument is omited, tests will start from the beginning." 
     79                print "  --shell,-s SHELL" 
     80                print "      Run the tests with the specified SHELL cmd. This can also be" 
     81                print "      used to run the test with ccdash. Example:" 
     82                print "        --shell '/bin/sh -c'" 
     83                print "  run.py-OPTIONS are applicable here" 
     84                sys.exit(0) 
     85        elif sys.argv[0] == '-r' or sys.argv[0] == '--resume': 
     86                if len(sys.argv) > 1: 
     87                        resume_script=sys.argv[1] 
     88                        sys.argv.pop(0) 
     89                        sys.argv.pop(1) 
     90                else: 
     91                        sys.argv.pop(0) 
     92                        sys.stderr.write("Error: argument value required") 
     93                        sys.exit(1) 
     94        elif sys.argv[0] == '--list': 
     95                sys.argv.pop(0) 
     96                for t in tests: 
     97                      print t 
     98                sys.exit(0) 
     99        elif sys.argv[0] == '--list-xml': 
     100                sys.argv.pop(0) 
     101                for t in tests: 
     102                        (mod,param) = t.split(None,2) 
     103                        tname = mod[4:mod.find(".py")] + "_" + \ 
     104                                param[param.find("/")+1:param.find(".py")] 
     105                        tcmd = 'python run.py ' + t 
     106                        print '\t\t<Test name="%s" cmd="%s" wdir="tests/pjsua" />' % (tname, tcmd) 
     107                sys.exit(0) 
     108        elif sys.argv[0] == '-s' or sys.argv[0] == '--shell': 
     109                if len(sys.argv) > 1: 
     110                        shell_cmd = sys.argv[1] 
     111                        sys.argv.pop(0) 
     112                        sys.argv.pop(1) 
     113                else: 
     114                        sys.argv.pop(0) 
     115                        sys.stderr.write("Error: argument value required") 
     116                        sys.exit(1) 
    80117 
    81118 
    82119# Generate arguments for run.py 
    83 argv = sys.argv 
    84 argv_to_skip = 1 
    85 if resume_script != "": 
    86     argv_to_skip += 2 
    87 argv_st = "" 
    88 for a in argv: 
    89     if argv_to_skip > 0: 
    90         argv_to_skip -= 1 
    91     else: 
    92         argv_st += a + " " 
    93  
     120argv_st = " ".join(sys.argv) 
    94121 
    95122# Init vars 
     
    109136 
    110137# Now run the tests 
     138total_cnt = len(tests) 
    111139for t in tests: 
    112140        if resume_script!="" and t.find(resume_script)==-1: 
    113141            print "Skipping " + t +".." 
     142            total_cnt = total_cnt - 1 
    114143            continue 
    115144        resume_script="" 
    116145        cmdline = "python run.py " + argv_st + t 
     146        if shell_cmd: 
     147                cmdline = "%s '%s'" % (shell_cmd, cmdline) 
    117148        t0 = time.time() 
    118         print "Running " + cmdline + "...", 
     149        msg = "Running %d/%d: %s..." % (tests_cnt+1, total_cnt, cmdline) 
     150        sys.stdout.write(msg) 
     151        sys.stdout.flush() 
    119152        ret = os.system(cmdline + " > output.log") 
    120153        t1 = time.time() 
Note: See TracChangeset for help on using the changeset viewer.