-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #789 from cppalliance/fuzzing
Improved Fuzzing
- Loading branch information
Showing
2 changed files
with
70 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/env python | ||
|
||
# Copyright (c) 2025 Alexander Grund | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# https://www.boost.org/LICENSE_1_0.txt. | ||
|
||
import os | ||
import sys | ||
|
||
def get_samples(input_files): | ||
for file_name in input_files: | ||
if not os.path.isfile(file_name): | ||
raise RuntimeError("Not a file: " + file_name) | ||
with open(file_name, 'r') as input_file: | ||
yield from input_file | ||
|
||
|
||
def process_files(output_folder, input_files): | ||
if not os.path.exists(output_folder): | ||
os.makedirs(output_folder) | ||
|
||
for i, sample in enumerate(get_samples(input_files)): | ||
with open(os.path.join(output_folder, str(i) + ".txt"), 'w') as output_file: | ||
output_file.write(sample) | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 3: | ||
print("Usage: python script.py <output_folder> <input_file1> [<input_file2> ...]") | ||
sys.exit(1) | ||
|
||
process_files(output_folder=sys.argv[1], input_files=sys.argv[2:]) |