summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrChat <arkolbed@gmail.com>2017-12-20 14:36:10 -0600
committerDrChat <arkolbed@gmail.com>2017-12-20 14:36:10 -0600
commita9318f72c950ee4248afa3b35bef984c3fd52da8 (patch)
tree449ab5e040742a39026ca6638783e427d226aab2
parent4881603df94b26bd08db3395c0deeb7e875a4f8d (diff)
Validate trace executable before starting thread pool
-rw-r--r--tools/xenosci/local_runner.py40
1 files changed, 28 insertions, 12 deletions
diff --git a/tools/xenosci/local_runner.py b/tools/xenosci/local_runner.py
index 508f7cdf0..9f146a21d 100644
--- a/tools/xenosci/local_runner.py
+++ b/tools/xenosci/local_runner.py
@@ -27,19 +27,17 @@ def file_type(value):
def run_dumper(exe_path, input_name):
- try:
- start_time = time.perf_counter()
+ start_time = time.perf_counter()
- p = subprocess.Popen([
- exe_path,
- input_name,
- '--log_file=stdout',
- ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p.wait()
- elapsed_time = time.perf_counter() - start_time
- print("%.3f seconds, code %2d (%s)" % (elapsed_time, p.returncode, input_name))
- except OSError:
- print("exe is invalid :(")
+ p = subprocess.Popen([
+ exe_path,
+ input_name,
+ '--log_file=stdout',
+ ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p.wait()
+ elapsed_time = time.perf_counter() - start_time
+ print("%.3f seconds, code %2d (%s)" %
+ (elapsed_time, p.returncode, input_name))
def main(argv):
@@ -60,6 +58,24 @@ def main(argv):
print("No input files found!")
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...")
pool = Pool(args.j)