• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python sut.state函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: tester

def tester():
    global sut,act,n,test,para,lCovered,actNum,bugs,M,flag, filename
    act = sut.randomEnabled(rgen)
    flag = 0
    n = sut.safely(act)
    if running:
        if sut.newBranches() != set([]):
            for d in sut.newBranches():
                print time.time() - start, len(sut.allBranches()),"New branch",d
    if len(sut.newStatements()) > 0:
        test = sut.state()
        para = True
        print sut.newStatements()
    if (para == False):
        if (lCovered != None):
            if (lCovered in sut.currStatements()):
                test = sut.state()
                para = True
    actNum += 1
    if (n == 0):
        bugs += 1
        print "A failure has been found!", bugs
        print sut.failure()
        M = sut.reduce(sut.test(),sut.fails, True, True)
        sut.prettyPrintTest(M)
        print sut.failure()
        filename ='failure%d.test'%bugs
        sut.saveTest(M,filename)
        flag = 1
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:tester2.py


示例2: newState

def newState():
    global rgen,sut,collected_test,storedTest,action_cnt,bugfound
    for i in xrange(0,DEPTH):
        action = sut.randomEnabled(rgen)
        no_bug_found = sut.safely(action)
        if RUNNING:
            if sut.newBranches() != set([]):
                for d in sut.newBranches():
                    print time.time() - start,len(sut.allBranches()),"New Branches",d
        if len(sut.newStatements()) > 0:
            collected_test = sut.state()
            storedTest = True
            print "new statement:",sut.newStatements()
        if (not storedTest) and (lst_coverage != None) and (lst_coverage in sut.currStatements()):

            collected_test = sut.state()
            storedTest = True
        action_cnt += 1
        if not no_bug_found:
            bugfound += 1
            print "A failure happened here."
            rds = sut.reduce(sut.test(),sut.fails, True, True)
            sut.prettyPrintTest(rds)
            print sut.failure()
            break
开发者ID:agroce,项目名称:cs569sp16,代码行数:25,代码来源:tester1.py


示例3: savingTest

def savingTest():
	global sut, fullPool, savedTest, savedFlag
	if len(sut.newBranches()) > 0:
		savedTest = sut.state()
		savedFlag = True
	if len(sut.newStatements()) > 0:
		savedTest = sut.state()
		savedFlag = True
	return
开发者ID:agroce,项目名称:cs569sp16,代码行数:9,代码来源:mytester.py


示例4: main

def main():
    global start,BUDGET,sut,COVERAGE_REPORT,savedcoverage,rgen,storedTest,act,ok,savedcoverage,running,savedcoverage,Num,faults,foundbug,savedTestState
    while time.time()-start < BUDGET:
        sut.restart()
        if (savedcoverage != None) and (rgen.random() > 0.3):
            print "Processing"
            sut.backtrack(savedcoverage)
        storedTest = False
        print "First: AVL tree"
        for s in xrange(0,100):
            act = sut.randomEnabled(rgen)
            ok = sut.safely(act)
            if running:
                if sut.newBranches() != set([]):
                    ## print "ACTION:",a[0],tryStutter
                    for d in sut.newBranches():
                        print time.time()-start,len(sut.allBranches()),"New branch",d
        

            if len(sut.newStatements()) > 0:
                savedcoverage = sut.state()
                storedTest = True
                if(running):
                    print "New Statement",sut.newStatements()
            if (not storedTest) and (i != None) and (i in sut.currStatements()):
                savedcoverage = sut.state()
                storedTest = True
            Num += 1

            if(faults):
                if not ok:
                    foundbug += 1
                    print "Failed"
                    print sut.failure()
                    print "REDUCE"
                    R = sut.reduce(sut.test(),sut.fails, True, True)
                    sut.prettyPrintTest(R)
                    print sut.failure()
                    filename = 'failure%d.test'%bugs_found
                    sut.saveTest(R,filename)
                    break
        savedTestState = sut.state()
        expandNewState()

    if coverage:
        sut.internalReport()

    print foundbug,"FAILED"
    print "ACTIVE",Num
    print "RUNTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:50,代码来源:tester2.py


示例5: 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


示例6: mutate

def mutate(test,failureNum,start,timeout,running):
	tcopy = list(test)
	i = rgen.randint(0,len(tcopy))
	sut.replay(tcopy[:i],catchUncaught = True)
	e = sut.randomEnabled(rgen)
	ok = sut.safely(e)
	ifRunning((time.time()-start),running,e)
	if not ok:
		f1_mutate = sut.test()
		failureNum = Failure(failureNum,f1_mutate)
	trest = [e]
	for s in tcopy[i+1:]:
		if time.time()-start > timeout:
			break
		if s[1]():
			trest.append(s)
			ok=sut.safely(s)
			newCovBran, newCovStat = ifRunning((time.time()-start),running,action)
			if not ok:
				f1_mutate = sut.test()
				failureNum = Failure(failureNum,f1_mutate)
			if newCovBran or newCovStat:
				BFSstartState = sut.state()
				failureNum = BFS(BFSstartState,failureNum,depthNum,lastCovTime,newCovTime)
				break
	tcopy = test[:i]+trest
	return tcopy,failureNum
开发者ID:agroce,项目名称:cs569sp16,代码行数:27,代码来源:finaltester.py


示例7: newFunction

def newFunction():
	global savecoverage_test,rgen,depth,explore,savecoverage_test,Number,sut,BUDGET,seed,width,faults,coverage,running,bugs_found,Cover_percent,Coverage_W,Least,weight,Coverage_all,start
	sut.restart()
	if (savecoverage_test != None) and (rgen.random() > explore):
		print "processing"
		sut.backtrack(savecoverage_test)
	storedTest = False
	print "part1: AVL"
	for s in xrange(0,100):
		act = sut.randomEnabled(rgen)
		ok = sut.safely(act)
		if len(sut.newStatements()) > 0:
			savecoverage_test = sut.state()
			storedTest = True
			print "New state",sut.newStatements()
		if (not storedTest) and (Least != None) and (Least in sut.currStatements()):
			#print "SAW LEAST COVERED STATEMENT, STORING TEST"
			savecoverage_test = sut.state()
			storedTest = True
		Number += 1
		if not ok:
			bugs_found += 1
			print "FAILURE"
            #sut.prettyPrintTest(sut.test())
			print sut.failure()
			R = sut.reduce(sut.test(),sut.fails, True, True)
			sut.prettyPrintTest(R)
			print sut.failure()
			break
	for s in sut.currStatements():
		if s not in Cover_percent:
			Cover_percent[s] = 0
		Cover_percent[s] += 1
	sortedCov = sorted(Cover_percent.keys(), key=lambda x: Cover_percent[x])
	# go through the sortedCov and assign weights on them
	print "part2: coverage"
	# weight is calculated by: coverage * (mean - Cover_percent),
	# the greater the difference between the mean and the coverage count,
	# the larger your weight will be
	for t in sortedCov:
		weight = (Coverage_all - Cover_percent[t])
		weightedCov = t*weight
		if weightedCov > 20:
			Coverage_W.append(weightedCov)
			print "Coverage:", t
开发者ID:Cianna,项目名称:cs569sp16,代码行数:45,代码来源:tester1.py


示例8: checkAlg

def checkAlg():
    global error, noerror,newseq,currseq,states
    newseq=sut.newStatements()
    c = sut.check()
    if c:
        if(not ((newseq in error) or (newseq in noerror))):
            states.insert(ntest-1,sut.state())
            noerror.append(sut.currStatements())
    else:
        error.append(sut.currStatements())
开发者ID:agroce,项目名称:cs569sp16,代码行数:10,代码来源:finaltester.py


示例9: main

def main():
    global start,BUDGET,sut,savedcoverage,rgen,storedTest,act,ok,savedcoverage,running,savedcoverage,Num,faults,foundbug,savedTestState
    while time.time()-start < BUDGET:
        sut.restart()
        if (savedcoverage != None) and (rgen.random() > 0.4):
            print "Processing"
            sut.backtrack(savedcoverage)
        storedTest = False
        print "First: AVL tree"
        for s in xrange(0,100):
            act = sut.randomEnabled(rgen)
            ok = sut.safely(act)
            if len(sut.newStatements()) > 0:
                savedcoverage = sut.state()
                storedTest = True
                if(running):
                    print "New Statement",sut.newStatements()
            if (not storedTest) and (i != None) and (i in sut.currStatements()):
                savedcoverage = sut.state()
                storedTest = True
            Num += 1

            if(faults):
                if not ok:
                    foundbug += 1
                    print "Failed"
                    print sut.failure()
                    print "REDUCE"
                    R = sut.reduce(sut.test(),sut.fails, True, True)
                    sut.prettyPrintTest(R)
                    print sut.failure()
                    break
        savedTestState = sut.state()
        expandNewState()

    print foundbug,"FAILED"
    print "ACTIVE",Num
    print "RUNTIME",time.time()-start
    for s in sortedCoverage:
        print s, coverageCount[s]
    if (COVERAGE_REPORT):
        sut.internalReport()
开发者ID:Cianna,项目名称:cs569sp16,代码行数:42,代码来源:tester.py


示例10: checkAlg

def checkAlg():
    global error, noerror,newseq,currseq,states
     #newseq = sut.randomEnableds(R, depth)
    newseq=sut.newStatements()
    c=sut.check()
    if c:
        if(not ((newseq in error) or (newseq in noerror))):
            states.insert(ntest-1,sut.state())
            noerror.append(sut.currStatements())
            flags(newseq,c)
    else:
        error.append(sut.currStatements())
开发者ID:agroce,项目名称:cs569sp16,代码行数:12,代码来源:tester2.py


示例11: newState

def newState():
    global rgen,sut,collected_test,storedTest,action_cnt,bugfound
    for i in xrange(0,100):
        action = sut.randomEnabled(rgen)
        no_bug_found = sut.safely(action)
        if len(sut.newStatements()) > 0:
            collected_test = sut.state()
            storedTest = True
            print "new statement collected here",sut.newStatements()
        if (not storedTest) and (lst_coverage != None) and (lst_coverage in sut.currStatements()):

            collected_test = sut.state()
            storedTest = True
        action_cnt += 1
        if not no_bug_found:
            bugfound += 1
            print "A failure happened here."
            rds = sut.reduce(sut.test(),sut.fails, True, True)
            sut.prettyPrintTest(rds)
            print sut.failure()
            break
开发者ID:Cianna,项目名称:cs569sp16,代码行数:21,代码来源:test.py


示例12: func1

def func1():
    global sut,testSaving,testStored,srun,failCount,R,flag,actionsCount
    flag = 0
    if len(sut.newStatements()) > 0:
        testSaving = sut.state()
        testStored = True
        print "Find statements:",sut.newStatements()
    if (covrageLeast != None):
        if (covrageLeast in sut.currStatements()) and (testStored == 0):
            testSaving = sut.state()
            testStored = True
    actionsCount = actionsCount + 1
    if (srun == 0):
        failCount = failCount + 1
        print "This is failure"
        print sut.failure()
        print "Now reducing.."
        R = sut.reduce(sut.test(),sut.fails, True, True)
        sut.prettyPrintTest(R)            
        print sut.failure()
        flag = 1
开发者ID:agroce,项目名称:cs569sp16,代码行数:21,代码来源:tester1.py


示例13: avlfunction

def avlfunction():
	global storedTest,sortedCov,savecoverage_test,rgen,depth,explore,savecoverage_test,Number,sut,BUDGET,seed,width,faults,coverage,running,bugs_found,Cover_percent,Coverage_W,Least,weight,Coverage_all,start
	for s in xrange(0,depth):
		act = sut.randomEnabled(rgen)
		ok = sut.safely(act)
		if running:
			if len(sut.newBranches()) > 0:
				print "ACTION:", act[0]
				for d in sut.newBranches():
					print time.time() - start, len(sut.allBranches()),"New branch",d 	
		if len(sut.newStatements()) > 0:
				savecoverage_test = sut.state()
				storedTest = True
				print "New state",sut.newStatements()
		#if len(sut.newStatements()) > 0:
		#	savecoverage_test = sut.state()
		#	storedTest = True
		#	print "New state",sut.newStatements()
		if (not storedTest) and (Least != None) and (Least in sut.currStatements()):
			#print "SAW LEAST COVERED STATEMENT, STORING TEST"
			savecoverage_test = sut.state()
			storedTest = True
		Number += 1
		if faults:
			if not ok:
				bugs_found += 1
				print "FAILURE"
				print sut.failure()
				R = sut.reduce(sut.test(),sut.fails, True, True)
				sut.prettyPrintTest(R)
				print sut.failure()
				filename = 'failure%d.test'%bugs_found
				sut.saveTest(R,filename)
				break
		
	for s in sut.currStatements():
		if s not in Cover_percent:
			Cover_percent[s] = 0
		Cover_percent[s] += 1
	sortedCov = sorted(Cover_percent.keys(), key=lambda x: Cover_percent[x])
开发者ID:agroce,项目名称:cs569sp16,代码行数:40,代码来源:tester2.py


示例14: tester

def tester():
    global sut,act,n,test,para,lCovered,actNum,bugs,M,flag
    act = sut.randomEnabled(rgen)
    flag = 0
    n = sut.safely(act)
    if len(sut.newStatements()) > 0:
        test = sut.state()
        para = True
        print sut.newStatements()
    if (para == False):
        if (lCovered != None):
            if (lCovered in sut.currStatements()):
                test = sut.state()
                para = True
    actNum += 1
    if (n == 0):
        bugs += 1
        print "Emerge a bug!"
        print sut.failure()
        M = sut.reduce(sut.test(),sut.fails, True, True)
        sut.prettyPrintTest(M)
        print sut.failure()
        flag = 1
开发者ID:Cianna,项目名称:cs569sp16,代码行数:23,代码来源:tester1.py


示例15: loopBug

def loopBug():
    global Stest,rgen,sut,depth,LCov,actCount,running,faults,j,bugs
    if Stest != None:
        if rgen.random() > 0.4:
            sut.backtrack(Stest)
    test = False  
    for s in xrange(0,depth):
            act = sut.randomEnabled(rgen)
            ok = sut.safely(act)
 
            if len(sut.newBranches()) > 0:
                Stest = sut.state()
                test = True
                
            if (not test):
				if (LCov!= None):
					if (LCov in sut.currBranches()):
						Stest = sut.state()
						test = True
            
            actCount += 1 
            if running == 1:
                if sut.newBranches() != set([]):
                    print "ACTION:",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 FAILURES and It IS STORING IN FILES:"
                    j += 1
                    bugs += 1
                    fault = sut.failure()
                    failurename = 'failure' + str(bugs) + '.test' 
                    sut.saveTest(sut.test(), failurename)
                    print "The bug's number found is" ,j
                    sut.restart()
开发者ID:agroce,项目名称:cs569sp16,代码行数:37,代码来源:finaltester.py


示例16: expandNewState

def expandNewState():
    global sut,Coverage,sortedCov,weight,weightedCov,BelowCoverage
    for s in sut.currStatements():
        if s not in Coverage:
            Coverage[s] = 0
        Coverage[s] += 1
    sortedCov = sorted(Coverage.keys(), key=lambda x: Coverage[x])
    print "Second: coverage"
    for t in sortedCov:
        weight = (100 - Coverage[t])
        weightedCov = t*weight
        if weightedCov > 20:
            BelowCoverage.append(weightedCov)
            print "Cov:", t
            sut.backtrack(sut.state())
开发者ID:Cianna,项目名称:cs569sp16,代码行数:15,代码来源:tester.py


示例17: main

def main():
    global start,sut,R,noerror,error,actCount, bugs,ntest,newseq,currseq,states
    actCount = 0
    bugs = 0
    start = time.time()
    noerror = []
    error = []
    newseq = []
    ntest=0
    currseq=[]
    sut = sut.sut()
    R = random.Random()
    R.seed(seed)
    states = [sut.state()]
    print "STARTING PHASE 1"
    while(time.time() < start + timeout):
        for st in states:
            ntest+=1
            if (time.time() > start + timeout):
                break
            sut.restart()
            sut.backtrack(st)
            for s in xrange(0, depth):
                if (time.time() > start + timeout):
                    break
                ok = randomAction()
                if not ok:
                    error.append(sut.currStatements())
                    break
                checkAlg()

    #if not error ==[]:
    #    print "SHOW ERROR SEQUENCE"
    #    print error
    #    f = open(("error" + str(actCount) + ".test"), 'w')
    #    f.write(str(error))
    #    f.close()
    #else:
    #    print "Data in noerror sequence"
        # print noerror


    if coverage:
        sut.internalReport()

    print "TOTAL BUGS", bugs
    print "TOTAL ACTIONS",actCount
    print "TOTAL RUNTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:48,代码来源:finaltester.py


示例18: BFS

def BFS(state,failureNum,depthNum,lastCovTime,newCovTime):
	queue = [state]
	d=0
	BfsBugCount=0
	newCovBran=False
	newCovStat=False
	while depthNum + d < depth and time.time()-start <= timeout/rtTimePara and (newCovBran==False and newCovStat==False):
		d+=1
		frontier = []
		for s2 in queue[:width]:
			if time.time()-start > timeout/rtTimePara:
				break
			sut.backtrack(s2)
			allEnabled = sut.enabled()
			rgen.shuffle(allEnabled)
			for a in allEnabled[:5]:
				if time.time()-start > timeout/rtTimePara:
					break
				ok = sut.safely(a)
				newCovBran, newCovStat = ifRunning((time.time()-start),running,a)
				sss = sut.state()
				if sss not in visited:
					visited.append(sss)
					frontier.append(sss)
				if not ok:
					f1_bfs = sut.test()
					failureNum = Failure(failureNum,f1_bfs)
					BfsBugCount+=1
					if BfsBugCount==BfsBugNum:
						BfsBugCount=0
						break
				if newCovBran or newCovStat:
					lastCovTime = time.time()
					newCovTime = 0
					break
				else:
					newCovTime = time.time() - lastCovTime
				sut.backtrack(s2)
			else:
				sut.backtrack(s2)
				continue
			break
		rgen.shuffle(frontier)
		queue = frontier
	return failureNum
开发者ID:agroce,项目名称:cs569sp16,代码行数:45,代码来源:finaltester.py


示例19: randomAction

def randomAction(pool):
    'Execute a random enabled action from the SUT, catch bugs or add to pool'
    global nbug
    act = sut.randomEnabled(rgen)
    ok = sut.safely(act)
    if not ok:
        nbug += 1
        if (opts.fault):
            captureFault()
        else:
            print "FAILURE LOCATED"
        collectCoverage() # collecting coverage because sut.restart() resets internal coverage
        sut.restart()   
    else:
        if (opts.running):
            runtimeCoverage()
        pool.addTest(sut.test(),sut.state(),set(sut.currStatements()))
    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:18,代码来源:tester1.py


示例20: main

def main():
    global start,sut,R,noerror,error,reduceTime,actCount, bugs,ntest,newseq,currseq,states, beforeReduceS, beforeReduceB,quickCount
    actCount = 0
    bugs = 0
    start = time.time()
    noerror = []
    error = []
    newseq = []
    ntest=0
    currseq=[]
    sut = sut.sut()
    reduceTime = 0.0
    R = random.Random()
    R.seed(seed)
    beforeReduceS = set(sut.allStatements())
    beforeReduceB = set(sut.allBranches())
    states = [sut.state()]
    quickCount=0
    print "STARTING PHASE 1"
    while(time.time() < start + timeout):
        for st in states:
            ntest+=1
            if (time.time() > start + timeout):
                break
            sut.restart()
            sut.backtrack(st)
            for s in xrange(0, depth):
                if (time.time() > start + timeout):
                    break
                ok = randomAction()
                if not ok:
                    break
                checkAlg()

    if coverage:
        sut.internalReport()
    if quickTests==1:
        #if (sut.newCurrBranches() != set([])) or (sut.newCurrStatements() != set([])):
        handle_failure(sut.test(), "NEW COVERAGE", False, newCov=True)


    print "TOTAL BUGS", bugs
    print "TOTAL ACTIONS",actCount
    print "TOTAL RUNTIME",time.time()-start
开发者ID:agroce,项目名称:cs569sp16,代码行数:44,代码来源:mytester.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sut.sut函数代码示例发布时间:2022-05-27
下一篇:
Python sut.saveTest函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap