Revision: 12648
Author:   [email protected]
Date:     Tue Oct  2 01:50:02 2012
Log:      Test runner: More fixes.

- handle Ctrl+C better
- actually show error messages sent by network peers
- gracefully handle missing test cases
- pull test.py and utils.py during server setup (temporary fix for testcfg import issue)

Review URL: https://codereview.chromium.org/11036005
http://code.google.com/p/v8/source/detail?r=12648

Modified:
 /branches/bleeding_edge/tools/test-server.py
 /branches/bleeding_edge/tools/testrunner/local/execution.py
 /branches/bleeding_edge/tools/testrunner/network/endpoint.py
 /branches/bleeding_edge/tools/testrunner/network/network_execution.py
 /branches/bleeding_edge/tools/testrunner/server/work_handler.py

=======================================
--- /branches/bleeding_edge/tools/test-server.py        Fri Sep 28 08:53:46 2012
+++ /branches/bleeding_edge/tools/test-server.py        Tue Oct  2 01:50:02 2012
@@ -124,6 +124,15 @@
   scriptname = os.path.abspath(sys.argv[0])
   _Cmd("svn cat %s > %s" % (path, scriptname))

+ # The testcfg.py files currently need to be able to import the old test.py
+  # script, so we temporarily need to make that available.
+  # TODO(jkummerow): Remove this when removing test.py.
+  for filename in ("test.py", "utils.py"):
+    url = ("http://v8.googlecode.com/svn/branches/bleeding_edge/";
+           "tools/%s" % filename)
+    filepath = os.path.join(os.path.dirname(scriptname), filename)
+    _Cmd("svn cat %s > %s" % (url, filepath))
+
   # Check out or update V8.
   v8_dir = os.path.join(ROOT, "v8")
   if os.path.exists(v8_dir):
=======================================
--- /branches/bleeding_edge/tools/testrunner/local/execution.py Mon Sep 24 02:38:46 2012 +++ /branches/bleeding_edge/tools/testrunner/local/execution.py Tue Oct 2 01:50:02 2012
@@ -35,6 +35,10 @@
 from . import utils


+BREAK_NOW = -1
+EXCEPTION = -2
+
+
 class Job(object):
   def __init__(self, command, dep_command, test_id, timeout, verbose):
     self.command = command
@@ -57,9 +61,11 @@
         return (job.id, dep_output, time.time() - start_time)
     output = commands.Execute(job.command, job.verbose, job.timeout)
     return (job.id, output, time.time() - start_time)
+  except KeyboardInterrupt:
+    return (-1, BREAK_NOW, 0)
   except Exception, e:
     print(">>> EXCEPTION: %s" % e)
-    return (-1, -1, 0)
+    return (-1, EXCEPTION, 0)


 class Runner(object):
@@ -90,10 +96,17 @@
     pool = multiprocessing.Pool(processes=jobs)
     test_map = {}
     queue = []
+    queued_exception = None
     for test in self.tests:
       assert test.id >= 0
       test_map[test.id] = test
-      command = self.GetCommand(test)
+      try:
+        command = self.GetCommand(test)
+      except Exception, e:
+        # If this failed, save the exception and re-raise it later (after
+        # all other tests have had a chance to run).
+        queued_exception = e
+        continue
       timeout = self.context.timeout
       if ("--stress-opt" in test.flags or
           "--stress-opt" in self.context.mode_flags or
@@ -111,6 +124,13 @@
       for result in it:
         test_id = result[0]
         if test_id < 0:
+          if result[1] == BREAK_NOW:
+            self.terminate = True
+          else:
+            continue
+        if self.terminate:
+          pool.terminate()
+          pool.join()
           raise BreakNowException("User pressed Ctrl+C or IO went wrong")
         test = test_map[test_id]
         self.indicator.AboutToRun(test)
@@ -124,10 +144,16 @@
           self.succeeded += 1
         self.remaining -= 1
         self.indicator.HasRun(test)
-    except:
+    except KeyboardInterrupt:
       pool.terminate()
       pool.join()
+    except Exception, e:
+      print("Exception: %s" % e)
+      pool.terminate()
+      pool.join()
       raise
+    if queued_exception:
+      raise queued_exception
     return


=======================================
--- /branches/bleeding_edge/tools/testrunner/network/endpoint.py Mon Oct 1 10:16:00 2012 +++ /branches/bleeding_edge/tools/testrunner/network/endpoint.py Tue Oct 2 01:50:02 2012
@@ -60,7 +60,6 @@
     self.sender_lock.acquire()
     while keep_running:
       time.sleep(0.1)
-      t1 = time.time()
       # This should be "atomic enough" without locking :-)
       # (We don't care which list any new elements get appended to, as long
       # as we don't lose any and the last one comes last.)
@@ -77,7 +76,10 @@
       result = []
       for t in tests:
         result.append(t.PackResult())
-      compression.Send(result, self.sock)
+      try:
+        compression.Send(result, self.sock)
+      except:
+        self.runner.terminate = True
       for t in tests:
         self.server.CompareOwnPerf(t, self.context.arch, self.context.mode)
       tests = []
@@ -116,7 +118,7 @@
                  e.filename)
     else:
       message = "%s" % e
-    compression.Send([-1, message], sock)
+    compression.Send([[-1, message]], sock)
   progress_indicator.HasRun(None)  # Sentinel to signal the end.
progress_indicator.sender_lock.acquire() # Released when sending is done.
   progress_indicator.sender_lock.release()
=======================================
--- /branches/bleeding_edge/tools/testrunner/network/network_execution.py Mon Oct 1 02:05:27 2012 +++ /branches/bleeding_edge/tools/testrunner/network/network_execution.py Tue Oct 2 01:50:02 2012
@@ -187,8 +187,8 @@
             test_id = data[0]
             if test_id < 0:
               # The peer is reporting an error.
-              print("Peer %s reports error: %s" % (peer.address, data[1]))
-              rec.Advance()
+              with self.lock:
+ print("\nPeer %s reports error: %s" % (peer.address, data[1]))
               continue
             test = test_map.pop(test_id)
             test.MergeResult(data)
@@ -214,7 +214,11 @@
               self.indicator.HasRun(test)
           rec.Advance()
         peer.runtime = time.time() - start_time
-      except Exception:
+      except KeyboardInterrupt:
+        sock.close()
+        raise
+      except Exception, e:
+        print("Got exception: %s" % e)
         pass  # Fall back to local execution.
     else:
       compression.Send([constants.UNRESPONSIVE_PEER, peer.address],
@@ -222,7 +226,7 @@
     sock.close()
     if len(test_map) > 0:
       # Some tests have not received any results. Run them locally.
- print("No results for %d tests, running them locally." % len(test_map)) + print("\nNo results for %d tests, running them locally." % len(test_map))
       self._EnqueueLocally(test_map)

   def _EnqueueLocally(self, test_map):
=======================================
--- /branches/bleeding_edge/tools/testrunner/server/work_handler.py Mon Oct 1 10:16:00 2012 +++ /branches/bleeding_edge/tools/testrunner/server/work_handler.py Tue Oct 2 01:50:02 2012
@@ -76,7 +76,7 @@
   def _SendResponse(self, error_message=None):
     try:
       if error_message:
-        compression.Send([-1, error_message], self.request)
+        compression.Send([[-1, error_message]], self.request)
       compression.Send(constants.END_OF_STREAM, self.request)
       return
     except Exception, e:

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to