Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: tools/foozzie/v8_commands.py

Issue 2578503003: [foozzie] Initial correctness fuzzer harness. (Closed)
Patch Set: updates Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/foozzie/v8_foozzie.py » ('j') | tools/foozzie/v8_foozzie.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/foozzie/v8_commands.py
diff --git a/tools/foozzie/v8_commands.py b/tools/foozzie/v8_commands.py
new file mode 100644
index 0000000000000000000000000000000000000000..643117f572b8d5cdc19195f69bac3353387fe161
--- /dev/null
+++ b/tools/foozzie/v8_commands.py
@@ -0,0 +1,65 @@
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Fork from commands.py and output.py in v8 test driver.
+
+import signal
+import subprocess
+import sys
+from threading import Timer
+
+
+class Output(object):
+ def __init__(self, exit_code, timed_out, stdout, pid):
+ self.exit_code = exit_code
+ self.timed_out = timed_out
+ self.stdout = stdout
+ self.pid = pid
+
+ def HasCrashed(self):
+ # Timed out tests will have exit_code -signal.SIGTERM.
+ if self.timed_out:
+ return False
+ return (self.exit_code < 0 and
+ self.exit_code != -signal.SIGABRT)
+
+ def HasTimedOut(self):
+ return self.timed_out
+
+
+def Execute(args, cwd, timeout=None):
+ popen_args = [ c for c in args if c != "" ]
tandrii(chromium) 2016/12/16 16:46:26 nit-nit: space after [ and before ]
Michael Achenbach 2016/12/19 08:42:45 Done.
+ try:
+ process = subprocess.Popen(
+ args=popen_args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ cwd=cwd
+ )
+ except Exception as e:
+ sys.stderr.write("Error executing: %s\n" % popen_args)
+ raise e
+
+ def kill_process(process, timeout_result):
tandrii(chromium) 2016/12/16 16:46:26 why args if this func is already inside Execute cl
Michael Achenbach 2016/12/19 08:42:45 Done.
+ timeout_result[0] = True
tandrii(chromium) 2016/12/16 16:46:26 this code relies on this line being atomic, as wel
Michael Achenbach 2016/12/19 08:42:45 Done.
+ try:
+ process.kill()
+ except OSError:
+ sys.stderr.write('Error: Process %s already ended.\n' % process.pid)
+
+ # Pseudo object to communicate with timer thread.
+ timeout_result = [False]
+
+ timer = Timer(timeout, kill_process, [process, timeout_result])
+ timer.start()
+ stdout, _ = process.communicate()
+ timer.cancel()
+
+ return Output(
+ process.returncode,
+ timeout_result[0],
+ stdout.decode('utf-8', 'replace').encode('utf-8'),
+ process.pid,
+ )
+
« no previous file with comments | « no previous file | tools/foozzie/v8_foozzie.py » ('j') | tools/foozzie/v8_foozzie.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698