本文整理汇总了Python中sut.internalReport函数的典型用法代码示例。如果您正苦于以下问题:Python internalReport函数的具体用法?Python internalReport怎么用?Python internalReport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了internalReport函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: main
def main(argv):
global sut, rgen, ntest, nbug, coverageCount, start, selectStatements, threshold
parse_options(argv)
# GLOBAL VARIABLES
sut = sut.sut()
rgen = random.Random(opts.seed)
ntest = 0
nbug = 0
coverageCount = {}
selectStatements = {}
threshold = 0
start = time.time()
# PHASES
phaseLimit = 0
if opts.timeout < 30:
phaseLimit = int(round(opts.timeout/3*2))
else:
phaseLimit = int(round(opts.timeout/10))
while (time.time() - start) < (0.95 * opts.timeout):
randomPool = phase1(phaseLimit)
selectPool = filterPool(randomPool)
phase2(randomPool, selectPool)
print "FULL POOL:",len(randomPool),", SELECT POOL:",len(selectPool)
print "EXECUTED:",ntest,"tests"
print "BUGS:",nbug
print "TOTAL ELAPSED:",round(time.time() - start,5),"seconds"
if (opts.coverage):
sut.internalReport()
示例4: 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
示例5: 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
示例6: main
def main():
global config, rgen, start
parsed_args, parser = parse_args()
config = make_config(parsed_args, parser)
print('Testing using config={}'.format(config))
rgen.seed(config.seed)
start = time.time()
nseqs.append(getSeq())
while time.time() - start < config.timeout:
seq = rgen.choice(nseqs)[:]
sut.replay(seq)
if rgen.randint(0, 9) == 0:
n = rgen.randint(2, 100)
ok, propok, timeover = appendAndExecuteSeq(seq, n, eseqs, nseqs)
else:
ok, propok, timeover = appendAndExecuteSeq(seq, 1, eseqs, nseqs)
if timeover:
break
if ok and propok:
nseqs.append(seq)
if config.coverage:
sut.internalReport()
示例7: 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
示例8: 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()
示例9: main
def main():
global running,start,TIMEBUDGET,sut,testSaving,gene,testStored,act,srun,flag,coverageCount,covrSort,calculateWei,allCoverage,cW,coverageWM,failCount,actionsCount,sd
#global running,possible
global config
parsed_args, parser = parse_args()
config = make_config(parsed_args, parser)
while time.time()-start < TIMEBUDGET:
sut.restart()
if (testSaving != None) and (gene.random() > 0.3):
sut.backtrack(testSaving)
testStored = False
print "Firstly test the AVL tree"
for s in xrange(0,100):
act = sut.randomEnabled(gene)
srun = sut.safely(act)
if config.running:
if sut.newBranches() != set([]):
for d in sut.newBranches():
print time.time()-start,len(sut.allBranches()),"New branch",d
func1()
if flag == 1:
break
for s in sut.currStatements():
if s not in coverageCount:
coverageCount[s] = 0
coverageCount[s] = coverageCount[s] + 1
covrSort = sorted(coverageCount.keys(), key=lambda x: coverageCount[x])
for st in covrSort:
if st*(allCoverage - coverageCount[st]) >25:
coverageWM.append(st*(allCoverage - coverageCount[st]))
print "Now I have the statement below coverage:", st
for sd in covrSort:
print sd,coverageCount[sd]
sut.internalReport()
print failCount,"FAILED"
print len(sut.allBranches()),"BRANCH"
print actionsCount,"TOTAL ACTIONS"
print time.time()-start,"TOTAL RUNTIME"
示例10: str
i += 1
bugs += 1
saveFault = 'failure' + str(bugs) + '.test'
sut.saveTest(sut.test(), saveFault)
print "Number bugs found is" ,i
sut.restart()
#To see what is the least covered branch to do experiments on them
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])
leastCov = sortedCov[0]
if (time.time() - start > config.timeout):
break
#Take the name of all actions and sort them by their action count
sortedCov = sorted(covCount.keys(), key=lambda x: covCount[x])
# Produce coverage report
if config.coverage:
sut.internalReport()
print "TOTAL NUMBER OF BUGS",bugs
print "TOTAL NUMBER OF TESTS",no_tests
print "TOTAL NUMBER OF ACTIONS",actCount
print "TOTAL NUMBER OF RUNTIME",time.time()-start
示例11: str
failureCount = failureCount + 1 #the failure count will go on increasing
if (FAULT_CHECK): # this will check for the faults
name = "failure" + str(failureCount) + ".test"
f = sut.test()
sut.saveTest(F,filename)
for (s_reduces) in S:
steps_reduce = "#no of steps taken " + str(j)
print >> f, sut.prettyName(s_reduces).ljust(80 - len(steps_reduce), ' '), steps_reduce
j =j + 1
else:
print ""/n
print "This is the same test"
sut.prettyPrintTest(F)
break;
if (COVERAGE_REPORT):
sut.internalReport() #printing the result
示例12: randomOperation
def randomOperation():
global bug_num, time_start
operation = sut.randomEnabled(rand)
good = sut.safely(operation)
runtime = time.time() - time_start
if (running):
if (len(sut.newBranches())) > 0
print "Operation: ", operation[0]
for i in sut.newBranches():
print runtime, len(sut.allBranches()), "New Branch", i
if (not good):
bug_num += 1
print "A bug is found! #", bug_num
print sut.failure()
print ("Reducing!")
reduce = sut.reduce(sut.test(), sut.fails, True, True)
sut.prettyPrintTest(reduce)
print(sut.failure())
if (faults):
f = open((fail + str(bug_num) + ".test"), "w")
print >> f, sut.failure()
j = 0
for (s_reduce, _, _) in reduce:
steps_reduce = "# Step " + str(j)
print >> f, sut.prettyName(s_reduce).ljust(80 - len(steps_reduce), ' '), steps_reduce
j += 1
f.close()
print "Time: ", runtime
return good
time_start = time.time()
current_depth = 1
state_queue = [sut.state()]
Time_Phase1 = timeout / 4
print "PHASE 1 ..."
while (time.time() < (time_start + Time_Phase1)):
sut.restart()
for d in xrange(0, depth):
good = randomOperation()
if (not good):
break
if (len(sut.newStatements()) > 0):
new_state.append(sut.state())
new_statement.append(sut.newStatements())
for s in sut.currStatements():
if s not in coverageCount:
coverageCount[s] = 0
coverageCount[s] += 1
sortedCoverage = sorted(coverageCount.keys(), key = lambda x: coverageCount[x])
sum_value = 0
for s in sortedCoverage:
sum_value += coverageCount[s]
mean_value = sum_value / len(coverageCount)
sum_value = 0.0
for s in sortedCoverage:
sum_value += math.pow(coverageCount[s] - mean_value, 2)
sum_value = sum_value / (len(coverageCount) - 1)
std = math.sqrt(sum_value)
threshold = mean_value - (0.67 * std)
print "Mean: ", mean_value
print "Standard Deviation: ", std
print "Threshold: ", threshold
for s in sortedCoverage:
if (coverageCount[s] > threshold):
break
for k in k_chosen:
if s in new_statement[k]:
continue
for k in xrange(0, len(new_statement)):
if s in new_statement[k]:
k_chosen.append(k)
for k in k_chosen:
chosen_state.append(new_state[k])
print bug_num, " Bugs Found!"
for s in sortedCoverage:
print s, coverageCount[s]
if (coverage):
sut.internalReport()
print "PHASE 2 ..."
Time_Phase2 = timeout - Time_Phase1
all_state = []
new_statement = []
i = 0;
#.........这里部分代码省略.........
示例13: print_results
def print_results():
if COVERAGE:
sut.internalReport()
print "Number of bugs found: " + str(bugs)