本文整理汇总了Python中sut.saveTest函数的典型用法代码示例。如果您正苦于以下问题:Python saveTest函数的具体用法?Python saveTest怎么用?Python saveTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了saveTest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例2: 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
示例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()
示例4: 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
示例5: 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
示例6: 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 branch",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."
R = sut.reduce(sut.test(),sut.fails, True, True)
sut.prettyPrintTest(R)
print sut.failure()
filename ='failure%d.test'%bugfound
sut.saveTest(R,filename)
break
示例7: 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
示例8: failure
def failure():
global bugs
bugs += 1
collectCoverage()
R = sut.reduce(sut.test(), sut.fails, True, True)
if config.faults :
filename = 'failure%d.test'%bugs
sut.saveTest(sut.test(), filename)
sut.prettyPrintTest(R)
sut.restart()
return
示例9: mutate
def mutate(test):
tcopy = list(test)
i = rgen.randint(0,len(tcopy))
sut.replay(tcopy[i:])
e = sut.randomEnabled(rgen)
ok = sut.safely(e)
elapsed = time.time() - start
if RUNNING: #should branch coverage be produced
if sut.newBranches() != set([]):
for b in sut.newBranches():
print elapsed,len(sut.allBranches()),"New branch",b
if not ok: #found a bug, report it
bugs+=1
print "Found a FAILURE"
#sut.prettyPrintTest(sut.test())
print sut.failure()
print "REDUCING"
R = sut.reduce(sut.test(), sut.fails, True, True)
sut.prettyPrintTest(R)
print sut.failure()
if FAULT: #save test to a file if FAULT is enabled
filename = "failure" + str(bugs) + ".test"
sut.saveTest(R,filename)
trest = [e]
for s in tcopy[i+1:]:
if s[1]():
trest.append(s)
ok = sut.safely(s)
if not ok: #found a bug, report it
bugs+=1
print "Found a FAILURE"
#sut.prettyPrintTest(sut.test())
print sut.failure()
print "REDUCING"
R = sut.reduce(sut.test(), sut.fails, True, True)
sut.prettyPrintTest(R)
print sut.failure()
if FAULT: #save test to a file if FAULT is enabled
filename = "failure" + str(bugs) + ".test"
sut.saveTest(R,filename)
tcopy = test[i:] +trest
return tcopy
示例10: captureFault
def captureFault():
'Print failure state and reduction, save to file'
global nbugs
nbugs += 1
print "FAILURE LOCATED:"
print sut.failure()
print "REDUCING FAILURE:"
R = sut.reduce(sut.test(),sut.fails, True, True)
sut.prettyPrintTest(R)
print sut.failure()
# output to file for each fault
filename = 'failure%d.test' % nbugs
sut.saveTest(R, filename)
示例11: 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
示例12: takeTest
def takeTest(actt):
global fullPool,bugs,sut
ok = sut.safely(actt)
collectCoverage()
if len(sut.newStatements()) != 0:
fullPool.append((list(sut.test()), set(sut.currStatements())))
if not ok :
bugs += 1
if Faults :
R = sut.reduce(sut.test(),sut.fails, True, True)
filename = "failure" + str(bugs) + ".test"
sut.saveTest(R,filename)
示例13: notOK
def notOK():
global bugs, sut
bugs += 1
print "FOUND A FAILURE"
print sut.failure()
print "REDUCING"
R = sut.reduce(sut.test(), sut.fails, True, True)
sut.prettyPrintTest(R)
print sut.failure()
# save test
name = "failure" + str(bugs) + ".test"
f = sut.test()
sut.saveTest(f, name)
示例14: fault_collection
def fault_collection():
if(FAULT_CHECK):
print "use"+str(time.time()-startAll)
print "FOUND A FAILURE"
print sut.failure()
print "REDUCING"
R = sut.reduce(sut.test(),sut.fails, True, True)
sut.prettyPrintTest(R)
print "this is fault:"+ str(sut.failure())
fname = 'failure'+str(bugs)+'.test'
sut.saveTest(R,fname)
示例15: Failure
def Failure(failureNum,f):
failureNum+=1
#print "FIND " + str(failureNum) + " FAILURE"
if faults:
name='failure'+str(failureNum)+'.test'
sut.saveTest(f,name)
'''
if reduce:
print "REDUCING"
R = sut.reduce(sut.test(),sut.fails, True, True)
sut.prettyPrintTest(R)
if normalize:
print "NOMALIZING"
N = sut.normalize(sut.test(),sut.fails, True, True)
sut.prettyPrintTest(N)
'''
return failureNum