Ignore:
Timestamp:
Jun 27, 2008 9:12:12 PM (16 years ago)
Author:
nanang
Message:

Ticket #543:

  • added options to run.py
  • passing options in runall.py to run.py
  • removing userdata in module callback functions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/test-pjsua/runall.py

    r2071 r2078  
    33import sys 
    44import time 
     5import re 
     6import shutil 
     7 
    58 
    69# Usage: 
     
    5457resume_script="" 
    5558if len(sys.argv) > 1: 
    56     if sys.argv[1][0]=='-' or sys.argv[1][0]=='/': 
     59    if sys.argv[1]=='-r' or sys.argv[1]=='--resume': 
     60        resume_script=sys.argv[2] 
     61    if sys.argv[1]=='/h' or sys.argv[1]=='-h' or sys.argv[1]=='--help' or sys.argv[1]=='/help': 
    5762        print "Usage:" 
    58         print "  runall.py [RESUME]" 
    59         print "where" 
    60         print "  RESUME is string/substring to specify where to resume tests." 
    61         print "  If this argument is omited, tests will start from the beginning." 
     63        print "  runall.py [OPTIONS] [run.py OPTIONS]" 
     64        print "Options:" 
     65        print "  --resume,-r RESUME" 
     66        print "  where" 
     67        print "      RESUME is string/substring to specify where to resume tests." 
     68        print "      If this argument is omited, tests will start from the beginning." 
    6269        sys.exit(0) 
    63     resume_script=sys.argv[1] 
    6470 
     71 
     72# Generate arguments for run.py 
     73argv = sys.argv 
     74argv_to_skip = 1 
     75if resume_script != "": 
     76    argv_to_skip += 2 
     77argv_st = "" 
     78for a in argv: 
     79    if argv_to_skip > 0: 
     80        argv_to_skip -= 1 
     81    else: 
     82        argv_st += a + " " 
     83 
     84 
     85# Init vars 
     86failed_cnt = 0 
     87 
     88# Create "logs" directory 
     89try: 
     90    os.mkdir("logs") 
     91except: 
     92    print 
    6593 
    6694# Now run the tests 
     
    7098            continue 
    7199        resume_script="" 
    72         cmdline = "python run.py " + t 
     100        cmdline = "python run.py " + argv_st + t 
    73101        t0 = time.time() 
    74102        print "Running " + cmdline + "...", 
     
    78106                dur = int(t1 - t0) 
    79107                print " failed!! [" + str(dur) + "s]" 
    80                 print "Please see 'output.log' for the test log." 
    81                 sys.exit(1) 
     108                logname = re.search(".*\s+(.*)", t).group(1) 
     109                logname = re.sub("[\\\/]", "_", logname) 
     110                logname = "logs/" + logname 
     111                shutil.move("output.log", logname) 
     112                print "Please see '" + logname + "' for the test log." 
    82113        else: 
    83114                dur = int(t1 - t0) 
    84115                print " ok [" + str(dur) + "s]" 
    85116 
    86 print "All tests completed successfully" 
     117if failed_cnt == 0: 
     118        print "All tests completed successfully" 
     119else: 
     120        print "Tests completed, with " +  str(failed_cnt) + " test(s) failed" 
     121 
Note: See TracChangeset for help on using the changeset viewer.