Example #1
0
def getSrcCov(srcPath, testDataPathDir):
    cov_info = []
    res = []
    files = os.listdir(testDataPathDir)
    for i in files:
        if ".in" not in i:
            continue
        input_file = os.path.join(testDataPathDir, i)
        output_file = os.path.join(testDataPathDir, i[:-2] + "out")
        cmd = COMLINE_COV % (srcPath, input_file)
        try:
            os.system(cmd)
            filename = ".coverage"
            f = open(filename, 'r')
            text = f.read()
            f.close()
            # print(text)
            posr = text.rfind(']')
            posl = text.rfind('[')
            sub = text[posl + 1:posr].split(',')
            subs = []
            for item in sub:
                subs.append(int(item))
                subs.sort()
            cov_info.append(subs)
        except:
            cov_info.append([])

        cmd = COMLINE_RUN % (srcPath, input_file, './temp.out')
        os.system(cmd)
        filename = "./temp.out"
        res.append(util.compare_res(filename, output_file))
    return cov_info, res
Example #2
0
def getSrcCov(granularity, srcPath, testDataPathDir, outputDir):
    cov_info = []
    res = []
    file_order = []
    files = os.listdir(testDataPathDir)
    files.sort()
    for i in files:
        if ".in" not in i:
            continue
        input_file = os.path.join(testDataPathDir, i)
        output_file = os.path.join(testDataPathDir, i[: -2] + "out")
        file_order.append(i[: -2] + "out")
        cmd = COMLINE_COV % (srcPath, input_file)
        try:
            os.system(cmd)
            filename = ".coverage"
            f = open(filename, 'r')
            text = f.read()
            f.close()
            # print(text)
            posr = text.rfind(']')
            posl = text.rfind('[')
            sub = text[posl + 1:posr].split(',')
            subs = []
            for item in sub:
                subs.append(int(item))
                subs.sort()
            cov_info.append(subs)
        except:
            cov_info.append([])

        try:
            outFIleName = os.path.join(outputDir, i[: -2] + "out")
            cmd = COMLINE_RUN % (srcPath, input_file, outFIleName)
            os.system(cmd)
            filename = outFIleName
            res.append(util.compare_res(filename, output_file))
        except:
            res.append(False)

    granularity_cov_info = []
    granularity_res = []
    mod = len(res)
    for i in range(10):
        stpos = i * granularity
        edpos = (i + 1) * granularity
        temp_cov = []
        temp_res = True
        for index in range(stpos, edpos):
            temp_cov = util.mergeList(temp_cov, cov_info[index % mod])
            temp_res = util.mergeResult(temp_res, res[index % mod])
        granularity_cov_info.append(temp_cov)
        granularity_res.append(temp_res)
    return granularity_cov_info, granularity_res, file_order
Example #3
0
def getInfo(temp_order, caseNum, res, mutateOutPutDir, programOutPutDir):
    Akf, Anf, Akp, Anp = 0, 0, 0, 0
    for i in range(caseNum):
        myOutFile = os.path.join(programOutPutDir, temp_order[i])
        mutantOutFile = os.path.join(mutateOutPutDir, temp_order[i])
        kill = not util.compare_res(mutantOutFile, myOutFile)
        if res[i] == True:
            if kill == True:
                Akp += 1
            if kill == False:
                Anp += 1
        if res[i] == False:
            if kill == True:
                Akf += 1
            if kill == False:
                Anf += 1
    return Akf, Anf, Akp, Anp
Example #4
0
def getInfo(granularity, temp_order, caseNum, res, mutateOutPutDir, programOutPutDir):
    Akf, Anf, Akp, Anp = 0, 0, 0, 0
    mod = len(temp_order)
    for i in range(caseNum):
        stpos = i * granularity
        edpos = (i + 1) * granularity
        kill = True
        for index in range(stpos, edpos):
            myOutFile = os.path.join(programOutPutDir, temp_order[index%mod])
            mutantOutFile = os.path.join(mutateOutPutDir, temp_order[index%mod])
            kill = util.mergeResult(kill, not util.compare_res(mutantOutFile, myOutFile))

        if res[i] == True:
            if kill == True:
                Akp += 1
            if kill == False:
                Anp += 1
        if res[i] == False:
            if kill == True:
                Akf += 1
            if kill == False:
                Anf += 1
    return Akf, Anf, Akp, Anp