Validate trace executable before starting thread pool

This commit is contained in:
DrChat 2017-12-20 14:36:10 -06:00
parent 4881603df9
commit a9318f72c9
1 changed files with 28 additions and 12 deletions

View File

@ -27,19 +27,17 @@ def file_type(value):
def run_dumper(exe_path, input_name): def run_dumper(exe_path, input_name):
try: start_time = time.perf_counter()
start_time = time.perf_counter()
p = subprocess.Popen([ p = subprocess.Popen([
exe_path, exe_path,
input_name, input_name,
'--log_file=stdout', '--log_file=stdout',
], stdout=subprocess.PIPE, stderr=subprocess.PIPE) ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait() p.wait()
elapsed_time = time.perf_counter() - start_time elapsed_time = time.perf_counter() - start_time
print("%.3f seconds, code %2d (%s)" % (elapsed_time, p.returncode, input_name)) print("%.3f seconds, code %2d (%s)" %
except OSError: (elapsed_time, p.returncode, input_name))
print("exe is invalid :(")
def main(argv): def main(argv):
@ -60,6 +58,24 @@ def main(argv):
print("No input files found!") print("No input files found!")
return 1 return 1
# Test the executable first.
valid = False
try:
p = subprocess.Popen([
exepath,
'--log_file=stdout',
], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()
if p.returncode == 5:
# code 5 = invalid trace file / trace file unspecified
valid = True
except OSError:
pass
if not valid:
print("Trace executable invalid!")
return 1
print("Processing...") print("Processing...")
pool = Pool(args.j) pool = Pool(args.j)