Skip to content

Instantly share code, notes, and snippets.

@jon-whit
Created November 12, 2015 21:10
Show Gist options
  • Save jon-whit/7506871fa466c6a85aef to your computer and use it in GitHub Desktop.
Save jon-whit/7506871fa466c6a85aef to your computer and use it in GitHub Desktop.
import argparse
import glob
import os
import re
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Reports svcomp benchmarks which have references to uninitialized memory.")
parser.add_argument("--bench-dir", default=".", help="The directory containing the benchmark files that will be stripped.")
parser.add_argument("--dest-dir", default="./stripped-files", help="The destination directory where stripped files will be placed.")
args = parser.parse_args()
benchmarks = glob.glob(args.bench_dir + '/' + "*.[ic]")
regex = "^#(line)? \d"
for benchmark_path in benchmarks:
# Open the benchmark file for reading
benchmark_name = os.path.basename(benchmark_path)
benchmark_file = open(benchmark_path, 'r')
# Create the output file path (if it doesn't exist)
dest_dir = args.bench_dir + "/stripped-files/"
dest_path = dest_dir + benchmark_name
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
dest_file = open(dest_path, 'w')
for line in benchmark_file:
if not re.match(regex, line):
dest_file.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment