当前位置: 首页>>代码示例>>Python>>正文


Python sut.restart函数代码示例

本文整理汇总了Python中sut.restart函数的典型用法代码示例。如果您正苦于以下问题:Python restart函数的具体用法?Python restart怎么用?Python restart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了restart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():				
	global ntests,start
	while time.time()-start < timeout:
		
		for ts in xrange(0,width):
			sut.restart()
			ntests += 1
			if (Stest != None ) and (r.random() > 0.6):
				sut.backtrack(Stest)
		
			randomAction()
		
		for b in sut.currBranches():
			if b not in covCount:
				covCount[b] = 0
			covCount[b] += 1
			sortedCov = sorted(covCount.keys(), key = lambda x: covCount[x]) 
			LCov = sortedCov[0]
		
    		if time.time()-start > timeout:
        		print "THE TEST IS STOPPED SINCE TIMEOUT"
        		break 

	sortedCov = sorted(covCount.keys(), key = lambda x: covCount[x])		

	if coverage:
		print"Show Coverage"
        	sut.internalReport()
	
	print ntests,"TOTAL TESTS"    
	print "TOTAL BUGS",bugs
	print "TOTAL ACTIONS",actCount
	print "TOTAL RUNTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:33,代码来源:tester2.py

示例2: action

def action():
    global actCount, bugs, failPool
    act = sut.randomEnabled(rgen)
    actCount += 1
    ok = sut.safely(act)
    if running == 1:
            if len(sut.newBranches()) > 0:
                print "ACTION:", act[0]
                for b in sut.newBranches():
                    print time.time() - start, len(sut.allBranches()), "New branch", b
                for s in sut.newStatements():
                    print time.time() - start, len(sut.allStatements()),"New statement",s
    
    if not ok:
        if faults:
            bugs += 1
            print "FOUND A FAILURE"
            print sut.failure()
            print "REDUCING"
            failPool.append(sut.test())
            collectCoverage()
            R = sut.reduce(sut.test(),sut.fails, True, True)
            sut.prettyPrintTest(R)
            print sut.failure()
            fname="failure" + str(bugs) + ".test"
            sut.saveTest(sut.test(),fname)
            errorSeqs.append(sut.currStatements())
            sut.restart()
    else: 
        expand()

    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:32,代码来源:tester2.py

示例3: randomAction

def randomAction():   
	global actCount,bugs,j,running,actCount,r
    
	test = False
	for b in xrange(0,depth):
		act = sut.randomEnabled(r)   
#		actCount += 1
		ok = sut.safely(act)
		Scheck = sut.check()
		if len(sut.newBranches()) > 0:
			Stest = sut.state()
			test = True
			
		if (not test) and (LCov != None) and (LCov in sut.currBranches()):
			Stest = sut.start()
			test = True
		actCount += 1
		
		if running == 1:
	        	if sut.newBranches() != set([]):
				print "ACTIONS:", act[0]
            			for b in sut.newBranches():
                			print time.time()-start,len(sut.allBranches()),"New branch",b
				
                if faults == 1:    
			if not ok: 
				print "FOUND A FAILURE"
				j += 1
				bugs += 1
				fault = sut.failure()
				failurename = 'failure' + str(bugs) + '.test'
				sut.saveTest(sut.test(), failurename)
				print"the bugs is ",j
				sut.restart()
开发者ID:agroce,项目名称:cs569sp16,代码行数:34,代码来源:tester2.py

示例4: phase1

def phase1(timeLimit):
    global ntest
    BUDGET = timeLimit
    DEPTH = opts.depth
    print "-------------------------------------------"
    print "PHASE 1: Starting\t(BUDGET:",BUDGET,"seconds,","DEPTH:",DEPTH,"tests)"
    phase_start = time.time()
    phase_test = ntest

    pool = Pool("randomPool")
    
    elapsed = time.time()-phase_start
    while elapsed < BUDGET and (time.time() - start) < opts.timeout:
        sut.restart()
        ntest += 1
        if opts.progress and ntest % 300:
            update_progress(elapsed/BUDGET)
        for s in xrange(0,DEPTH):
            if not randomAction(pool):
                break
        collectCoverage() # collecting coverage at the end of each test
        elapsed = time.time()-phase_start
    if opts.progress:
        update_progress(1.0)
    
    interval = time.time()-phase_start
    print "PHASE 1: Ending\t\t(EXECUTED:",(ntest - phase_test),"tests, USED:",round(interval,5),"seconds)"
    print "-------------------------------------------"
    return pool
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:tester1.py

示例5: randomAction

def randomAction():
    global actCount, bugs, coverageCount, belowMean,lastAddCoverage

    act = sut.randomEnabled(random.Random())
    actCount += 1
    ok = sut.safely(act)

    if running:
        if len(sut.newBranches()) > 0:
            print "ACTION:",sut.randomEnabled(random.Random(seed))[0]
            for b in sut.newBranches():
                print time.time() - start, len(sut.allBranches()),"New branch",b
            for s1 in sut.newStatements():
                print time.time() - start, len(sut.allStatements()),"New statement",b

    if not ok or not sut.check():
        bugs += 1
        print "FOUND A FAILURE"
        if faults:
            print("SHOW FAULT")
            print sut.failure()
            error.append(sut.test())
            R = sut.reduce(sut.test(),sut.fails, True, True)
            sut.prettyPrintTest(R)
            print sut.failure()
            sut.restart()

    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:28,代码来源:tester1.py

示例6: main

def main():
    global ntests
    while time.time()-start < timeout:
        for ts in xrange(0,width):
            sut.restart()
            ntests += 1
              
            loopBug()
          
            for s in sut.currBranches():
                if s not in covCount:
                    covCount[s] = 0
                covCount[s] += 1    
                sortedCov = sorted(covCount.keys(), key=lambda x: covCount[x])
                LCov= sortedCov[0]
        
            if (time.time() - start > timeout):
				print "THE TEST IS STOPPED SINCE TIMEOUT"
                                break
				
    sortedCov = sorted(covCount.keys(), key=lambda x: covCount[x])
    if coverage == 1:
	print "SHOW COVERAGE"
        sut.internalReport()
	
	print ntests, "TOTAL TESTS"
    print "TOTAL BUGS",bugs
    print "TOTAL ACTIONS",actCount
    print "TOTAL RUNNINGTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:finaltester.py

示例7: randomAction

def randomAction():   
    global actCount, bugs, fails, errCount, newCount
    sawNew = False
    act = sut.randomEnabled(seeds)
    actCount += 1
    ok = sut.safely(act)
    propok = sut.check()
   
    if running:
        if sut.newBranches() != set([]):
            for b in sut.newBranches():
                print time.time()-start,len(sut.allBranches()),"New branch",b
            sawNew = True
            newCount += 1
        else:
            sawNew = False    

    if not ok or not propok:
        if faults:
            bugs += 1
            fail.append(sut.test())
            saveCover()
            sut.restart()
            print "FAILURE FOUND.....FAILURES ARE STORING IN FILES"
            errCount += 1
            fault = sut.failure()
            fname = 'failure' + str(bugs) + '.test'
            sut.saveTest(sut.test(), fname)
            sut.restart() 

    else:
        expandPool()
    return ok 
开发者ID:agroce,项目名称:cs569sp16,代码行数:33,代码来源:finaltester.py

示例8: action

def action():
    global actCount, bugs, failPool
    act = sut.randomEnabled(rgen)
    actCount += 1
    ok = sut.safely(act)
    if running == 1:
            if len(sut.newBranches()) > 0:
                print "ACTION:", act[0]
                for b in sut.newBranches():
                    print time.time() - start, len(sut.allBranches()), "New branch", b
    if faults:
        if not ok:
            bugs += 1
            print "FOUND A FAILURE"
            print sut.failure()
            print "REDUCING"
            failPool.append(sut.test())
            collectCoverage()
            R = sut.reduce(sut.test(),sut.fails, True, True)
            sut.prettyPrintTest(R)
            print sut.failure()
            
            f = open(("failure" + str(bugs) + ".test"),"w")
            f.writelines(str(sut.failure()))
            f.close()
            
            sut.restart()
        else:
            expand()
    
    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:31,代码来源:tester1.py

示例9: phase2

def phase2(randomPool, selectPool):
    global ntest
    DEPTH = opts.depth
    print "PHASE 2: Starting\t(FILTER SET:", len(selectStatements),"DEPTH:",DEPTH,"tests)"
    phase_start = time.time()
    phase_test = ntest

    mean = calculateMean(selectStatements)
    initialMean = mean

    while mean < threshold and (time.time() - start) < opts.timeout:
        sut.restart()
        test = selectPool.getRandom()
        #sut.replay(test[0])
        sut.backtrack(test[1])
        ntest += 1
        if opts.progress and ntest % 10:
            update_progress((mean - initialMean)/threshold)
        for s in xrange(0,DEPTH):
            if not randomAction(selectPool):
                break
        mean = calculateMean(selectStatements)
        collectCoverage() # collecting coverage at the end of each test
    if opts.progress:
        update_progress(1.0)
    
    interval = time.time()-phase_start
    print "PHASE 2: Ending\t\t(EXECUTED:",(ntest - phase_test),"tests, USED:",round(interval,5),"seconds)"
    print "-------------------------------------------"
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:tester1.py

示例10: main

def main():
    global flag,timeout,sut,test,para,currStatements,coverageNum,sortedCov,weight,weightedCov,coverageWBM,bugs,actNum,start
    while time.time()-start < timeout:
        sut.restart()
        if (test != None):
            if (rgen.random() > exp):
                sut.backtrack(test)
        para = False
        for s in xrange(0,lenth):
            tester()
            if flag == 1:
                break
        for s in sut.currStatements():
            if s not in coverageNum:
                coverageNum[s] = 0
            coverageNum[s] += 1
        sortedCov = sorted(coverageNum.keys(), key=lambda x: coverageNum[x])
        for c in sortedCov:
            weightedCov = c * (lenth - coverageNum[c])
            if weightedCov > 20:
                coverageWBM.append(weightedCov)
                print c
    sut.internalReport()
    for s in sortedCov:
        print s, coverageNum[s]


    print bugs,"Failures have been found"
    print "TOTAL ACTIONS",actNum
    print "TOTAL RUNTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:30,代码来源:tester2.py

示例11: main

def main():
    global flag,timeout,sut,test,para,currStatements,coverageNum,sortedCov,weight,weightedCov,coverageWeightedBelowMean,bugs,actNum,start
    while time.time()-start < timeout:
        sut.restart()
        if (test != None):
            if (rgen.random() > 0.4):
                sut.backtrack(test)
        para = False

        print "Testing"
        for s in xrange(0,100):
            tester()
            if flag == 1:
                break
        for s in sut.currStatements():
            if s not in coverageNum:
                coverageNum[s] = 0
            coverageNum[s] += 1
        sortedCov = sorted(coverageNum.keys(), key=lambda x: coverageNum[x])
        print "Coverage"
        for c in sortedCov:
            weight = (100 - coverageNum[c])
            weightedCov = c * weight
            if weightedCov > 25:
                coverageWeightedBelowMean.append(weightedCov)
                print c

    sut.internalReport()
    for s in sortedCov:
        print s, coverageNum[s]

    print bugs,"BUGS"
    print "TOTAL ACTIONS",actNum
    print "TOTAL RUNTIME",time.time()-start
开发者ID:Cianna,项目名称:cs569sp16,代码行数:34,代码来源:tester1.py

示例12: randomAction

def randomAction():
    global actCount, bugs,newseq,currseq
    act = sut.randomEnabled(R)
    actCount += 1
    ok = sut.safely(act)

    if running:
        if len(sut.newBranches()) > 0:
            print "ACTION:",sut.randomEnabled(random.Random(seed))[0]
            for b in sut.newBranches():
                print time.time() - start, len(sut.allBranches()),"New branch",b
            for s1 in sut.newStatements():
                print time.time() - start, len(sut.allStatements()),"New statement",s1

    if not ok:
        bugs += 1
        print "FOUND A FAILURE"

        if faults:
            f = sut.reduce(sut.test(), sut.fails, True, True)
            sut.prettyPrintTest(f)
            currseq.append((f,set(sut.currStatements())))
            print("SHOW FAULT")
            file = 'failure' + str(actCount) + '.test'
            sut.saveTest(sut.test(), file)
            sut.restart()
            print sut.failure()

    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:tester2.py

示例13: main

def main():
	global config, R, sut, bugs, actCount, branchCount, statementCount, ntest, start

	parsed_args, parser = parse_args()
	config = make_config(parsed_args, parser)
	print('Testing using config={}'.format(config))

	R = random.Random(config.seed)
	sut = sut.sut()

	sut.silenceCoverage()
	
	bugs = 0
	actCount = 0
	coverageCount = {}
	branchCount = {}
	statementCount = {}
	ntest = 0

	start = time.time()
	elapsed = time.time() - start
	
	print "Starting Test"
	while elapsed < config.timeout:
		sut.restart()
		ntest += 1
		for i in xrange(0, config.depth):
			if not randomAct():
				break
			elapsed = time.time() - start
			if config.running:
				showRunning()
			elapsed = time.time() - start
			if elapsed > config.timeout:
				print "Stopping test [TIMEOUT]"
				break
		collectCoverage()
		elapsed = time.time() - start
	print "Finishing Test"

	if time.time() - start > config.timeout:
		print "[TIMEOUT]"

	printCoverage()

	if config.coverage:
		sut.internalReport()

	print "Covered", len(sut.allBranches()), "branches"
	print "Covered", len(sut.allStatements()), "statements"
	
	print "Failed", bugs, "times"
	print "Total tests", ntest
	print "Total actions", actCount
	print "Total runtime", time.time() - start
开发者ID:agroce,项目名称:cs569sp16,代码行数:55,代码来源:finaltester.py

示例14: failures

def failures():
	bugs += 1
	print "FOUND A FAILURE"
	print sut.failure()
	print "REDUCING"
	failPool.append(sut.test())
	collectCoverage()
	R = sut.reduce(sut.test(),sut.fails, True, True)
	sut.prettyPrintTest(R)
	print sut.failure()
	sut.restart()
开发者ID:Cianna,项目名称:cs569sp16,代码行数:11,代码来源:tester1.py

示例15: main

def main():
	global config,rgen,actCount,failCount,ntests,coverageCount

	parsed_args, parser = parse_args()
	config = make_config(parsed_args, parser)
	rgen = random.Random(config.seed)

	actCount = 0
	failCount = 0
	coverageCount = {}

	start = time.time()
	ntests = 0
	while True:
		elapsed = time.time() - start
		if elapsed > config.timeout:
			print "STOPPING TEST DUE TO TIMEOUT, TERMINATED AT LENGTH",ntests
			break

		for i in xrange(0, config.depth):
			sut.restart()
			ntests += 1
			for j in xrange(0, config.width):
				act = sut.randomEnabled(rgen)
				actCount += 1
				ok = sut.safely(act)
				if not ok:
					failCount += 1
					print "FOUND A FAILURE"
					collectCoverage()
					R = sut.reduce(sut.test(),sut.fails, True, True)
					sut.prettyPrintTest(R)
					print sut.failure()
					break

				if config.running:
					if sut.newBranches() != set([]):
						for b in sut.newBranches():
							print time.time()-start, len(sut.allBranches()), "New branch", b
					if sut.newStatements() != set([]):
						for s in sut.newStatements():
							print time.time()-start,len(sut.allStatements()),"New statement",s

		collectCoverage()	

	if config.faults:
		print "TOTAL FAULTS", failCount

	if config.coverage:
		print len(sut.allBranches()),"BRANCHES COVERED"
		print len(sut.allStatements()),"STATEMENTS COVERED"
	
	print "TOTAL ACTIONS",actCount
	print "TOTAL RUNTIME",time.time()-start
开发者ID:Cianna,项目名称:cs569sp16,代码行数:54,代码来源:tester1.py


注:本文中的sut.restart函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。