def generateOracleResults(startidx, endidx, eachsize, tslength): oracle_app = '%s/yaffs2_oracle' % (G_ROOT_FOLDER) for i in range(startidx, endidx + 1): tsfile = '%s/testcases/%06d/ts%06d.c' % (G_WORKING_FOLDER, tslength, i) res = generateResultNew(tsfile, oracle_app) myutils.appendline2file( '%s/oracle_res/testresult#%06d.txt' % (G_WORKING_FOLDER, tslength), res)
def main(): global G_ROOT_FOLDER G_ROOT_FOLDER = os.getcwd() now = datetime.datetime.now() randseed = now.microsecond parser = OptionParser() parser.add_option("", "--testcasesdir", dest="testcasesdir", action="store", type="string") parser.add_option("", "--mutantid", dest="mutantid", action="store", type = "int") parser.add_option("", "--mukillfile", dest="mukillfile", action="store", type="string") (options, args) = parser.parse_args() # prepare mutant binary os.chdir('mutgen') myutils.exec_cmd('bash generateMutants.sh yaffs2.c yaffs2mutants %d'%(options.mutantid)) if os.path.exists('mutant1%06d_yaffs2.c'%(options.mutantid)): myutils.exec_cmd('cp mutant1%06d_yaffs2.c ../muyaffs2.c'%(options.mutantid)) else: assert(0) os.chdir(G_ROOT_FOLDER) myutils.exec_cmd('gcc -o yaffs2_oracle yaffs2/yaffs2.c testcaserunner.cpp -DNO_COVERAGE %s %s -lstdc++ -ldl'\ %(YAFFS2_COMPILE_OPTIONS, OPTIMIZATION)) myutils.exec_cmd('gcc -o yaffs2_mutant muyaffs2.c testcaserunner.cpp -DNO_COVERAGE %s %s -lstdc++ -ldl'\ %(YAFFS2_COMPILE_OPTIONS, OPTIMIZATION)) testcasefiles=glob.glob('%s/ts*.c'%(options.testcasesdir)) testcasefiles= testcasefiles +glob.glob('%s/ts*.c.cmin'%(options.testcasesdir)) # print testcasefiles testcasefiles.sort() myutils.exec_cmd('rm oracle_results.txt mutant_results.txt') files = [] for tsfile in testcasefiles: files.append(tsfile.split("/")[-1]) res = generateResultNew(tsfile, 'yaffs2_oracle') myutils.appendline2file('oracle_results.txt', res) res = generateResultNew(tsfile, 'yaffs2_mutant') myutils.appendline2file('mutant_results.txt', res) oracle_results=myutils.getFileLines('oracle_results.txt') mutant_results=myutils.getFileLines('mutant_results.txt') assert(len(oracle_results)==len(mutant_results)) cmpstr= 'M:' + str(options.mutantid) + ',' for i in range(0, len(oracle_results)): cmpstr += files[i]+':' if oracle_results[i] == mutant_results[i]: cmpstr += '0,' else: cmpstr += '1,' myutils.appendline2file(options.mukillfile, cmpstr)
def main(): global G_ROOT_FOLDER G_ROOT_FOLDER = os.getcwd() now = datetime.datetime.now() randseed = now.microsecond parser = OptionParser() parser.add_option("", "--testcasesdir", dest="testcasesdir", action="store", type="string") parser.add_option("", "--mutantid", dest="mutantid", action="store", type = "int") parser.add_option("", "--mukillfile", dest="mukillfile", action="store", type="string") (options, args) = parser.parse_args() # prepare mutant binary os.chdir('mutgen') myutils.exec_cmd('bash generateMutants.sh yaffs2.c yaffs2mutants %d'%(options.mutantid)) if os.path.exists('mutant1%06d_yaffs2.c'%(options.mutantid)): myutils.exec_cmd('cp mutant1%06d_yaffs2.c ../muyaffs2.c'%(options.mutantid)) else: assert(0) os.chdir(G_ROOT_FOLDER) myutils.exec_cmd('rm yaffs2_oracle yaffs2_mutant') myutils.exec_cmd('gcc -o yaffs2_oracle yaffs2/yaffs2.c testcaserunner.cpp -DNO_COVERAGE %s %s -lstdc++ -ldl'\ %(YAFFS2_COMPILE_OPTIONS, OPTIMIZATION)) myutils.exec_cmd('gcc -o yaffs2_mutant muyaffs2.c testcaserunner.cpp -DNO_COVERAGE %s %s -lstdc++ -ldl'\ %(YAFFS2_COMPILE_OPTIONS, OPTIMIZATION)) if not( os.path.exists('yaffs2_oracle') and os.path.exists('yaffs2_mutant')): return testcasefiles=glob.glob('%s/ts*.c'%(options.testcasesdir)) testcasefiles.sort() myutils.exec_cmd('rm oracle_results.txt mutant_results.txt') for tsfile in testcasefiles: res = generateResultNew(tsfile, 'yaffs2_oracle') myutils.appendline2file('oracle_results.txt', res) res = generateResultNew(tsfile, 'yaffs2_mutant') myutils.appendline2file('mutant_results.txt', res) oracle_results=myutils.getFileLines('oracle_results.txt') mutant_results=myutils.getFileLines('mutant_results.txt') assert(len(oracle_results)==len(mutant_results)) cmpstr='' for i in range(0, len(oracle_results)): if oracle_results[i] == mutant_results[i]: cmpstr += '0,' else: cmpstr += '1,' myutils.appendline2file(options.mukillfile, cmpstr)
def main(): global G_ROOT_FOLDER G_ROOT_FOLDER = os.getcwd() now = datetime.datetime.now() randseed = now.microsecond parser = OptionParser() parser.add_option("", "--precompile", dest="precompile", action="store_true", default=False) parser.add_option("", "--ignore", dest="ignore", action="store_true", default=False) parser.add_option("", "--gentestcases", dest="gentestcases", action="store_true", default=False) parser.add_option("", "--strategy", dest="strategy", action="store", type="string") parser.add_option("", "--format", dest="format", action="store", type="string") parser.add_option("", "--tslength", dest="tslength", action="store", type="int") parser.add_option("", "--configfile", dest="configfile", action="store", type="string") parser.add_option("", "--startidx", dest="startidx", action="store", type="int") parser.add_option("", "--endidx", dest="endidx", action="store", type="int") parser.add_option("", "--suitesize", dest="suitesize", action="store", type="int") parser.add_option("", "--coverage", dest="coverage", action="store_true", default=False) parser.add_option("", "--tracedb", dest="tracedb", action="store", type="string") parser.add_option("", "--mutantskill", dest="mutantskill", action="store_true", default=False) parser.add_option("", "--savetemp", dest="savetemp", action="store_true", default=False) parser.add_option("", "--timelimit", dest="timelimit", action="store", type="int") parser.add_option("", "--workingfolder", dest="workingfolder", action="store", type="string") parser.add_option("", "--randseed", dest="randseed", action="store", type="int") (options, args) = parser.parse_args() # precompile/instrument some common modules. if options.precompile == True: preCompile() return if options.randseed != None: randseed = options.randseed tslength = 200 if options.tslength != None: tslength = options.tslength # set path related stuff, everthing is absolute. global G_WORKING_FOLDER if options.workingfolder != None: if os.path.isabs(options.workingfolder) == True: G_WORKING_FOLDER = options.workingfolder else: G_WORKING_FOLDER = os.path.abspath(options.workingfolder) myutils.ensuredir(G_WORKING_FOLDER) global G_TMP_FOLDER G_TMP_FOLDER = "__tmp__%d" % (os.getpid()) G_TMP_FOLDER = os.path.abspath(G_TMP_FOLDER) myutils.ensuredir(G_TMP_FOLDER) # log current command myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strftime("%Y-%m-%d %H:%M:%S", localtime())) myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), string.join(sys.argv[0:], " ")) configfile = "" if options.configfile != None: configfile = options.configfile singlesize = 1 if options.startidx != None and options.endidx != None: startidx = options.startidx endidx = options.endidx timer = myutils.Timer() if options.gentestcases == True: myutils.ensuredir("%s/testcases" % (G_WORKING_FOLDER)) timer.start() generateTestCases( startidx, endidx, singlesize, tslength, "%s/testcases" % (G_WORKING_FOLDER), configfile, randseed, options.strategy, options.format, ) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), "Generating test cases took %d seconds." % (timer.elapsed()) ) if options.coverage == True: myutils.ensuredir("%s/coverage" % (G_WORKING_FOLDER)) timer.start() generateCoverageInfo( startidx, endidx, singlesize, tslength, "%s/coverage" % (G_WORKING_FOLDER), options.suitesize ) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), "Generating coverage information took %d seconds." % (timer.elapsed()), ) if options.mutantskill == True: timer.start() myutils.ensuredir("%s/oracle_res" % (G_WORKING_FOLDER)) generateOracleResults(startidx, endidx, singlesize, tslength) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), "Generating oracle results took %d seconds." % (timer.elapsed()), ) timer.start() generateMuResults(startidx, endidx, options.suitesize, tslength, options.savetemp) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), "Generating mutants results took %d seconds." % (timer.elapsed()), ) myutils.rmfiles([G_TMP_FOLDER]) myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strftime("%Y-%m-%d %H:%M:%S", localtime())) numofdash = len(string.join(sys.argv[0:], " ")) strdash = "-" * numofdash myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strdash)
def generateOracleResults(startidx, endidx, eachsize, tslength): oracle_app = "%s/yaffs2_oracle" % (G_ROOT_FOLDER) for i in range(startidx, endidx + 1): tsfile = "%s/testcases/%06d/ts%06d.c" % (G_WORKING_FOLDER, tslength, i) res = generateResultNew(tsfile, oracle_app) myutils.appendline2file("%s/oracle_res/testresult#%06d.txt" % (G_WORKING_FOLDER, tslength), res)
def main(): global G_ROOT_FOLDER G_ROOT_FOLDER = os.getcwd() now = datetime.datetime.now() randseed = now.microsecond parser = OptionParser() parser.add_option("", "--precompile", dest="precompile", action="store_true", default=False) parser.add_option("", "--ignore", dest="ignore", action="store_true", default=False) parser.add_option("", "--gentestcases", dest="gentestcases", action="store_true", default=False) parser.add_option("", "--strategy", dest="strategy", action="store", type='string') parser.add_option("", "--format", dest="format", action="store", type='string') parser.add_option("", "--tslength", dest="tslength", action="store", type="int") parser.add_option("", "--configfile", dest="configfile", action="store", type='string') parser.add_option("", "--startidx", dest="startidx", action="store", type="int") parser.add_option("", "--endidx", dest="endidx", action="store", type="int") parser.add_option("", "--suitesize", dest="suitesize", action="store", type="int") parser.add_option("", "--coverage", dest="coverage", action="store_true", default=False) parser.add_option("", "--tracedb", dest="tracedb", action="store", type="string") parser.add_option("", "--mutantskill", dest="mutantskill", action="store_true", default=False) parser.add_option("", "--savetemp", dest="savetemp", action="store_true", default=False) parser.add_option("", "--timelimit", dest="timelimit", action="store", type="int") parser.add_option("", "--workingfolder", dest="workingfolder", action="store", type="string") parser.add_option("", "--randseed", dest="randseed", action="store", type="int") (options, args) = parser.parse_args() # precompile/instrument some common modules. if options.precompile == True: preCompile() return if options.randseed != None: randseed = options.randseed tslength = 200 if options.tslength != None: tslength = options.tslength # set path related stuff, everthing is absolute. global G_WORKING_FOLDER if options.workingfolder != None: if os.path.isabs(options.workingfolder) == True: G_WORKING_FOLDER = options.workingfolder else: G_WORKING_FOLDER = os.path.abspath(options.workingfolder) myutils.ensuredir(G_WORKING_FOLDER) global G_TMP_FOLDER G_TMP_FOLDER = '__tmp__%d' % (os.getpid()) G_TMP_FOLDER = os.path.abspath(G_TMP_FOLDER) myutils.ensuredir(G_TMP_FOLDER) # log current command myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strftime("%Y-%m-%d %H:%M:%S", localtime())) myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), string.join(sys.argv[0:], " ")) configfile = '' if options.configfile != None: configfile = options.configfile singlesize = 1 if options.startidx != None and options.endidx != None: startidx = options.startidx endidx = options.endidx timer = myutils.Timer() if options.gentestcases == True: myutils.ensuredir('%s/testcases' % (G_WORKING_FOLDER)) timer.start() generateTestCases(startidx, endidx, singlesize, tslength, '%s/testcases'%(G_WORKING_FOLDER), \ configfile, randseed, options.strategy, options.format) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), 'Generating test cases took %d seconds.' % (timer.elapsed())) if options.coverage == True: myutils.ensuredir('%s/coverage' % (G_WORKING_FOLDER)) timer.start() generateCoverageInfo(startidx, endidx, singlesize, tslength, '%s/coverage' % (G_WORKING_FOLDER), options.suitesize) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), 'Generating coverage information took %d seconds.' % (timer.elapsed())) if options.mutantskill == True: timer.start() myutils.ensuredir('%s/oracle_res' % (G_WORKING_FOLDER)) generateOracleResults(startidx, endidx, singlesize, tslength) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), 'Generating oracle results took %d seconds.' % (timer.elapsed())) timer.start() generateMuResults(startidx, endidx, options.suitesize, tslength, options.savetemp) timer.end() myutils.appendline2file( "%s/cmdhistory.txt" % (G_WORKING_FOLDER), 'Generating mutants results took %d seconds.' % (timer.elapsed())) myutils.rmfiles([G_TMP_FOLDER]) myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strftime("%Y-%m-%d %H:%M:%S", localtime())) numofdash = len(string.join(sys.argv[0:], " ")) strdash = '-' * numofdash myutils.appendline2file("%s/cmdhistory.txt" % (G_WORKING_FOLDER), strdash)