예제 #1
0
def generate():
    total_count = 0
    syntax_valid_count = 0
    files = []
    for root, d_names, f_names in os.walk(seed_path):
        for f in f_names:
            files.append(os.path.join(root, f))
    for file in files:
        if 'deepfuzz' in file:
            continue
        if not file.endswith('.kt'):
            continue
        #try:
        text = open(file, 'r').read()
        # text = pp.replace_macro(text, file)
        text = pp.remove_comment(text)
        #text = pp.remove_space(text)
        is_valid = pp.verify_correctness(text, file, 'deepfuzz_original')
        if not is_valid:
            continue
        total_count += 1
        text = synthesis(text, 'g3', 'sample')
        is_valid = pp.verify_correctness(text, file, 'deepfuzz_g1_nosample')
        if (is_valid):
            syntax_valid_count += 1
        #except:
        #continue
    pass_rate = syntax_valid_count / total_count
    print('syntax_valid_count: %d' % syntax_valid_count)
    print('total_count: %d' % total_count)
    print('pass rate: %f' % pass_rate)
예제 #2
0
        print(sentences[i] + "\t" + next_chars[i])


path = './testData1'
files = []
valid_count = 0
for root, d_names, f_names in os.walk(path):
    try:
        for f in f_names:
            files.append(os.path.join(root, f))
    except Exception:
        continue
for file in files:
    try:
        print('--------------------------------------------------')
        print(file)
        # if 'nocomment' in file or 'nospace' in file or 'nomacro' in file or 'raw' in file:
        #     command = 'rm ' + file
        #     p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
        text = open(file, 'r').read()
        text = pp.remove_comment(text)
        # text = pp.replace_macro(text, file)
        text = pp.remove_space(text)
        is_valid = pp.verify_correctness(text, file, 'nospace')
        if is_valid:
            valid_count += 1
            generate_training_data(text)
    except Exception:
        continue
print(valid_count)