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

Side by Side Diff: tools/testrunner/network/endpoint.py

Issue 10919265: First commit of new tools/run-tests.py (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: s/server.py/test-server.py/ in README Created 8 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/testrunner/network/distro.py ('k') | tools/testrunner/network/network_execution.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided
11 # with the distribution.
12 # * Neither the name of Google Inc. nor the names of its
13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29 import multiprocessing
30 import os
31 import Queue
32 import threading
33 import time
34
35 from ..local import execution
36 from ..local import progress
37 from ..local import testsuite
38 from ..local import utils
39 from ..server import compression
40
41
42 class EndpointProgress(progress.ProgressIndicator):
43 def __init__(self, sock, server, ctx):
44 super(EndpointProgress, self).__init__()
45 self.sock = sock
46 self.server = server
47 self.context = ctx
48 self.results_queue = [] # Accessors must synchronize themselves.
49 self.sender_lock = threading.Lock()
50 self.senderthread = threading.Thread(target=self._SenderThread)
51 self.senderthread.start()
52
53 def HasRun(self, test):
54 # The runners that call this have a lock anyway, so this is safe.
55 self.results_queue.append(test)
56
57 def _SenderThread(self):
58 keep_running = True
59 tests = []
60 self.sender_lock.acquire()
61 while keep_running:
62 time.sleep(0.1)
63 t1 = time.time()
64 # This should be "atomic enough" without locking :-)
65 # (We don't care which list any new elements get appended to, as long
66 # as we don't lose any and the last one comes last.)
67 current = self.results_queue
68 self.results_queue = []
69 for c in current:
70 if c is None:
71 keep_running = False
72 else:
73 tests.append(c)
74 if keep_running and len(tests) < 1:
75 continue # Wait for more results.
76 if len(tests) < 1: break # We're done here.
77 result = []
78 for t in tests:
79 result.append(t.PackResult())
80 compression.Send(result, self.sock)
81 for t in tests:
82 self.server.CompareOwnPerf(t, self.context.arch, self.context.mode)
83 tests = []
84 self.sender_lock.release()
85
86
87 def Execute(workspace, ctx, tests, sock, server):
88 suite_paths = utils.GetSuitePaths(os.path.join(workspace, "test"))
89 suites = []
90 for root in suite_paths:
91 suite = testsuite.TestSuite.LoadTestSuite(
92 os.path.join(workspace, "test", root))
93 if suite:
94 suites.append(suite)
95
96 suites_dict = {}
97 for s in suites:
98 suites_dict[s.name] = s
99 s.tests = []
100 for t in tests:
101 suite = suites_dict[t.suite]
102 t.suite = suite
103 suite.tests.append(t)
104
105 suites = [ s for s in suites if len(s.tests) > 0 ]
106 for s in suites:
107 s.DownloadData()
108
109 progress_indicator = EndpointProgress(sock, server, ctx)
110 runner = execution.Runner(suites, progress_indicator, ctx)
111 runner.Run(server.jobs)
112 progress_indicator.HasRun(None) # Sentinel to signal the end.
113 progress_indicator.sender_lock.acquire() # Released when sending is done.
114 progress_indicator.sender_lock.release()
OLDNEW
« no previous file with comments | « tools/testrunner/network/distro.py ('k') | tools/testrunner/network/network_execution.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698