diff --git a/frontend/src/frontend/code_generator/user_callgraph.py b/frontend/src/frontend/code_generator/user_callgraph.py index 756a81b..172cdf0 100644 --- a/frontend/src/frontend/code_generator/user_callgraph.py +++ b/frontend/src/frontend/code_generator/user_callgraph.py @@ -59,11 +59,11 @@ def _load_cfg_from_file(path: str) -> cfg_pb2.CFG: with open(path, 'rb') as f: if path.endswith('pb'): cfg.ParseFromString(f.read()) - elif path.endswith('pbtext'): + elif path.endswith('pbtxt'): text_format.Parse(f.read(), cfg) else: raise RuntimeError( - 'Invalid protobuf suffix found, expected .pb or .pbtext') + 'Invalid protobuf suffix found, expected .pb or .pbtxt') return cfg def format_vars_definition(self) -> str: diff --git a/frontend/tests/resources/branch_conditional_direct.pbtext b/frontend/tests/resources/branch_conditional_direct.pbtxt similarity index 100% rename from frontend/tests/resources/branch_conditional_direct.pbtext rename to frontend/tests/resources/branch_conditional_direct.pbtxt diff --git a/frontend/tests/resources/branch_direct_call.pbtext b/frontend/tests/resources/branch_direct_call.pbtxt similarity index 100% rename from frontend/tests/resources/branch_direct_call.pbtext rename to frontend/tests/resources/branch_direct_call.pbtxt diff --git a/frontend/tests/resources/branch_implicit_fallthrough.pbtext b/frontend/tests/resources/branch_implicit_fallthrough.pbtxt similarity index 100% rename from frontend/tests/resources/branch_implicit_fallthrough.pbtext rename to frontend/tests/resources/branch_implicit_fallthrough.pbtxt diff --git a/frontend/tests/resources/branch_indirect.pbtext b/frontend/tests/resources/branch_indirect.pbtxt similarity index 100% rename from frontend/tests/resources/branch_indirect.pbtext rename to frontend/tests/resources/branch_indirect.pbtxt diff --git a/frontend/tests/resources/branch_indirect_call.pbtext b/frontend/tests/resources/branch_indirect_call.pbtxt similarity index 100% rename from frontend/tests/resources/branch_indirect_call.pbtext rename to frontend/tests/resources/branch_indirect_call.pbtxt diff --git a/frontend/tests/resources/branch_indirect_call_multitarget.pbtext b/frontend/tests/resources/branch_indirect_call_multitarget.pbtxt similarity index 100% rename from frontend/tests/resources/branch_indirect_call_multitarget.pbtext rename to frontend/tests/resources/branch_indirect_call_multitarget.pbtxt diff --git a/frontend/tests/resources/conflictingfunction_codeblock.pbtext b/frontend/tests/resources/conflictingfunction_codeblock.pbtxt similarity index 100% rename from frontend/tests/resources/conflictingfunction_codeblock.pbtext rename to frontend/tests/resources/conflictingfunction_codeblock.pbtxt diff --git a/frontend/tests/resources/missingbranchtargets.pbtext b/frontend/tests/resources/missingbranchtargets.pbtxt similarity index 100% rename from frontend/tests/resources/missingbranchtargets.pbtext rename to frontend/tests/resources/missingbranchtargets.pbtxt diff --git a/frontend/tests/resources/missingcodeblockbody.pbtext b/frontend/tests/resources/missingcodeblockbody.pbtxt similarity index 100% rename from frontend/tests/resources/missingcodeblockbody.pbtext rename to frontend/tests/resources/missingcodeblockbody.pbtxt diff --git a/frontend/tests/resources/missingentry.pbtext b/frontend/tests/resources/missingentry.pbtxt similarity index 100% rename from frontend/tests/resources/missingentry.pbtext rename to frontend/tests/resources/missingentry.pbtxt diff --git a/frontend/tests/resources/missingsignature.pbtext b/frontend/tests/resources/missingsignature.pbtxt similarity index 100% rename from frontend/tests/resources/missingsignature.pbtext rename to frontend/tests/resources/missingsignature.pbtxt diff --git a/frontend/tests/resources/onecallchain.pbtext b/frontend/tests/resources/onecallchain.pbtxt similarity index 100% rename from frontend/tests/resources/onecallchain.pbtext rename to frontend/tests/resources/onecallchain.pbtxt diff --git a/frontend/tests/resources/onefunction.pbtext b/frontend/tests/resources/onefunction.pbtxt similarity index 100% rename from frontend/tests/resources/onefunction.pbtext rename to frontend/tests/resources/onefunction.pbtxt diff --git a/frontend/tests/resources/onefunction_globalvars.pbtext b/frontend/tests/resources/onefunction_globalvars.pbtxt similarity index 100% rename from frontend/tests/resources/onefunction_globalvars.pbtext rename to frontend/tests/resources/onefunction_globalvars.pbtxt diff --git a/frontend/tests/resources/small_callchain.pbtext b/frontend/tests/resources/small_callchain.pbtxt similarity index 100% rename from frontend/tests/resources/small_callchain.pbtext rename to frontend/tests/resources/small_callchain.pbtxt diff --git a/frontend/tests/unit/test_callgraph.py b/frontend/tests/unit/test_callgraph.py index 6dfdb60..7b6bfc7 100644 --- a/frontend/tests/unit/test_callgraph.py +++ b/frontend/tests/unit/test_callgraph.py @@ -27,7 +27,7 @@ def test_callgraph_from_proto_file(resources): def test_get_formatted_headers_onecallchain(resources): - test_file = os.path.join(resources, 'onecallchain.pbtext') + test_file = os.path.join(resources, 'onecallchain.pbtxt') expected = ('void function_2();\n' 'void function_3();\n' 'void function_4();\n' @@ -39,7 +39,7 @@ def test_get_formatted_headers_onecallchain(resources): def test_load_onecallchain(resources): - test_file = os.path.join(resources, 'onecallchain.pbtext') + test_file = os.path.join(resources, 'onecallchain.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) assert isinstance(cfg, user_callgraph.Callgraph) assert len(cfg.functions) == 5 @@ -55,7 +55,7 @@ def test_load_binary_proto(resources): def test_load_onefunction(resources): - test_file = os.path.join(resources, 'onefunction.pbtext') + test_file = os.path.join(resources, 'onefunction.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) assert isinstance(cfg, user_callgraph.Callgraph) assert len(cfg.functions) == 1 @@ -63,7 +63,7 @@ def test_load_onefunction(resources): def test_print_function_onefunction(resources): - test_file = os.path.join(resources, 'onefunction.pbtext') + test_file = os.path.join(resources, 'onefunction.pbtxt') expected = ('void function_19() {\n' 'label1:;\n' 'int x = 1;\n' @@ -77,7 +77,7 @@ def test_print_function_onefunction(resources): def test_print_function_onecallchain(resources): - test_file = os.path.join(resources, 'onecallchain.pbtext') + test_file = os.path.join(resources, 'onecallchain.pbtxt') expected_2 = ('void function_2() {\n' 'label74:;\n' 'int x = 1;\n' @@ -100,7 +100,7 @@ def test_print_function_onecallchain(resources): def test_get_formatted_headers_onefunction(resources): - test_file = os.path.join(resources, 'onefunction.pbtext') + test_file = os.path.join(resources, 'onefunction.pbtxt') expected = 'void function_19();\n' cfg = user_callgraph.Callgraph.from_proto(test_file) output = cfg.format_headers() @@ -109,7 +109,7 @@ def test_get_formatted_headers_onefunction(resources): def test_indirect_branch_multitarget(resources): test_file = os.path.join(resources, - 'branch_indirect_call_multitarget.pbtext') + 'branch_indirect_call_multitarget.pbtxt') blocks.Branch.set_seed(0) expected = ( 'static int index_1034 = 0;\n' diff --git a/frontend/tests/unit/test_source_generator.py b/frontend/tests/unit/test_source_generator.py index 814c91b..6a2a64d 100644 --- a/frontend/tests/unit/test_source_generator.py +++ b/frontend/tests/unit/test_source_generator.py @@ -28,7 +28,7 @@ def resources(rootdir): @pytest.mark.parametrize( 'pbfile', - ['branch_indirect_call.pbtext', 'branch_indirect_call_multitarget.pbtext']) + ['branch_indirect_call.pbtxt', 'branch_indirect_call_multitarget.pbtxt']) def test_branch_indirect_call(resources, tmpdir, pbfile): test_file = os.path.join(resources, pbfile) cfg = user_callgraph.Callgraph.from_proto(test_file) @@ -45,7 +45,7 @@ def test_branch_indirect_call(resources, tmpdir, pbfile): def test_branch_direct_call(resources, tmpdir): - test_file = os.path.join(resources, 'branch_direct_call.pbtext') + test_file = os.path.join(resources, 'branch_direct_call.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) source_gen.write_files() @@ -60,7 +60,7 @@ def test_branch_direct_call(resources, tmpdir): def test_branch_indirect(resources, tmpdir): - test_file = os.path.join(resources, 'branch_indirect.pbtext') + test_file = os.path.join(resources, 'branch_indirect.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) source_gen.write_files() @@ -75,7 +75,7 @@ def test_branch_indirect(resources, tmpdir): def test_branch_conditional_direct(resources, tmpdir): - test_file = os.path.join(resources, 'branch_conditional_direct.pbtext') + test_file = os.path.join(resources, 'branch_conditional_direct.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) source_gen.write_files() @@ -86,7 +86,7 @@ def test_branch_conditional_direct(resources, tmpdir): def test_branch_implicit_fallthrough(resources, tmpdir): - test_file = os.path.join(resources, 'branch_implicit_fallthrough.pbtext') + test_file = os.path.join(resources, 'branch_implicit_fallthrough.pbtxt') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) source_gen.write_files() @@ -131,7 +131,7 @@ def check_for_asm(binary: str, symbol: str, asm: str) -> bool: def test_write_onefunction(resources, tmpdir): - test_file = os.path.join(resources, 'onefunction.pbtext') + test_file = os.path.join(resources, 'onefunction.pbtxt') expected_dir = os.path.join(resources, 'write_onefunction') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) @@ -142,7 +142,7 @@ def test_write_onefunction(resources, tmpdir): def test_write_onefunction_globalvars(resources, tmpdir): - test_file = os.path.join(resources, 'onefunction_globalvars.pbtext') + test_file = os.path.join(resources, 'onefunction_globalvars.pbtxt') expected_dir = os.path.join(resources, 'write_onefunction_globalvars') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg) @@ -153,7 +153,7 @@ def test_write_onefunction_globalvars(resources, tmpdir): def test_write_onecallchain(resources, tmpdir): - test_file = os.path.join(resources, 'onecallchain.pbtext') + test_file = os.path.join(resources, 'onecallchain.pbtxt') expected_dir = os.path.join(resources, 'write_onecallchain') cfg = user_callgraph.Callgraph.from_proto(test_file) source_gen = source_generator.SourceGenerator(tmpdir, cfg)