[PATCH] Add per-test timeouts to lit

Eric Fiselier eric at efcs.ca
Thu May 28 09:06:55 PDT 2015


Leading question: If a shell command guarded by a Watchdog exits scope via an exception should `Watchdog.cancel()` be called? I think the `Watchdog` should provide a factory function that can be used in a `with` statement. The definition would looks something like this:

  @contextmanager
  def createWatchdog(timeout, popen=None):
      wg = Watchdog(timeout)
      if popen is not None:
        wg.watch(popen)
      yield wg
      wg.cancel()

I think the usage pattern for `Watchdog` should be:

  p = subprocess.Popen(cmd)
  with createWatchdog(timeout, p) as wg:
      out,err = p.communicate()
      exitCode = p.wait()
      

What do you think?


================
Comment at: utils/lit/lit/TestRunner.py:294
@@ -287,1 +293,3 @@
+        if wd is not None:
+            wd.cancel()
     except InternalShellError:
----------------
Should this call to cancel be exception safe?

================
Comment at: utils/lit/lit/util.py:35
@@ +34,3 @@
+
+    def _handler(self):
+        with self._lock:
----------------
I'm not sure if this matters, but I want to clarify what is considered a "timeout failure". For example, what if the timers invokes the handler but every open process has already finished? Should this be considered a timeout?


================
Comment at: utils/lit/lit/util.py:226
@@ -169,1 +225,3 @@
 
+    if timeout is not None:
+        wd.cancel()
----------------
Should this call to cancel be exception safe?

http://reviews.llvm.org/D6584

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list