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

Python sut.currStatements函数代码示例

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

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



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

示例1: running_oh

def running_oh():
	global actinos, elapsed, lastAddCoverage, median_even, median_odd 


	if len(sut.newBranches()) != set ([]):
		print "ACTION:", list_actions[0]
		for s in sut.newBranches():
			print elapsed,len(sut.allBranches()),"New branch",s

	if len(sut.newStatements())> 0:
		print "ACTION:", list_actions[0]
		for s in sut.newStatements():
			print elapsed,len(sut.allStatements()),"New statement",s

		old_test = list(sut.test())
		store_new_test  = sut.reduce(old_test,sut.coversStatements(sut.newStatements()))
		sut.replay(old_test)
		testBuffer.append(store_new_test)	
		currentStatementBuffer.append(set(sut.currStatements()))
		lastAddCoverage = set(sut.currStatements())
		

	for s in median_odd or median_even:
		if s in sut.currStatements() and s not in lastAddCoverage:
			print "find new path to lower coverstatements: ", s
			testBuffer.append(list(sut.test()) )
			currentStatementBuffer.append(set(sut.currStatements()))
			lastAddCoverage = set(sut.currStatements() )
开发者ID:agroce,项目名称:cs569sp16,代码行数:28,代码来源:comparsion.py


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


示例3: newStatement

def newStatement():
    global lastAddCoverage
    print "NEW STATEMENTS DISCOVERED",sut.newStatements()
    oldTest = list(sut.test())
    storeTest = sut.reduce(oldTest,sut.coversStatements(sut.newStatements()))
    print "OLD LENGTH = ",len(oldTest),"NEW LENGTH = ",len(storeTest)
    sut.replay(oldTest)
    fullPool.append((storeTest, set(sut.currStatements())))
    lastAddCoverage = set(sut.currStatements())
    return
开发者ID:agroce,项目名称:cs569sp16,代码行数:10,代码来源:tester2.py


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


示例5: Statement

def Statement():
	global belowMid,lastAddCoverage 
	if len(sut.newStatements()) != 0:
		oldTest = list(sut.test())
		storeTest = sut.reduce(oldTest,sut.coversStatements(sut.newStatements()))
		sut.replay(oldTest)
		visited.append((storeTest, set(sut.currStatements())))
		lastAddCoverage = set(sut.currStatements())
		return
	for s in belowMid:
		if s in sut.currStatements() and s not in lastAddCoverage:
			visited.append((list(sut.test()), set(sut.currStatements())))
			lastAddCoverage = set(sut.currStatements())
			return	
开发者ID:Cianna,项目名称:cs569sp16,代码行数:14,代码来源:tester1.py


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


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


示例8: collectCoverage

def collectCoverage():
	global coverageCount

	for s in sut.currStatements():
		if s not in coverageCount:
			coverageCount[s] = 0
		coverageCount[s] += 1    
开发者ID:agroce,项目名称:cs569sp16,代码行数:7,代码来源:finaltester.py


示例9: randomAction

def randomAction():
    global actCount, bugs, visited
    act = sut.randomEnabled(rgen)
    actCount += 1
    ok = sut.safely(act)
    elapsed = time.time() - start
    if not ok:
        bugs += 1
        if FAULTS:
            name = "failure"+str(bugs)+".test"
            f = sut.test()
            sut.saveTest(f,name)
    else:
        if RUNNING:
            if sut.newBranches() != set([]):
                print "ACTION:",act[0]
                for d in sut.newBranches():
                    print elapsed,len(sut.allBranches()),"New branch",d
                sawNew = True
            else:
                sawNew = False

            if sut.newStatements() != set([]):
                print "ACTION:",act[0]
                for s in sut.newStatements():
                    print elapsed,len(sut.allStatements()),"New statement",s
                sawNew = True
            else:
                sawNew = False

        if len(sut.newStatements()) != 0:
            visited.append((list(sut.test()), set(sut.currStatements())))
    
    return ok
开发者ID:agroce,项目名称:cs569sp16,代码行数:34,代码来源:finaltester.py


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


示例11: crossover

def crossover(test,test2):
    
    global bugs
    tcopy = list(test)
    #randomly choose part of test
    i = rgen.randint(0,len(tcopy))
    #replay to be the chosen state
    sut.replay(tcopy[:i],catchUncaught = True)
    
    trest = []

    for s in test2[i:]:
        if s[1]():
            
            trest.append(s)
            #check whether it is correct
            ok = sut.safely(s)
            
            if not ok:
                bugs = bugs+1
                errors.append(sut.currStatements())
                fault_collection()

    #to do crossover
    tcopy = test[:i]+trest

    #if we find new branches
    if len(sut.newCurrBranches()) != 0:
        print "NEW BRANCHES DUE TO CROSSOVER:",sut.newCurrBranches()
    return tcopy
开发者ID:agroce,项目名称:cs569sp16,代码行数:30,代码来源:finaltester.py


示例12: Find_bugs

def Find_bugs(list_actions):
	# print "Find_bugs"
	global coverage_counter
	global bugs	
	global Record
	global string
	safe = sut.safely(list_actions)
	running_oh()
	if not safe:
		bugs = bugs + 1
		print " *** find a bug: ",bugs
		# bugs = bugs + 1
		for t in sut.currStatements():
			if t not in coverage_counter:
				coverage_counter[t]=0
			coverage_counter[t] = coverage_counter[t] + 1	
		# Collect_coverage()
		print sut.failure()
		# string = str(sut.failure)
		Record = True
		print "reducing..."
		R = sut.reduce(sut.test(),sut.fails, True, True)
		sut.prettyPrintTest(R)	
		# record_failures(R)
		if FAULTS:
			print"create file"
			# for x in xrange(1,bugs):
				# print "save"
			sut.saveTest(R, failure + str(bugs)+ ".test")
			# filename = "failure" +  str(bugs) + ".test"
			# sut.saveTest(sut.test(), filename)
		# sut.restart()
	return safe
开发者ID:agroce,项目名称:cs569sp16,代码行数:33,代码来源:tester2.py


示例13: mutate

def mutate(test):
    
    global bugs
    tcopy = list(test)
    #randomly choose part of the chosen case
    i = rgen.randint(0,len(tcopy))
    #replay to be the chosen state
    sut.replay(tcopy[:i],catchUncaught = True)
    e = sut.randomEnabled(rgen)
    #check whether it is correct
    ok = sut.safely(e)
    
    if not ok:
       bugs = bugs+1
       errors.append(sut.currStatements())
       fault_collection()

    trest = [e]

    for s in tcopy[i+1:]:
        if s[1]():
            trest.append(s)
            sut.safely(s)
    tcopy = test[:i]+trest
    
    #if we find new branches
    if len(sut.newCurrBranches()) != 0:
        print "NEW BRANCHES DUE TO MUTATION:",sut.newCurrBranches()
    return tcopy
开发者ID:agroce,项目名称:cs569sp16,代码行数:29,代码来源:finaltester.py


示例14: collectCoverage

def collectCoverage():
    'Update the global coverage count for executions on each statement'
    global coverageCount
    for s in sut.currStatements():
        if s not in coverageCount:
            coverageCount[s] = 0
        coverageCount[s] += 1   
开发者ID:agroce,项目名称:cs569sp16,代码行数:7,代码来源:tester1.py


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


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


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


示例18: expand

def expand():
    global lastAddCoverage
    nonErrorSeqs.append(sut.currStatements())
    if len(sut.newStatements()) != 0:
        print "NEW STATEMENTS DISCOVERED",sut.newStatements()
        newSeq = sut.newStatements()
        if (newSeq in nonErrorSeqs or newSeq in errorSeqs):
           action()
           #sut.restart() 
        else:
            oldTest = list(sut.test())
            storeTest = sut.reduce(oldTest,sut.coversStatements(newSeq))
            print "OLD LENGTH = ",len(oldTest),"NEW LENGTH = ",len(storeTest)
            sut.replay(oldTest)
            fullPool.append((storeTest, set(sut.currStatements())))
            lastAddCoverage = set(sut.currStatements())
        return
开发者ID:agroce,项目名称:cs569sp16,代码行数:17,代码来源:tester2.py


示例19: expandPool

def expandPool():
    global belowMean,lastAddCoverage 
    if len(sut.newStatements()) != 0:
        print "NEW STATEMENTS DISCOVERED",sut.newStatements()
        oldTest = list(sut.test())
        storeTest = sut.reduce(oldTest,sut.coversStatements(sut.newStatements()))
        print "OLD LENGTH = ",len(oldTest),"NEW LENGTH = ",len(storeTest)
        sut.replay(oldTest)
        fullPool.append((storeTest, set(sut.currStatements())))
        lastAddCoverage = set(sut.currStatements())
        return
    for s in belowMean:
        if s in sut.currStatements() and s not in lastAddCoverage:
            print "NEW PATH TO LOW COVERAGE STATEMENT",s
            fullPool.append((list(sut.test()), set(sut.currStatements())))
            lastAddCoverage = set(sut.currStatements())
            return
开发者ID:Cianna,项目名称:cs569sp16,代码行数:17,代码来源:newCover.py


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sut.failure函数代码示例发布时间:2022-05-27
下一篇:
Python sut.backtrack函数代码示例发布时间: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