Roll gtest-parallel.
Brings in change that eliminates Queues which shows significant speed improvement for huge work lists. R=andrew@webrtc.org BUG= Review URL: https://webrtc-codereview.appspot.com/26409004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7132 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
2
third_party/gtest-parallel/README.webrtc
vendored
2
third_party/gtest-parallel/README.webrtc
vendored
@@ -1,5 +1,5 @@
|
|||||||
URL: https://github.com/google/gtest-parallel
|
URL: https://github.com/google/gtest-parallel
|
||||||
Version: 166648f68f6a26eaf4073fc244f0031ea139ce66
|
Version: ebf302fdc83f2c5afb9b7b45dc14dd0807b9e67d
|
||||||
License: Apache 2.0
|
License: Apache 2.0
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
|
|
||||||
|
|||||||
74
third_party/gtest-parallel/gtest-parallel
vendored
74
third_party/gtest-parallel/gtest-parallel
vendored
@@ -12,13 +12,13 @@
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import Queue
|
|
||||||
import optparse
|
import optparse
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
stdout_lock = threading.Lock()
|
||||||
class FilterFormat:
|
class FilterFormat:
|
||||||
total_tests = 0
|
total_tests = 0
|
||||||
finished_tests = 0
|
finished_tests = 0
|
||||||
@@ -39,7 +39,6 @@ class FilterFormat:
|
|||||||
(binary, test) = arg.split(' ', 1)
|
(binary, test) = arg.split(' ', 1)
|
||||||
self.tests[job_id] = (binary, test.strip())
|
self.tests[job_id] = (binary, test.strip())
|
||||||
self.outputs[job_id] = []
|
self.outputs[job_id] = []
|
||||||
self.total_tests += 1
|
|
||||||
elif command == "EXIT":
|
elif command == "EXIT":
|
||||||
(exit_code, time_ms) = [int(x) for x in arg.split(' ', 1)]
|
(exit_code, time_ms) = [int(x) for x in arg.split(' ', 1)]
|
||||||
self.finished_tests += 1
|
self.finished_tests += 1
|
||||||
@@ -49,35 +48,37 @@ class FilterFormat:
|
|||||||
self.failures.append(self.tests[job_id])
|
self.failures.append(self.tests[job_id])
|
||||||
for line in self.outputs[job_id]:
|
for line in self.outputs[job_id]:
|
||||||
print line
|
print line
|
||||||
|
elif command == "TESTCNT":
|
||||||
|
self.total_tests = int(arg.split(' ', 1)[1])
|
||||||
|
print "[0/%d] Running tests...\r" % self.total_tests,
|
||||||
|
|
||||||
def add_stdout(self, job_id, output):
|
def add_stdout(self, job_id, output):
|
||||||
self.outputs[job_id].append(output)
|
self.outputs[job_id].append(output)
|
||||||
|
|
||||||
def log(self):
|
def log(self, line):
|
||||||
print "[0/?] Running tests...\r",
|
stdout_lock.acquire()
|
||||||
while True:
|
(prefix, output) = line.split(' ', 1)
|
||||||
line = log.get()
|
|
||||||
if line == "":
|
|
||||||
break
|
|
||||||
(prefix, output) = line.split(' ', 1)
|
|
||||||
|
|
||||||
if prefix[-1] == ':':
|
if prefix[-1] == ':':
|
||||||
self.handle_meta(int(prefix[:-1]), output)
|
self.handle_meta(int(prefix[:-1]), output)
|
||||||
else:
|
else:
|
||||||
self.add_stdout(int(prefix[:-1]), output)
|
self.add_stdout(int(prefix[:-1]), output)
|
||||||
|
stdout_lock.release()
|
||||||
|
|
||||||
|
def end(self):
|
||||||
if self.failures:
|
if self.failures:
|
||||||
print "FAILED TESTS (%d/%d):" % (len(self.failures), self.total_tests)
|
print "FAILED TESTS (%d/%d):" % (len(self.failures), self.total_tests)
|
||||||
for (binary, test) in self.failures:
|
for (binary, test) in self.failures:
|
||||||
print " ", binary + ": " + test
|
print " ", binary + ": " + test
|
||||||
|
|
||||||
class RawFormat:
|
class RawFormat:
|
||||||
def log(self):
|
def log(self, line):
|
||||||
while True:
|
stdout_lock.acquire()
|
||||||
line = log.get()
|
sys.stdout.write(line + "\n")
|
||||||
if line == "":
|
sys.stdout.flush()
|
||||||
return
|
stdout_lock.release()
|
||||||
sys.stdout.write(line + "\n")
|
def end(self):
|
||||||
sys.stdout.flush()
|
pass
|
||||||
|
|
||||||
parser = optparse.OptionParser(
|
parser = optparse.OptionParser(
|
||||||
usage = 'usage: %prog [options] executable [executable ...]')
|
usage = 'usage: %prog [options] executable [executable ...]')
|
||||||
@@ -137,13 +138,9 @@ for test_binary in binaries:
|
|||||||
|
|
||||||
# Repeat tests (-r flag).
|
# Repeat tests (-r flag).
|
||||||
tests *= options.repeat
|
tests *= options.repeat
|
||||||
|
test_lock = threading.Lock()
|
||||||
log = Queue.Queue()
|
job_id = 0
|
||||||
test_queue = Queue.Queue()
|
logger.log(str(-1) + ': TESTCNT ' + ' ' + str(len(tests)))
|
||||||
|
|
||||||
for job_id, (test_binary, command, test) in enumerate(tests):
|
|
||||||
log.put(str(job_id) + ': TEST ' + test_binary + ' ' + test)
|
|
||||||
test_queue.put((command, job_id, test))
|
|
||||||
|
|
||||||
exit_code = 0
|
exit_code = 0
|
||||||
def run_job((command, job_id, test)):
|
def run_job((command, job_id, test)):
|
||||||
@@ -157,22 +154,29 @@ def run_job((command, job_id, test)):
|
|||||||
line = sub.stdout.readline()
|
line = sub.stdout.readline()
|
||||||
if line == '':
|
if line == '':
|
||||||
break
|
break
|
||||||
log.put(str(job_id) + '> ' + line.rstrip())
|
logger.log(str(job_id) + '> ' + line.rstrip())
|
||||||
|
|
||||||
code = sub.wait()
|
code = sub.wait()
|
||||||
runtime_ms = int(1000 * (time.time() - begin))
|
runtime_ms = int(1000 * (time.time() - begin))
|
||||||
log.put(str(job_id) + ': EXIT ' + str(code) + ' ' + str(runtime_ms))
|
logger.log(str(job_id) + ': EXIT ' + str(code) + ' ' + str(runtime_ms))
|
||||||
if code != 0:
|
if code != 0:
|
||||||
global exit_code
|
global exit_code
|
||||||
exit_code = code
|
exit_code = code
|
||||||
|
|
||||||
def worker():
|
def worker():
|
||||||
|
global job_id
|
||||||
while True:
|
while True:
|
||||||
try:
|
job = None
|
||||||
run_job(test_queue.get_nowait())
|
test_lock.acquire()
|
||||||
test_queue.task_done()
|
if job_id < len(tests):
|
||||||
except Queue.Empty:
|
(test_binary, command, test) = tests[job_id]
|
||||||
|
logger.log(str(job_id) + ': TEST ' + test_binary + ' ' + test)
|
||||||
|
job = (command, job_id, test)
|
||||||
|
job_id += 1
|
||||||
|
test_lock.release()
|
||||||
|
if job is None:
|
||||||
return
|
return
|
||||||
|
run_job(job)
|
||||||
|
|
||||||
def start_daemon(func):
|
def start_daemon(func):
|
||||||
t = threading.Thread(target=func)
|
t = threading.Thread(target=func)
|
||||||
@@ -181,9 +185,7 @@ def start_daemon(func):
|
|||||||
return t
|
return t
|
||||||
|
|
||||||
workers = [start_daemon(worker) for i in range(options.workers)]
|
workers = [start_daemon(worker) for i in range(options.workers)]
|
||||||
printer = start_daemon(logger.log)
|
|
||||||
|
|
||||||
[t.join() for t in workers]
|
[t.join() for t in workers]
|
||||||
log.put("")
|
logger.end()
|
||||||
printer.join()
|
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|||||||
Reference in New Issue
Block a user