Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def randomAction():
    global bug_no, time_start, allAction, ii
    action = sut.randomEnabled(rand)
    ok = sut.safely(action)
    elapsed = time.time() - time_start
    if RUNNING_DETAIL:
        if len(sut.newBranches()) > 0:
            print "ACTION:", action[0]
            for b in sut.newBranches():
                print elapsed, len(sut.allBranches()), "New branch", b

    if not ok:  # found a bug
        bug_no += 1
        print "FOUND A BUG! #", bug_no
        print sut.failure()
        print("REDUCING")
        reduce = sut.reduce(sut.test(), sut.fails, True, True)

        sut.prettyPrintTest(reduce)
        print(sut.failure())
        # write the bug to file if FAULT_ARGUMENT is enabled
        if (FAULT_CHECK):
            f = open((failure_file + str(bug_no) + ".test"), "w")
            print >> f, sut.failure()
            # print sequence that causes failure
            j = 0
            for (s_reduces, _, _) in reduce:
                steps_reduce = "# STEP " + str(j)
                print >> f, sut.prettyName(s_reduces).ljust(80 - len(steps_reduce), ' '), steps_reduce
                j += 1
            f.close()
        print "time: ", time.time() - time_start
    return ok
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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()
Ejemplo n.º 10
0
def failures(sut,bugs, Config, faults_file):
    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()
Ejemplo n.º 11
0
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
Ejemplo n.º 12
0
def main():
	global config,rgen,actCount,failCount,ntests,fullPool

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

	actCount = 0
	failCount = 0
	fullPool = []

	start = time.time()
	ntests = 0
	while time.time() - start < config.timeout:
		ntests += 1
		sut.restart()
		for d in xrange(0, config.depth):
			act = sut.randomEnabled(rgen)
			actCount += 1

			ok = sut.safely(act)
			expandPool()
			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

			if not ok:
				failCount += 1
				if config.faults:
					failureHandle(failCount)
				print "FOUND A FAILURE"
				R = sut.reduce(sut.test(),sut.fails, True, True)
				sut.prettyPrintTest(R)
				print sut.failure()
				sut.restart()
				break

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

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

	if config.coverage:
		sut.internalReport()
	
	print "TOTAL ACTIONS",actCount
	print "TOTAL RUNTIME",time.time()-start
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
def captureFault():
    'Print failure state and reduction'
    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
    fname = 'failure%d.test' % nbugs
    fo = open(fname, "wb")
    fo.write(sut.failure())
    fo.close()
Ejemplo n.º 15
0
def failure():
    global bugs, failPool
    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()
    return     
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
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
Ejemplo n.º 19
0
def Find_bugs(a):
	#print "aaaaa"
	global coverage_counter
	global bugs
	safe = sut.safely(a)
	if not safe:
		print " find a bug: "
		bugs = bugs + 1
		for s in sut.currStatements():
			if s not in coverage_counter:
				coverage_counter[s]=0
			coverage_counter[s] = coverage_counter[s] + 1	
		print sut.failure()
		R = sut.reduce(sut.test(),sut.fails, True, True)
		sut.prettyPrintTest(R)	
Ejemplo n.º 20
0
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 
Ejemplo n.º 21
0
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()
Ejemplo n.º 22
0
def RecordFail():
	count = 0
	while os.path.exists('failure' + str(count) + 'test') == True:
		count = count + 1

	records = open('failure' + str(count) + '.test', 'w')
	records.write(str(sut.failure()))
	records.close
Ejemplo n.º 23
0
def RecordFail():
	global BUG
	while os.path.exists('failure' + str(BUG) + 'test') == True:
		BUG += 1

	records = open('failure' + str(BUG) + '.test', 'w')
	records.write(str(sut.failure()))
	records.close
Ejemplo n.º 24
0
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
Ejemplo n.º 25
0
def runAct(action):
    global bug_no, time_start
    ok = sut.safely(action)
    elapsed = time.time() - time_start
    if RUNNING_DETAIL:
        if len(sut.newBranches()) > 0:
            print "ACTION:", action[0]
            for b in sut.newBranches():
                print elapsed, len(sut.allBranches()), "New branch", b
    if not ok:  # found a bug
        bug_no += 1
        print "FOUND A BUG in runAct! #", bug_no
        print sut.failure()
        # write the bug to file if FAULT_ARGUMENT is enabled
        if (FAULT_CHECK):
            filename = failure_file + str(bug_no) + ".test"
            sut.saveTest(sut.test(), filename)
        print "time: ", time.time() - time_start
    return ok
Ejemplo n.º 26
0
def randomAct():
	global actCount, bugs, R
	act = None
	act = sut.randomEnabled(R)
	actCount += 1

	ok = sut.safely(act)
	propok = sut.check()

	if ((not ok) or (not propok)):
		bugs += 1
		if config.faults == 1:
			test_file.write(str(sut.failure()) + "\n")
		R = sut.reduce(sut.test(), sut.fails, True, True)
		sut.prettyPrintTest(R)
		print sut.failure()
		sut.restart()

	return ok
Ejemplo n.º 27
0
def randomAction():
    global actCount, bugs, failPool
    act = sut.randomEnabled(rgen)
    actCount += 1
    ok = sut.safely(act)
    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()
        sut.restart()
    else:
        expandPool()
    return ok     
Ejemplo n.º 28
0
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()
Ejemplo n.º 29
0
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
Ejemplo n.º 30
0
def main():
	non_Errtemp = []
	Errtemp = []
	rgen = random.Random()
	rgen.seed(seed)
	sTime = time.time()
	Action_Count = 0

	while (time.time() - sTime) < timeout:
		newSeqs = sut.randomEnableds(rgen, depth)
		Seqs = RandomSeqs(non_Errtemp, n = 5)
		newSeqs.extend(Seqs)
		
		not_okay = False
		for run in newSeqs:
			if running == 1:
				ExecutingInfo(run, elapsed = (time.time() - sTime))

			okay = sut.safely(run)
			if sut.check() == False:
				not_okay = True

			Action_Count += 1

			if faults == 1:
				if okay == False or not_okay == True:
					RecordFail()
					print "BUG FOUND!"
					print sut.failure()
					filename = 'failure%d.test' % BUG
					sut.saveTest(sut.test() , filename)
					break

		if not_okay == True:
			Errtemp += newSeqs
		else:
			non_Errtemp += newSeqs

	print BUG, "BUGS FOUND!"
	print "Total Actions: ", Action_Count
	print "Total Runtime: ", (time.time() - sTime)
Ejemplo n.º 31
0
start = time.time()
while time.time() - start < BUDGET:
    sut.restart()
    for s in xrange(0, depth):
        acts = sut.randomEnableds(rgen, k)
        sortActs = sorted(acts, key=lambda x: actionCount[abstract(x[0])])
        act = sortActs[0]
        ok = sut.safely(act)
        actCount += 1
        actionCount[abstract(act[0])] += 1
        if not ok:
            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()
            sut.restart()

sut.internalReport()

orderedActs = sorted(actionCount.keys(), key=lambda x: actionCount[x])
for act in orderedActs:
    print act, actionCount[act]

print bugs, "FAILED"
print "TOTAL ACTIONS", actCount
print "TOTAL RUNTIME", time.time() - start
Ejemplo n.º 32
0
def main():

    if "--help" in sys.argv:
        print "Usage:  tstl_regress <test files> [--noCheck] [--html dir] [--noCover] [--verbose] [--running]"
        print "Options:"
        print " --noCheck:      do not run property checks"
        print " --html:         output an HTML coverage report to the chosen directory"
        print " --noCover:      do not compute code coverage"
        print " --verbose:      make actions verbose"
        print " --running:      give a running report on code coverage"
        print " --keepGoing:    don't stop on failed test"
        sys.exit(0)

    sut = sut.sut()

    nocover = False
    verbose = False
    running = False
    keepGoing = False
    ignoreProps = False
    lastWasHtml = False
    files = []
    htmlOut = None
    for f in sys.argv[1:]:
        if lastWasHtml:
            htmlOut = f
            lastWasHtml = False
        elif "--" not in f:
            files.append(f)
        elif f == "--html":
            lastWasHtml = True

    if "--noCover" in sys.argv:
        nocover = True
    if "--verbose" in sys.argv:
        verbose = True
    if "--noCheck" in sys.argv:
        ignoreProps = True
    if "--running" in sys.argv:
        running = True
    if "--keepGoing" in sys.argv:
        keepGoing = True

    if verbose:
        sut.verbose(True)

    anyFailed = False

    stime = time.time()
    for f in files:
        print "RUNNING TEST", f
        t = sut.loadTest(f)
        ok = False
        try:
            ok = sut.replay(t, checkProp=(not ignoreProps))
        except Exception as e:
            print "EXCEPTION RAISED:", e
        if running:
            if sut.newBranches() != set([]):
                for b in sut.newBranches():
                    print "New branch:", b
            if sut.newStatements() != set([]):
                for s in sut.newStatements():
                    print "New statement:", s
        if not ok:
            print "TEST", f, "FAILED:"
            print sut.failure()
            anyFailed = True
            if not keepGoing:
                sys.exit(255)
        print time.time() - stime, "ELAPSED"
        if not nocover:
            print "STATEMENTS:", len(sut.allStatements()), "BRANCHES:", len(
                sut.allBranches())

    if not nocover:
        sut.internalReport()
        print sut.report("coverage.out"), "PERCENT COVERED"

    if htmlOut != None:
        sut.htmlReport(htmlOut)

    if not anyFailed:
        print "ALL TESTS SUCCESSFUL"
Ejemplo n.º 33
0
import time
import sys

sut = sut.sut()

while True:
    forder = glob.glob("*.full")
    random.shuffle(forder)
    for f in forder:
        if os.path.exists(f.replace("full","normalized")):
            continue
        print "PROCESSING",f
        print "EXECUTING"
        t = sut.loadTest(f)
        assert(sut.failsAny(t))
        tfail = sut.failure()
        print tfail
        sys.stdout.flush()
        with open(f.replace("full","failure"),'w') as fout:
            fout.write(repr(sut.failure()[1]) + "\n")
        sameFail = lambda x: sut.failsAny(x,failure=tfail)
        tstart = time.time()
        r = sut.reduce(t, sameFail, keepLast=False)
        rtime = time.time()-tstart
        sys.stdout.flush()
        with open(f.replace("full","reducetime"),'w') as fout:
            fout.write(str(rtime) + "\n")        
        sut.saveTest(r, f.replace("full","reduced"))
        print "NORMALIZING"
        sut.clearNormalizationCache()
        tstart = time.time()