Esempio n. 1
0
    if output_type == 'svg':
        # Remove the number in 'Generated by graphviz version <number>'
        # to able to compare the output to the reference. This version
        # number is different for every Graphviz compilation.
        file = open(output_file, 'r')
        lines = file.readlines()
        file.close()

        file = open(output_file, 'w')
        for line in lines:
            if '<!-- Generated by graphviz version ' in line:
                file.write('<!-- Generated by graphviz version\n')
            else:
                file.write(line)

failures = 0
for shape in shapes:
    for output_type in output_types:
        generate_shape_graph(shape, output_type)
        if not compare_graphs(shape, output_type):
            failures += 1

print('')
print('Results for "shapes" regression test:')
print('    Number of tests: ' + str(len(shapes) * len(output_types)))
print('    Number of failures: ' + str(failures))

if not failures == 0:
    exit(1) 
Esempio n. 2
0
    if output_type == 'svg':
        # Remove the number in 'Generated by graphviz version <number>'
        # to able to compare the output to the reference. This version
        # number is different for every Graphviz compilation.
        file = open(output_file, 'r')
        lines = file.readlines()
        file.close()

        file = open(output_file, 'w')
        for line in lines:
            if '<!-- Generated by graphviz version ' in line:
                file.write('<!-- Generated by graphviz version\n')
            else:
                file.write(line)


failures = 0
for shape in shapes:
    for output_type in output_types:
        generate_shape_graph(shape, output_type)
        if not compare_graphs(shape, output_type):
            failures += 1

print('')
print('Results for "shapes" regression test:')
print(f'    Number of tests: {len(shapes) * len(output_types)}')
print(f'    Number of failures: {failures}')

if not failures == 0:
    exit(1)
Esempio n. 3
0
def test_shape(shape, output_type):
    os.chdir(Path(__file__).resolve().parent)
    generate_shape_graph(shape, output_type)
    assert compare_graphs(shape, output_type)
Esempio n. 4
0
def generate_vuln_graph(vulnfile, output_type):
    if not Path('output').exists():
        Path('output').mkdir(parents=True)

    output_file = Path('output') / f'{vulnfile}.{output_type[0]}'
    input_file = Path('input') / f'{vulnfile}.dot'
    process = Popen(
        ['dot', '-T' + output_type[1], '-o', output_file, input_file],
        stdin=PIPE)

    if process.wait() < 0:
        print(f'An error occurred while generating: {output_file}')
        exit(1)


failures = 0
for vulnfile in vulnfiles:
    for output_type in output_types:
        generate_vuln_graph(vulnfile, output_type)
        if not compare_graphs(vulnfile, output_type[0]):
            failures += 1

print('')
print('Results for "vuln" regression test:')
print(f'    Number of tests: {len(vulnfiles) * len(output_types)}')
print(f'    Number of failures: {failures}')

if not failures == 0:
    exit(1)
Esempio n. 5
0
 def test_shape(self, shape, output_type):
     os.chdir(os.path.dirname(os.path.realpath(__file__)))
     generate_shape_graph(shape, output_type)
     assert compare_graphs(shape, output_type)