コード例 #1
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "ho:", ["help",
            "protocol=","claims=","run-max=","run-step=",
            "output=","output-if","tools="])
    except:
        print "Could not parse arguments."
        usage()
        sys.exit(1)
    if args != []:
        print "Superflous arguments %s not recognized." % args
        usage()
        sys.exit(1)

    # Init
    Report.replog("Scanning main")
    prots = gatherClaims()
    Report.replog(repr(prots)+"\n")

    # Parse options
    (runmin,runmax,runstep) = TestConfig.getMaxProc()
    filter = None
    fclaim = None
    TestConfig.setGlobalOptions()   # Init global dict
    for o,a in opts:
        if o in ("-h","--help"):
            usage()
            sys.exit()
        elif o == "--protocol":
            filter = a
        elif o == "--claims":
            fclaim = a
        elif o == "--tools":
            go = TestConfig.setGlobalOption("tools",a.split(","))
        elif o == "--run-max":
            runmax = int(a)
            if runmax < runmin:
                runmin = runmax
        elif o == "--run-step":
            runstep = int(a)
            if runstep <= 0:
                assert False, "Run step number must be more than 0"
        elif o in ["-o","--output"]:
            Report.setFile(a)
        elif o == "--output-if":
            TestConfig.addGlobalOption(o)
        else:
            uo = "Unhandled option '%s'" % o
            assert False, uo

    proc = runmin
    while proc <= runmax:
        to = TestConfig.getTimeout(maxproc=proc)
        Report.separator()
        Report.replog("Testing performance for MaxProc(%i) from range (%i,%i,%i)" % (proc,runmin,runmax,runstep ))
        Report.replog("Using timeout of %i seconds" % (to))
        Report.replog("Current time and date: %s" % (time.asctime()))
        Report.separator()

        if filter in prots.keys():
            doProtocol(prots,filter,fclaim,maxproc=proc)
        else:
            for pn in prots.keys():
                doProtocol(prots,pn,maxproc=proc)
        proc += runstep