Exemplo n.º 1
0
    def test_merge_clang_extdef_mappings(self):
        """ Test merging multiple func map files. """

        output_file = os.path.join(self.test_workspace, 'externalDefMap.txt')
        merge_clang_extdef_mappings.merge(self.extdef_maps_dir, output_file)

        with open(output_file, 'r',
                  encoding='utf-8', errors='ignore') as o_file:
            lines = o_file.read().split('\n')

        expected_lines = ["c:@F@f# path/to/file.cpp.ast",
                          "c:@F@g# path/to/file.cpp.ast",
                          "c:@F@main# path/to/file2.cpp.ast",
                          "c:@F@h# path/to/file2.cpp.ast"]
        for expected_line in expected_lines:
            self.assertTrue(expected_line in lines)
Exemplo n.º 2
0
def main():
    """ Merge CTU funcs maps main command line. """
    parser = argparse.ArgumentParser(
        prog="merge-clang-extdef-mappings",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description="Merge individual clang extdef mapping files into one "
        "mapping file.",
        epilog="""Example:
  merge-clang-extdef-mappings -i /path/to/fn_map_folder
  /path/to/externalDefMap.txt""")

    __add_arguments_to_parser(parser)

    args = parser.parse_args()

    merge_clang_extdef_mappings.merge(args.input, args.output)
Exemplo n.º 3
0
def merge_clang_extdef_mappings(ctu_dir, ctu_func_map_file,
                                ctu_temp_fnmap_folder):
    """ Merge individual function maps into a global one."""

    triple_arches = glob.glob(os.path.join(ctu_dir, '*'))
    for triple_path in triple_arches:
        if not os.path.isdir(triple_path):
            continue

        triple_arch = os.path.basename(triple_path)
        fnmap_dir = os.path.join(ctu_dir, triple_arch, ctu_temp_fnmap_folder)

        merged_fn_map = os.path.join(ctu_dir, triple_arch, ctu_func_map_file)
        merge(fnmap_dir, merged_fn_map)

        # Remove all temporary files.
        shutil.rmtree(fnmap_dir, ignore_errors=True)