Ejemplo n.º 1
0
def remove_testcases_from_directories(directories):
    """Removes all testcases and their dependencies from testcase directories."""
    generators = []
    for directory in directories:
        if not directory.strip():
            continue

        # If there is a bot-specific files list, delete it now.
        bot_testcases_file_path = utils.get_bot_testcases_file_path(directory)
        shell.remove_file(bot_testcases_file_path)

        generators.append(os.walk(directory))

    for generator in generators:
        for structure in generator:
            base_directory = structure[0]
            for filename in structure[2]:
                if not is_testcase_resource(filename):
                    continue

                if filename.startswith(RESOURCES_PREFIX):
                    # In addition to removing this file, remove all resources.
                    resources_file_path = os.path.join(base_directory,
                                                       filename)
                    resources = read_resource_list(resources_file_path)
                    for resource in resources:
                        shell.remove_file(resource)

                file_path = os.path.join(base_directory, filename)
                shell.remove_file(file_path)
Ejemplo n.º 2
0
def create_testcase_list_file(testcase_file_paths, input_directory):
    """Store list of fuzzed testcases from fuzzer in a bot specific
  testcase list file."""
    if not testcase_file_paths:
        logs.log_error('No testcases found, skipping list file.')
        return

    bot_testcases_file_path = utils.get_bot_testcases_file_path(
        input_directory)
    with open(bot_testcases_file_path, 'wb') as bot_testcases_file_handle:
        bot_testcases_file_handle.write('\n'.join(testcase_file_paths))