Nathaniel Manista | ae4fbcd | 2015-09-23 16:29:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python2.7 |
Craig Tiller | 4083977 | 2016-01-05 12:34:49 -0800 | [diff] [blame] | 2 | # Copyright 2015-2016, Google Inc. |
Craig Tiller | c2c7921 | 2015-02-16 12:00:01 -0800 | [diff] [blame] | 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 31 | """Run tests in parallel.""" |
| 32 | |
| 33 | import argparse |
| 34 | import glob |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 35 | import hashlib |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 36 | import itertools |
Craig Tiller | 261dd98 | 2015-01-16 16:41:45 -0800 | [diff] [blame] | 37 | import json |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 38 | import multiprocessing |
Craig Tiller | 1cc11db | 2015-01-15 22:50:50 -0800 | [diff] [blame] | 39 | import os |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 40 | import platform |
| 41 | import random |
Craig Tiller | fe406ec | 2015-02-24 13:55:12 -0800 | [diff] [blame] | 42 | import re |
Craig Tiller | 8287523 | 2015-09-25 13:57:34 -0700 | [diff] [blame] | 43 | import socket |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 44 | import subprocess |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 45 | import sys |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 46 | import tempfile |
| 47 | import traceback |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 48 | import time |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 49 | import urllib2 |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 50 | import uuid |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 51 | |
| 52 | import jobset |
Adele Zhou | a30f829 | 2015-11-02 13:15:46 -0800 | [diff] [blame] | 53 | import report_utils |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 54 | import watch_dirs |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 55 | |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 56 | |
Craig Tiller | 2cc2b84 | 2015-02-27 11:38:31 -0800 | [diff] [blame] | 57 | ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..')) |
| 58 | os.chdir(ROOT) |
| 59 | |
| 60 | |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 61 | _FORCE_ENVIRON_FOR_WRAPPERS = {} |
| 62 | |
| 63 | |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 64 | def platform_string(): |
Nicolas "Pixel" Noble | f72d7b5 | 2015-12-03 03:07:43 +0100 | [diff] [blame] | 65 | return jobset.platform_string() |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 66 | |
| 67 | |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 68 | # SimpleConfig: just compile with CONFIG=config, and run the binary to test |
| 69 | class SimpleConfig(object): |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 70 | |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 71 | def __init__(self, config, environ=None, timeout_multiplier=1): |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 72 | if environ is None: |
| 73 | environ = {} |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 74 | self.build_config = config |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 75 | self.allow_hashing = (config != 'gcov') |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 76 | self.environ = environ |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 77 | self.environ['CONFIG'] = config |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 78 | self.timeout_multiplier = timeout_multiplier |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 79 | |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 80 | def job_spec(self, cmdline, hash_targets, timeout_seconds=5*60, |
| 81 | shortname=None, environ={}): |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 82 | """Construct a jobset.JobSpec for a test under this config |
| 83 | |
| 84 | Args: |
| 85 | cmdline: a list of strings specifying the command line the test |
| 86 | would like to run |
| 87 | hash_targets: either None (don't do caching of test results), or |
| 88 | a list of strings specifying files to include in a |
| 89 | binary hash to check if a test has changed |
| 90 | -- if used, all artifacts needed to run the test must |
| 91 | be listed |
| 92 | """ |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 93 | actual_environ = self.environ.copy() |
| 94 | for k, v in environ.iteritems(): |
| 95 | actual_environ[k] = v |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 96 | return jobset.JobSpec(cmdline=cmdline, |
Jan Tattermusch | 9a7d30c | 2015-04-23 16:12:55 -0700 | [diff] [blame] | 97 | shortname=shortname, |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 98 | environ=actual_environ, |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 99 | timeout_seconds=self.timeout_multiplier * timeout_seconds, |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 100 | hash_targets=hash_targets |
Craig Tiller | d4509a1 | 2015-09-28 09:18:40 -0700 | [diff] [blame] | 101 | if self.allow_hashing else None, |
Craig Tiller | 35505de | 2015-10-08 13:31:33 -0700 | [diff] [blame] | 102 | flake_retries=5 if args.allow_flakes else 0, |
| 103 | timeout_retries=3 if args.allow_flakes else 0) |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 104 | |
| 105 | |
| 106 | # ValgrindConfig: compile with some CONFIG=config, but use valgrind to run |
| 107 | class ValgrindConfig(object): |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 108 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 109 | def __init__(self, config, tool, args=None): |
| 110 | if args is None: |
| 111 | args = [] |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 112 | self.build_config = config |
Craig Tiller | 2aa4d64 | 2015-01-14 15:59:44 -0800 | [diff] [blame] | 113 | self.tool = tool |
Craig Tiller | 1a305b1 | 2015-02-18 13:37:06 -0800 | [diff] [blame] | 114 | self.args = args |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 115 | self.allow_hashing = False |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 116 | |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 117 | def job_spec(self, cmdline, hash_targets): |
Craig Tiller | 1a305b1 | 2015-02-18 13:37:06 -0800 | [diff] [blame] | 118 | return jobset.JobSpec(cmdline=['valgrind', '--tool=%s' % self.tool] + |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 119 | self.args + cmdline, |
Craig Tiller | 71ec6cb | 2015-06-03 00:51:11 -0700 | [diff] [blame] | 120 | shortname='valgrind %s' % cmdline[0], |
Craig Tiller | d4509a1 | 2015-09-28 09:18:40 -0700 | [diff] [blame] | 121 | hash_targets=None, |
Craig Tiller | 95cc07b | 2015-09-28 13:41:30 -0700 | [diff] [blame] | 122 | flake_retries=5 if args.allow_flakes else 0, |
Craig Tiller | 35505de | 2015-10-08 13:31:33 -0700 | [diff] [blame] | 123 | timeout_retries=3 if args.allow_flakes else 0) |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 124 | |
| 125 | |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 126 | def get_c_tests(travis, test_lang) : |
| 127 | out = [] |
| 128 | platforms_str = 'ci_platforms' if travis else 'platforms' |
| 129 | with open('tools/run_tests/tests.json') as f: |
murgatroid99 | 89899b1 | 2015-09-22 09:14:48 -0700 | [diff] [blame] | 130 | js = json.load(f) |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 131 | return [tgt |
| 132 | for tgt in js |
| 133 | if tgt['language'] == test_lang and |
| 134 | platform_string() in tgt[platforms_str] and |
| 135 | not (travis and tgt['flaky'])] |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 136 | |
murgatroid99 | fafeeb3 | 2015-09-22 09:13:03 -0700 | [diff] [blame] | 137 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 138 | class CLanguage(object): |
| 139 | |
Craig Tiller | e9c959d | 2015-01-18 10:23:26 -0800 | [diff] [blame] | 140 | def __init__(self, make_target, test_lang): |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 141 | self.make_target = make_target |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 142 | self.platform = platform_string() |
Craig Tiller | 711bbe6 | 2015-08-19 12:35:16 -0700 | [diff] [blame] | 143 | self.test_lang = test_lang |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 144 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 145 | def test_specs(self, config, args): |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 146 | out = [] |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 147 | binaries = get_c_tests(args.travis, self.test_lang) |
Craig Tiller | 711bbe6 | 2015-08-19 12:35:16 -0700 | [diff] [blame] | 148 | for target in binaries: |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 149 | if config.build_config in target['exclude_configs']: |
murgatroid99 | fafeeb3 | 2015-09-22 09:13:03 -0700 | [diff] [blame] | 150 | continue |
Nicolas Noble | e144536 | 2015-05-11 17:40:26 -0700 | [diff] [blame] | 151 | if self.platform == 'windows': |
Craig Tiller | f418260 | 2015-09-01 12:23:16 -0700 | [diff] [blame] | 152 | binary = 'vsprojects/%s/%s.exe' % ( |
| 153 | _WINDOWS_CONFIG[config.build_config], target['name']) |
Nicolas Noble | e144536 | 2015-05-11 17:40:26 -0700 | [diff] [blame] | 154 | else: |
| 155 | binary = 'bins/%s/%s' % (config.build_config, target['name']) |
yang-g | 6c1fdc6 | 2015-08-18 11:57:42 -0700 | [diff] [blame] | 156 | if os.path.isfile(binary): |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 157 | cmdline = [binary] + target['args'] |
| 158 | out.append(config.job_spec(cmdline, [binary], |
| 159 | shortname=' '.join(cmdline), |
Craig Tiller | cc0535d | 2015-12-08 15:14:47 -0800 | [diff] [blame] | 160 | environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH': |
| 161 | os.path.abspath(os.path.dirname( |
Craig Tiller | ed2164d | 2015-12-08 22:03:36 -0800 | [diff] [blame] | 162 | sys.argv[0]) + '/../../src/core/tsi/test_creds/ca.pem')})) |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 163 | elif args.regex == '.*' or platform_string() == 'windows': |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 164 | print '\nWARNING: binary not found, skipping', binary |
Nicolas Noble | e144536 | 2015-05-11 17:40:26 -0700 | [diff] [blame] | 165 | return sorted(out) |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 166 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 167 | def make_targets(self, test_regex): |
| 168 | if platform_string() != 'windows' and test_regex != '.*': |
| 169 | # use the regex to minimize the number of things to build |
| 170 | return [target['name'] |
| 171 | for target in get_c_tests(False, self.test_lang) |
| 172 | if re.search(test_regex, target['name'])] |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 173 | if platform_string() == 'windows': |
| 174 | # don't build tools on windows just yet |
| 175 | return ['buildtests_%s' % self.make_target] |
Craig Tiller | 7552f0f | 2015-06-19 17:46:20 -0700 | [diff] [blame] | 176 | return ['buildtests_%s' % self.make_target, 'tools_%s' % self.make_target] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 177 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 178 | def pre_build_steps(self): |
Jan Tattermusch | 874aec0 | 2015-10-07 19:26:19 -0700 | [diff] [blame] | 179 | if self.platform == 'windows': |
| 180 | return [['tools\\run_tests\\pre_build_c.bat']] |
| 181 | else: |
| 182 | return [] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 183 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 184 | def build_steps(self): |
| 185 | return [] |
| 186 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 187 | def post_tests_steps(self): |
| 188 | if self.platform == 'windows': |
| 189 | return [] |
| 190 | else: |
| 191 | return [['tools/run_tests/post_tests_c.sh']] |
| 192 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 193 | def makefile_name(self): |
| 194 | return 'Makefile' |
| 195 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 196 | def supports_multi_config(self): |
| 197 | return True |
| 198 | |
| 199 | def __str__(self): |
| 200 | return self.make_target |
| 201 | |
Craig Tiller | cc0535d | 2015-12-08 15:14:47 -0800 | [diff] [blame] | 202 | |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 203 | class NodeLanguage(object): |
| 204 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 205 | def test_specs(self, config, args): |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 206 | return [config.job_spec(['tools/run_tests/run_node.sh'], None, |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 207 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 208 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 209 | def pre_build_steps(self): |
murgatroid99 | ae369de | 2015-10-09 15:40:48 -0700 | [diff] [blame] | 210 | # Default to 1 week cache expiration |
murgatroid99 | 9375895 | 2015-10-14 11:51:05 -0700 | [diff] [blame] | 211 | return [['tools/run_tests/pre_build_node.sh']] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 212 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 213 | def make_targets(self, test_regex): |
murgatroid99 | db5b160 | 2015-10-01 13:20:11 -0700 | [diff] [blame] | 214 | return [] |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 215 | |
| 216 | def build_steps(self): |
| 217 | return [['tools/run_tests/build_node.sh']] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 218 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 219 | def post_tests_steps(self): |
| 220 | return [] |
| 221 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 222 | def makefile_name(self): |
| 223 | return 'Makefile' |
| 224 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 225 | def supports_multi_config(self): |
| 226 | return False |
| 227 | |
| 228 | def __str__(self): |
| 229 | return 'node' |
| 230 | |
Craig Tiller | 9977582 | 2015-01-30 13:07:16 -0800 | [diff] [blame] | 231 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 232 | class PhpLanguage(object): |
| 233 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 234 | def test_specs(self, config, args): |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 235 | return [config.job_spec(['src/php/bin/run_tests.sh'], None, |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 236 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 237 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 238 | def pre_build_steps(self): |
| 239 | return [] |
| 240 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 241 | def make_targets(self, test_regex): |
Craig Tiller | af7cf54 | 2015-05-22 10:07:34 -0700 | [diff] [blame] | 242 | return ['static_c', 'shared_c'] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 243 | |
| 244 | def build_steps(self): |
| 245 | return [['tools/run_tests/build_php.sh']] |
| 246 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 247 | def post_tests_steps(self): |
| 248 | return [] |
| 249 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 250 | def makefile_name(self): |
| 251 | return 'Makefile' |
| 252 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 253 | def supports_multi_config(self): |
| 254 | return False |
| 255 | |
| 256 | def __str__(self): |
| 257 | return 'php' |
| 258 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 259 | |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 260 | class PythonLanguage(object): |
| 261 | |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 262 | def __init__(self): |
Masood Malekghassemi | 2b84162 | 2015-07-28 17:39:02 -0700 | [diff] [blame] | 263 | self._build_python_versions = ['2.7'] |
Masood Malekghassemi | e5f7002 | 2015-06-29 09:20:26 -0700 | [diff] [blame] | 264 | self._has_python_versions = [] |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 265 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 266 | def test_specs(self, config, args): |
Masood Malekghassemi | 2b84162 | 2015-07-28 17:39:02 -0700 | [diff] [blame] | 267 | environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS) |
| 268 | environment['PYVER'] = '2.7' |
| 269 | return [config.job_spec( |
| 270 | ['tools/run_tests/run_python.sh'], |
| 271 | None, |
| 272 | environ=environment, |
| 273 | shortname='py.test', |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 274 | timeout_seconds=15*60 |
Masood Malekghassemi | 2b84162 | 2015-07-28 17:39:02 -0700 | [diff] [blame] | 275 | )] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 276 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 277 | def pre_build_steps(self): |
| 278 | return [] |
| 279 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 280 | def make_targets(self, test_regex): |
Craig Tiller | af7cf54 | 2015-05-22 10:07:34 -0700 | [diff] [blame] | 281 | return ['static_c', 'grpc_python_plugin', 'shared_c'] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 282 | |
| 283 | def build_steps(self): |
Masood Malekghassemi | e5f7002 | 2015-06-29 09:20:26 -0700 | [diff] [blame] | 284 | commands = [] |
| 285 | for python_version in self._build_python_versions: |
| 286 | try: |
| 287 | with open(os.devnull, 'w') as output: |
| 288 | subprocess.check_call(['which', 'python' + python_version], |
| 289 | stdout=output, stderr=output) |
| 290 | commands.append(['tools/run_tests/build_python.sh', python_version]) |
| 291 | self._has_python_versions.append(python_version) |
| 292 | except: |
| 293 | jobset.message('WARNING', 'Missing Python ' + python_version, |
| 294 | do_newline=True) |
| 295 | return commands |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 296 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 297 | def post_tests_steps(self): |
| 298 | return [] |
| 299 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 300 | def makefile_name(self): |
| 301 | return 'Makefile' |
| 302 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 303 | def supports_multi_config(self): |
| 304 | return False |
| 305 | |
| 306 | def __str__(self): |
| 307 | return 'python' |
| 308 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 309 | |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 310 | class RubyLanguage(object): |
| 311 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 312 | def test_specs(self, config, args): |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 313 | return [config.job_spec(['tools/run_tests/run_ruby.sh'], None, |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 314 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 315 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 316 | def pre_build_steps(self): |
Nicolas "Pixel" Noble | bcf988f | 2015-10-08 03:00:42 +0200 | [diff] [blame] | 317 | return [['tools/run_tests/pre_build_ruby.sh']] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 318 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 319 | def make_targets(self, test_regex): |
murgatroid99 | a43c14f | 2015-07-30 13:31:23 -0700 | [diff] [blame] | 320 | return ['static_c'] |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 321 | |
| 322 | def build_steps(self): |
| 323 | return [['tools/run_tests/build_ruby.sh']] |
| 324 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 325 | def post_tests_steps(self): |
Nicolas "Pixel" Noble | 7ef1e53 | 2015-12-02 00:55:33 +0100 | [diff] [blame] | 326 | return [['tools/run_tests/post_tests_ruby.sh']] |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 327 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 328 | def makefile_name(self): |
| 329 | return 'Makefile' |
| 330 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 331 | def supports_multi_config(self): |
| 332 | return False |
| 333 | |
| 334 | def __str__(self): |
| 335 | return 'ruby' |
| 336 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 337 | |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 338 | class CSharpLanguage(object): |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 339 | def __init__(self): |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 340 | self.platform = platform_string() |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 341 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 342 | def test_specs(self, config, args): |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 343 | with open('src/csharp/tests.json') as f: |
| 344 | tests_json = json.load(f) |
| 345 | assemblies = tests_json['assemblies'] |
| 346 | tests = tests_json['tests'] |
| 347 | |
| 348 | msbuild_config = _WINDOWS_CONFIG[config.build_config] |
| 349 | assembly_files = ['%s/bin/%s/%s.dll' % (a, msbuild_config, a) |
| 350 | for a in assemblies] |
| 351 | |
| 352 | extra_args = ['-labels'] + assembly_files |
| 353 | |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 354 | if self.platform == 'windows': |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 355 | script_name = 'tools\\run_tests\\run_csharp.bat' |
| 356 | extra_args += ['-domain=None'] |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 357 | else: |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 358 | script_name = 'tools/run_tests/run_csharp.sh' |
Jan Tattermusch | bf3b153 | 2015-10-26 10:24:42 -0700 | [diff] [blame] | 359 | |
Jan Tattermusch | bdf4b2e | 2015-10-28 08:22:34 -0700 | [diff] [blame] | 360 | if config.build_config == 'gcov': |
| 361 | # On Windows, we only collect C# code coverage. |
| 362 | # On Linux, we only collect coverage for native extension. |
| 363 | # For code coverage all tests need to run as one suite. |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 364 | return [config.job_spec([script_name] + extra_args, None, |
| 365 | shortname='csharp.coverage', |
| 366 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
Jan Tattermusch | 61c3a83 | 2015-10-27 17:54:50 -0700 | [diff] [blame] | 367 | else: |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 368 | specs = [] |
| 369 | for test in tests: |
| 370 | cmdline = [script_name, '-run=%s' % test] + extra_args |
| 371 | if self.platform == 'windows': |
| 372 | # use different output directory for each test to prevent |
| 373 | # TestResult.xml clash between parallel test runs. |
| 374 | cmdline += ['-work=test-result/%s' % uuid.uuid4()] |
| 375 | specs.append(config.job_spec(cmdline, None, |
| 376 | shortname='csharp.%s' % test, |
| 377 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)) |
| 378 | return specs |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 379 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 380 | def pre_build_steps(self): |
Jan Tattermusch | 48423fc | 2015-10-07 18:59:16 -0700 | [diff] [blame] | 381 | if self.platform == 'windows': |
Jan Tattermusch | 874aec0 | 2015-10-07 19:26:19 -0700 | [diff] [blame] | 382 | return [['tools\\run_tests\\pre_build_csharp.bat']] |
Jan Tattermusch | 48423fc | 2015-10-07 18:59:16 -0700 | [diff] [blame] | 383 | else: |
| 384 | return [['tools/run_tests/pre_build_csharp.sh']] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 385 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 386 | def make_targets(self, test_regex): |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 387 | # For Windows, this target doesn't really build anything, |
| 388 | # everything is build by buildall script later. |
Craig Tiller | d590482 | 2015-08-31 21:30:58 -0700 | [diff] [blame] | 389 | if self.platform == 'windows': |
| 390 | return [] |
| 391 | else: |
| 392 | return ['grpc_csharp_ext'] |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 393 | |
| 394 | def build_steps(self): |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 395 | if self.platform == 'windows': |
| 396 | return [['src\\csharp\\buildall.bat']] |
| 397 | else: |
| 398 | return [['tools/run_tests/build_csharp.sh']] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 399 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 400 | def post_tests_steps(self): |
| 401 | return [] |
| 402 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 403 | def makefile_name(self): |
| 404 | return 'Makefile' |
| 405 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 406 | def supports_multi_config(self): |
| 407 | return False |
| 408 | |
| 409 | def __str__(self): |
| 410 | return 'csharp' |
| 411 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 412 | |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 413 | class ObjCLanguage(object): |
| 414 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 415 | def test_specs(self, config, args): |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 416 | return [config.job_spec(['src/objective-c/tests/run_tests.sh'], None, |
| 417 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
| 418 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 419 | def pre_build_steps(self): |
| 420 | return [] |
| 421 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 422 | def make_targets(self, test_regex): |
Jorge Canizales | d0b32e9 | 2015-07-30 23:08:43 -0700 | [diff] [blame] | 423 | return ['grpc_objective_c_plugin', 'interop_server'] |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 424 | |
| 425 | def build_steps(self): |
Jorge Canizales | d0b32e9 | 2015-07-30 23:08:43 -0700 | [diff] [blame] | 426 | return [['src/objective-c/tests/build_tests.sh']] |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 427 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 428 | def post_tests_steps(self): |
| 429 | return [] |
| 430 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 431 | def makefile_name(self): |
| 432 | return 'Makefile' |
| 433 | |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 434 | def supports_multi_config(self): |
| 435 | return False |
| 436 | |
| 437 | def __str__(self): |
| 438 | return 'objc' |
| 439 | |
| 440 | |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 441 | class Sanity(object): |
| 442 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 443 | def test_specs(self, config, args): |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 444 | return [config.job_spec(['tools/run_tests/run_sanity.sh'], None, timeout_seconds=15*60), |
Jan Tattermusch | e3d6625 | 2015-10-26 11:33:45 -0700 | [diff] [blame] | 445 | config.job_spec(['tools/run_tests/check_sources_and_headers.py'], None)] |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 446 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 447 | def pre_build_steps(self): |
| 448 | return [] |
| 449 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 450 | def make_targets(self, test_regex): |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 451 | return ['run_dep_checks'] |
| 452 | |
| 453 | def build_steps(self): |
| 454 | return [] |
| 455 | |
Nicolas "Pixel" Noble | 87879b3 | 2015-10-12 23:28:53 +0200 | [diff] [blame] | 456 | def post_tests_steps(self): |
| 457 | return [] |
| 458 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 459 | def makefile_name(self): |
| 460 | return 'Makefile' |
| 461 | |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 462 | def supports_multi_config(self): |
| 463 | return False |
| 464 | |
| 465 | def __str__(self): |
| 466 | return 'sanity' |
| 467 | |
Nicolas "Pixel" Noble | e55cd7f | 2015-04-14 17:59:13 +0200 | [diff] [blame] | 468 | |
Nicolas "Pixel" Noble | fd2b093 | 2015-03-26 00:26:29 +0100 | [diff] [blame] | 469 | class Build(object): |
| 470 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 471 | def test_specs(self, config, args): |
Nicolas "Pixel" Noble | fd2b093 | 2015-03-26 00:26:29 +0100 | [diff] [blame] | 472 | return [] |
| 473 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 474 | def pre_build_steps(self): |
| 475 | return [] |
| 476 | |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 477 | def make_targets(self, test_regex): |
Nicolas "Pixel" Noble | c23827b | 2015-04-23 06:17:55 +0200 | [diff] [blame] | 478 | return ['static'] |
Nicolas "Pixel" Noble | fd2b093 | 2015-03-26 00:26:29 +0100 | [diff] [blame] | 479 | |
| 480 | def build_steps(self): |
| 481 | return [] |
| 482 | |
Nicolas "Pixel" Noble | fe30045 | 2015-10-27 23:05:10 +0100 | [diff] [blame] | 483 | def post_tests_steps(self): |
| 484 | return [] |
| 485 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 486 | def makefile_name(self): |
| 487 | return 'Makefile' |
| 488 | |
Nicolas "Pixel" Noble | fd2b093 | 2015-03-26 00:26:29 +0100 | [diff] [blame] | 489 | def supports_multi_config(self): |
| 490 | return True |
| 491 | |
| 492 | def __str__(self): |
| 493 | return self.make_target |
| 494 | |
| 495 | |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 496 | # different configurations we can run under |
| 497 | _CONFIGS = { |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 498 | 'dbg': SimpleConfig('dbg'), |
| 499 | 'opt': SimpleConfig('opt'), |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 500 | 'tsan': SimpleConfig('tsan', timeout_multiplier=2, environ={ |
Craig Tiller | 1ada6ad | 2015-07-16 16:19:14 -0700 | [diff] [blame] | 501 | 'TSAN_OPTIONS': 'suppressions=tools/tsan_suppressions.txt:halt_on_error=1:second_deadlock_stack=1'}), |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 502 | 'msan': SimpleConfig('msan', timeout_multiplier=1.5), |
Craig Tiller | 96bd5f6 | 2015-02-13 09:04:13 -0800 | [diff] [blame] | 503 | 'ubsan': SimpleConfig('ubsan'), |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 504 | 'asan': SimpleConfig('asan', timeout_multiplier=1.5, environ={ |
Craig Tiller | 0fe5ee7 | 2015-12-22 12:50:36 -0800 | [diff] [blame] | 505 | 'ASAN_OPTIONS': 'suppressions=tools/asan_suppressions.txt:detect_leaks=1:color=always', |
| 506 | 'LSAN_OPTIONS': 'suppressions=tools/asan_suppressions.txt:report_objects=1'}), |
Craig Tiller | 810725c | 2015-05-12 09:44:41 -0700 | [diff] [blame] | 507 | 'asan-noleaks': SimpleConfig('asan', environ={ |
Craig Tiller | 2a2a6ed | 2015-11-18 15:52:46 -0800 | [diff] [blame] | 508 | 'ASAN_OPTIONS': 'detect_leaks=0:color=always'}), |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 509 | 'gcov': SimpleConfig('gcov'), |
Craig Tiller | 1a305b1 | 2015-02-18 13:37:06 -0800 | [diff] [blame] | 510 | 'memcheck': ValgrindConfig('valgrind', 'memcheck', ['--leak-check=full']), |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 511 | 'helgrind': ValgrindConfig('dbg', 'helgrind') |
| 512 | } |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 513 | |
| 514 | |
Nicolas "Pixel" Noble | 1fb5e82 | 2015-03-16 06:20:37 +0100 | [diff] [blame] | 515 | _DEFAULT = ['opt'] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 516 | _LANGUAGES = { |
Craig Tiller | e9c959d | 2015-01-18 10:23:26 -0800 | [diff] [blame] | 517 | 'c++': CLanguage('cxx', 'c++'), |
| 518 | 'c': CLanguage('c', 'c'), |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 519 | 'node': NodeLanguage(), |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 520 | 'php': PhpLanguage(), |
| 521 | 'python': PythonLanguage(), |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 522 | 'ruby': RubyLanguage(), |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 523 | 'csharp': CSharpLanguage(), |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 524 | 'objc' : ObjCLanguage(), |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 525 | 'sanity': Sanity(), |
Nicolas "Pixel" Noble | fd2b093 | 2015-03-26 00:26:29 +0100 | [diff] [blame] | 526 | 'build': Build(), |
Craig Tiller | eb272bc | 2015-01-30 13:13:14 -0800 | [diff] [blame] | 527 | } |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 528 | |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 529 | _WINDOWS_CONFIG = { |
| 530 | 'dbg': 'Debug', |
| 531 | 'opt': 'Release', |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 532 | 'gcov': 'Debug', |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 533 | } |
| 534 | |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 535 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 536 | def _windows_arch_option(arch): |
| 537 | """Returns msbuild cmdline option for selected architecture.""" |
| 538 | if arch == 'default' or arch == 'windows_x86': |
| 539 | return '/p:Platform=Win32' |
| 540 | elif arch == 'windows_x64': |
| 541 | return '/p:Platform=x64' |
| 542 | else: |
| 543 | print 'Architecture %s not supported on current platform.' % arch |
| 544 | sys.exit(1) |
| 545 | |
| 546 | |
| 547 | def _windows_build_bat(compiler): |
| 548 | """Returns name of build.bat for selected compiler.""" |
| 549 | if compiler == 'default' or compiler == 'vs2013': |
| 550 | return 'vsprojects\\build_vs2013.bat' |
| 551 | elif compiler == 'vs2015': |
| 552 | return 'vsprojects\\build_vs2015.bat' |
| 553 | elif compiler == 'vs2010': |
| 554 | return 'vsprojects\\build_vs2010.bat' |
| 555 | else: |
| 556 | print 'Compiler %s not supported.' % compiler |
| 557 | sys.exit(1) |
| 558 | |
| 559 | |
| 560 | def _windows_toolset_option(compiler): |
| 561 | """Returns msbuild PlatformToolset for selected compiler.""" |
| 562 | if compiler == 'default' or compiler == 'vs2013': |
| 563 | return '/p:PlatformToolset=v120' |
| 564 | elif compiler == 'vs2015': |
| 565 | return '/p:PlatformToolset=v140' |
| 566 | elif compiler == 'vs2010': |
| 567 | return '/p:PlatformToolset=v100' |
| 568 | else: |
| 569 | print 'Compiler %s not supported.' % compiler |
| 570 | sys.exit(1) |
| 571 | |
| 572 | |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 573 | def runs_per_test_type(arg_str): |
| 574 | """Auxilary function to parse the "runs_per_test" flag. |
| 575 | |
| 576 | Returns: |
| 577 | A positive integer or 0, the latter indicating an infinite number of |
| 578 | runs. |
| 579 | |
| 580 | Raises: |
| 581 | argparse.ArgumentTypeError: Upon invalid input. |
| 582 | """ |
| 583 | if arg_str == 'inf': |
| 584 | return 0 |
| 585 | try: |
| 586 | n = int(arg_str) |
| 587 | if n <= 0: raise ValueError |
Craig Tiller | 50e53e2 | 2015-06-01 20:18:21 -0700 | [diff] [blame] | 588 | return n |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 589 | except: |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 590 | msg = '\'{}\' is not a positive integer or \'inf\''.format(arg_str) |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 591 | raise argparse.ArgumentTypeError(msg) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 592 | |
| 593 | # parse command line |
| 594 | argp = argparse.ArgumentParser(description='Run grpc tests.') |
| 595 | argp.add_argument('-c', '--config', |
| 596 | choices=['all'] + sorted(_CONFIGS.keys()), |
| 597 | nargs='+', |
| 598 | default=_DEFAULT) |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 599 | argp.add_argument('-n', '--runs_per_test', default=1, type=runs_per_test_type, |
| 600 | help='A positive integer or "inf". If "inf", all tests will run in an ' |
| 601 | 'infinite loop. Especially useful in combination with "-f"') |
Craig Tiller | fe406ec | 2015-02-24 13:55:12 -0800 | [diff] [blame] | 602 | argp.add_argument('-r', '--regex', default='.*', type=str) |
Craig Tiller | 83762ac | 2015-05-22 14:04:06 -0700 | [diff] [blame] | 603 | argp.add_argument('-j', '--jobs', default=2 * multiprocessing.cpu_count(), type=int) |
Craig Tiller | 8451e87 | 2015-02-27 09:25:51 -0800 | [diff] [blame] | 604 | argp.add_argument('-s', '--slowdown', default=1.0, type=float) |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 605 | argp.add_argument('-f', '--forever', |
| 606 | default=False, |
| 607 | action='store_const', |
| 608 | const=True) |
Nicolas "Pixel" Noble | a7df3f9 | 2015-02-26 22:07:04 +0100 | [diff] [blame] | 609 | argp.add_argument('-t', '--travis', |
| 610 | default=False, |
| 611 | action='store_const', |
| 612 | const=True) |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 613 | argp.add_argument('--newline_on_success', |
| 614 | default=False, |
| 615 | action='store_const', |
| 616 | const=True) |
Craig Tiller | 686fb26 | 2015-01-15 07:39:09 -0800 | [diff] [blame] | 617 | argp.add_argument('-l', '--language', |
Craig Tiller | 60f15e6 | 2015-05-13 09:05:17 -0700 | [diff] [blame] | 618 | choices=['all'] + sorted(_LANGUAGES.keys()), |
Craig Tiller | 686fb26 | 2015-01-15 07:39:09 -0800 | [diff] [blame] | 619 | nargs='+', |
Craig Tiller | 60f15e6 | 2015-05-13 09:05:17 -0700 | [diff] [blame] | 620 | default=['all']) |
Craig Tiller | cd43da8 | 2015-05-29 08:41:29 -0700 | [diff] [blame] | 621 | argp.add_argument('-S', '--stop_on_failure', |
| 622 | default=False, |
| 623 | action='store_const', |
| 624 | const=True) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 625 | argp.add_argument('--use_docker', |
| 626 | default=False, |
| 627 | action='store_const', |
| 628 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 629 | help='Run all the tests under docker. That provides ' + |
| 630 | 'additional isolation and prevents the need to install ' + |
| 631 | 'language specific prerequisites. Only available on Linux.') |
Craig Tiller | d4509a1 | 2015-09-28 09:18:40 -0700 | [diff] [blame] | 632 | argp.add_argument('--allow_flakes', |
| 633 | default=False, |
| 634 | action='store_const', |
| 635 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 636 | help='Allow flaky tests to show as passing (re-runs failed tests up to five times)') |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 637 | argp.add_argument('--arch', |
| 638 | choices=['default', 'windows_x86', 'windows_x64'], |
| 639 | default='default', |
| 640 | help='Selects architecture to target. For some platforms "default" is the only supported choice.') |
| 641 | argp.add_argument('--compiler', |
| 642 | choices=['default', 'vs2010', 'vs2013', 'vs2015'], |
| 643 | default='default', |
| 644 | help='Selects compiler to use. For some platforms "default" is the only supported choice.') |
| 645 | argp.add_argument('--build_only', |
| 646 | default=False, |
| 647 | action='store_const', |
| 648 | const=True, |
| 649 | help='Perform all the build steps but dont run any tests.') |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 650 | argp.add_argument('--update_submodules', default=[], nargs='*', |
| 651 | help='Update some submodules before building. If any are updated, also run generate_projects. ' + |
| 652 | 'Submodules are specified as SUBMODULE_NAME:BRANCH; if BRANCH is omitted, master is assumed.') |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 653 | argp.add_argument('-a', '--antagonists', default=0, type=int) |
Nicolas "Pixel" Noble | 5937b5b | 2015-06-26 02:04:12 +0200 | [diff] [blame] | 654 | argp.add_argument('-x', '--xml_report', default=None, type=str, |
| 655 | help='Generates a JUnit-compatible XML report') |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 656 | args = argp.parse_args() |
| 657 | |
Jan Tattermusch | c96b9eb | 2015-09-18 16:01:21 -0700 | [diff] [blame] | 658 | if args.use_docker: |
| 659 | if not args.travis: |
| 660 | print 'Seen --use_docker flag, will run tests under docker.' |
| 661 | print |
| 662 | print 'IMPORTANT: The changes you are testing need to be locally committed' |
| 663 | print 'because only the committed changes in the current branch will be' |
| 664 | print 'copied to the docker environment.' |
| 665 | time.sleep(5) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 666 | |
| 667 | child_argv = [ arg for arg in sys.argv if not arg == '--use_docker' ] |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 668 | run_tests_cmd = 'tools/run_tests/run_tests.py %s' % ' '.join(child_argv[1:]) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 669 | |
| 670 | # TODO(jtattermusch): revisit if we need special handling for arch here |
| 671 | # set arch command prefix in case we are working with different arch. |
| 672 | arch_env = os.getenv('arch') |
| 673 | if arch_env: |
| 674 | run_test_cmd = 'arch %s %s' % (arch_env, run_test_cmd) |
| 675 | |
| 676 | env = os.environ.copy() |
| 677 | env['RUN_TESTS_COMMAND'] = run_tests_cmd |
| 678 | if args.xml_report: |
| 679 | env['XML_REPORT'] = args.xml_report |
Jan Tattermusch | 261b58c | 2015-09-18 17:15:48 -0700 | [diff] [blame] | 680 | if not args.travis: |
| 681 | env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins. |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 682 | |
| 683 | subprocess.check_call(['tools/jenkins/build_docker_and_run_tests.sh'], |
| 684 | shell=True, |
| 685 | env=env) |
| 686 | sys.exit(0) |
| 687 | |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 688 | # update submodules if necessary |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 689 | need_to_regenerate_projects = False |
| 690 | for spec in args.update_submodules: |
| 691 | spec = spec.split(':', 1) |
| 692 | if len(spec) == 1: |
| 693 | submodule = spec[0] |
| 694 | branch = 'master' |
| 695 | elif len(spec) == 2: |
| 696 | submodule = spec[0] |
| 697 | branch = spec[1] |
| 698 | cwd = 'third_party/%s' % submodule |
| 699 | def git(cmd, cwd=cwd): |
| 700 | print 'in %s: git %s' % (cwd, cmd) |
| 701 | subprocess.check_call('git %s' % cmd, cwd=cwd, shell=True) |
| 702 | git('fetch') |
| 703 | git('checkout %s' % branch) |
| 704 | git('pull origin %s' % branch) |
| 705 | if os.path.exists('src/%s/gen_build_yaml.py' % submodule): |
| 706 | need_to_regenerate_projects = True |
| 707 | if need_to_regenerate_projects: |
| 708 | if jobset.platform_string() == 'linux': |
| 709 | subprocess.check_call('tools/buildgen/generate_projects.sh', shell=True) |
| 710 | else: |
| 711 | print 'WARNING: may need to regenerate projects, but since we are not on' |
| 712 | print ' Linux this step is being skipped. Compilation MAY fail.' |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 713 | |
| 714 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 715 | # grab config |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 716 | run_configs = set(_CONFIGS[cfg] |
| 717 | for cfg in itertools.chain.from_iterable( |
| 718 | _CONFIGS.iterkeys() if x == 'all' else [x] |
| 719 | for x in args.config)) |
| 720 | build_configs = set(cfg.build_config for cfg in run_configs) |
Craig Tiller | f1973b0 | 2015-01-16 12:32:13 -0800 | [diff] [blame] | 721 | |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 722 | if args.travis: |
murgatroid99 | d3b5b7f | 2015-10-06 17:02:03 -0700 | [diff] [blame] | 723 | _FORCE_ENVIRON_FOR_WRAPPERS = {'GRPC_TRACE': 'api'} |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 724 | |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 725 | if 'all' in args.language: |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 726 | lang_list = _LANGUAGES.keys() |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 727 | else: |
| 728 | lang_list = args.language |
| 729 | # We don't support code coverage on ObjC |
| 730 | if 'gcov' in args.config and 'objc' in lang_list: |
| 731 | lang_list.remove('objc') |
| 732 | |
| 733 | languages = set(_LANGUAGES[l] for l in lang_list) |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 734 | |
| 735 | if len(build_configs) > 1: |
| 736 | for language in languages: |
| 737 | if not language.supports_multi_config(): |
| 738 | print language, 'does not support multiple build configurations' |
| 739 | sys.exit(1) |
| 740 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 741 | if platform_string() != 'windows': |
| 742 | if args.arch != 'default': |
| 743 | print 'Architecture %s not supported on current platform.' % args.arch |
| 744 | sys.exit(1) |
| 745 | if args.compiler != 'default': |
| 746 | print 'Compiler %s not supported on current platform.' % args.compiler |
| 747 | sys.exit(1) |
| 748 | |
Nicolas "Pixel" Noble | f72d7b5 | 2015-12-03 03:07:43 +0100 | [diff] [blame] | 749 | if platform_string() == 'windows': |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 750 | def make_jobspec(cfg, targets, makefile='Makefile'): |
Craig Tiller | fc3c0c4 | 2015-09-01 16:47:54 -0700 | [diff] [blame] | 751 | extra_args = [] |
Craig Tiller | b5391e1 | 2015-09-03 14:35:18 -0700 | [diff] [blame] | 752 | # better do parallel compilation |
Jan Tattermusch | 47eeb2b | 2015-10-07 14:09:18 -0700 | [diff] [blame] | 753 | # empirically /m:2 gives the best performance/price and should prevent |
| 754 | # overloading the windows workers. |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 755 | extra_args.extend(['/m:2']) |
Craig Tiller | b5391e1 | 2015-09-03 14:35:18 -0700 | [diff] [blame] | 756 | # disable PDB generation: it's broken, and we don't need it during CI |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 757 | extra_args.extend(['/p:Jenkins=true']) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 758 | return [ |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 759 | jobset.JobSpec([_windows_build_bat(args.compiler), |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 760 | 'vsprojects\\%s.sln' % target, |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 761 | '/p:Configuration=%s' % _WINDOWS_CONFIG[cfg], |
| 762 | _windows_toolset_option(args.compiler), |
| 763 | _windows_arch_option(args.arch)] + |
Craig Tiller | fc3c0c4 | 2015-09-01 16:47:54 -0700 | [diff] [blame] | 764 | extra_args, |
Craig Tiller | dfc3eee | 2015-09-01 16:32:16 -0700 | [diff] [blame] | 765 | shell=True, timeout_seconds=90*60) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 766 | for target in targets] |
Craig Tiller | 5058c69 | 2015-04-08 09:42:04 -0700 | [diff] [blame] | 767 | else: |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 768 | def make_jobspec(cfg, targets, makefile='Makefile'): |
murgatroid99 | 8ae409f | 2015-10-26 16:39:00 -0700 | [diff] [blame] | 769 | if targets: |
| 770 | return [jobset.JobSpec([os.getenv('MAKE', 'make'), |
| 771 | '-f', makefile, |
| 772 | '-j', '%d' % (multiprocessing.cpu_count() + 1), |
| 773 | 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % |
| 774 | args.slowdown, |
| 775 | 'CONFIG=%s' % cfg] + targets, |
| 776 | timeout_seconds=30*60)] |
| 777 | else: |
| 778 | return [] |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 779 | make_targets = {} |
| 780 | for l in languages: |
| 781 | makefile = l.makefile_name() |
| 782 | make_targets[makefile] = make_targets.get(makefile, set()).union( |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 783 | set(l.make_targets(args.regex))) |
Craig Tiller | 5058c69 | 2015-04-08 09:42:04 -0700 | [diff] [blame] | 784 | |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 785 | def build_step_environ(cfg): |
| 786 | environ = {'CONFIG': cfg} |
Jan Tattermusch | 68016a1 | 2015-12-16 15:31:33 -0800 | [diff] [blame] | 787 | msbuild_cfg = _WINDOWS_CONFIG.get(cfg) |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 788 | if msbuild_cfg: |
| 789 | environ['MSBUILD_CONFIG'] = msbuild_cfg |
| 790 | return environ |
| 791 | |
murgatroid99 | fddac96 | 2015-09-22 09:20:11 -0700 | [diff] [blame] | 792 | build_steps = list(set( |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 793 | jobset.JobSpec(cmdline, environ=build_step_environ(cfg), flake_retries=5) |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 794 | for cfg in build_configs |
| 795 | for l in languages |
| 796 | for cmdline in l.pre_build_steps())) |
Craig Tiller | bd4e378 | 2015-09-01 06:48:55 -0700 | [diff] [blame] | 797 | if make_targets: |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 798 | make_commands = itertools.chain.from_iterable(make_jobspec(cfg, list(targets), makefile) for cfg in build_configs for (makefile, targets) in make_targets.iteritems()) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 799 | build_steps.extend(set(make_commands)) |
Craig Tiller | 5058c69 | 2015-04-08 09:42:04 -0700 | [diff] [blame] | 800 | build_steps.extend(set( |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 801 | jobset.JobSpec(cmdline, environ=build_step_environ(cfg), timeout_seconds=10*60) |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 802 | for cfg in build_configs |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 803 | for l in languages |
Craig Tiller | 533b1a2 | 2015-05-29 08:41:29 -0700 | [diff] [blame] | 804 | for cmdline in l.build_steps())) |
Craig Tiller | f1973b0 | 2015-01-16 12:32:13 -0800 | [diff] [blame] | 805 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 806 | post_tests_steps = list(set( |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 807 | jobset.JobSpec(cmdline, environ=build_step_environ(cfg)) |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 808 | for cfg in build_configs |
| 809 | for l in languages |
| 810 | for cmdline in l.post_tests_steps())) |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 811 | runs_per_test = args.runs_per_test |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 812 | forever = args.forever |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 813 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 814 | |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 815 | class TestCache(object): |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 816 | """Cache for running tests.""" |
| 817 | |
David Klempner | 2573958 | 2015-02-11 15:57:32 -0800 | [diff] [blame] | 818 | def __init__(self, use_cache_results): |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 819 | self._last_successful_run = {} |
David Klempner | 2573958 | 2015-02-11 15:57:32 -0800 | [diff] [blame] | 820 | self._use_cache_results = use_cache_results |
Craig Tiller | 69cd237 | 2015-06-11 09:38:09 -0700 | [diff] [blame] | 821 | self._last_save = time.time() |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 822 | |
| 823 | def should_run(self, cmdline, bin_hash): |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 824 | if cmdline not in self._last_successful_run: |
| 825 | return True |
| 826 | if self._last_successful_run[cmdline] != bin_hash: |
| 827 | return True |
David Klempner | 2573958 | 2015-02-11 15:57:32 -0800 | [diff] [blame] | 828 | if not self._use_cache_results: |
| 829 | return True |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 830 | return False |
| 831 | |
| 832 | def finished(self, cmdline, bin_hash): |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 833 | self._last_successful_run[cmdline] = bin_hash |
Craig Tiller | 69cd237 | 2015-06-11 09:38:09 -0700 | [diff] [blame] | 834 | if time.time() - self._last_save > 1: |
| 835 | self.save() |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 836 | |
| 837 | def dump(self): |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 838 | return [{'cmdline': k, 'hash': v} |
| 839 | for k, v in self._last_successful_run.iteritems()] |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 840 | |
| 841 | def parse(self, exdump): |
| 842 | self._last_successful_run = dict((o['cmdline'], o['hash']) for o in exdump) |
| 843 | |
| 844 | def save(self): |
| 845 | with open('.run_tests_cache', 'w') as f: |
Craig Tiller | 261dd98 | 2015-01-16 16:41:45 -0800 | [diff] [blame] | 846 | f.write(json.dumps(self.dump())) |
Craig Tiller | 69cd237 | 2015-06-11 09:38:09 -0700 | [diff] [blame] | 847 | self._last_save = time.time() |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 848 | |
Craig Tiller | 1cc11db | 2015-01-15 22:50:50 -0800 | [diff] [blame] | 849 | def maybe_load(self): |
| 850 | if os.path.exists('.run_tests_cache'): |
| 851 | with open('.run_tests_cache') as f: |
Craig Tiller | 261dd98 | 2015-01-16 16:41:45 -0800 | [diff] [blame] | 852 | self.parse(json.loads(f.read())) |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 853 | |
| 854 | |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 855 | def _start_port_server(port_server_port): |
| 856 | # check if a compatible port server is running |
| 857 | # if incompatible (version mismatch) ==> start a new one |
| 858 | # if not running ==> start a new one |
| 859 | # otherwise, leave it up |
| 860 | try: |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 861 | version = int(urllib2.urlopen( |
| 862 | 'http://localhost:%d/version_number' % port_server_port, |
| 863 | timeout=1).read()) |
| 864 | print 'detected port server running version %d' % version |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 865 | running = True |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 866 | except Exception as e: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 867 | print 'failed to detect port server: %s' % sys.exc_info()[0] |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 868 | print e.strerror |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 869 | running = False |
| 870 | if running: |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 871 | current_version = int(subprocess.check_output( |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 872 | [sys.executable, os.path.abspath('tools/run_tests/port_server.py'), |
| 873 | 'dump_version'])) |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 874 | print 'my port server is version %d' % current_version |
| 875 | running = (version >= current_version) |
| 876 | if not running: |
| 877 | print 'port_server version mismatch: killing the old one' |
| 878 | urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read() |
| 879 | time.sleep(1) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 880 | if not running: |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 881 | fd, logfile = tempfile.mkstemp() |
| 882 | os.close(fd) |
| 883 | print 'starting port_server, with log file %s' % logfile |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 884 | args = [sys.executable, os.path.abspath('tools/run_tests/port_server.py'), |
| 885 | '-p', '%d' % port_server_port, '-l', logfile] |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 886 | env = dict(os.environ) |
| 887 | env['BUILD_ID'] = 'pleaseDontKillMeJenkins' |
Nicolas "Pixel" Noble | f72d7b5 | 2015-12-03 03:07:43 +0100 | [diff] [blame] | 888 | if platform_string() == 'windows': |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 889 | # Working directory of port server needs to be outside of Jenkins |
| 890 | # workspace to prevent file lock issues. |
| 891 | tempdir = tempfile.mkdtemp() |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 892 | port_server = subprocess.Popen( |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 893 | args, |
| 894 | env=env, |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 895 | cwd=tempdir, |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 896 | creationflags = 0x00000008, # detached process |
| 897 | close_fds=True) |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 898 | else: |
| 899 | port_server = subprocess.Popen( |
| 900 | args, |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 901 | env=env, |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 902 | preexec_fn=os.setsid, |
| 903 | close_fds=True) |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 904 | time.sleep(1) |
Craig Tiller | 8b5f4dc | 2015-08-26 08:02:01 -0700 | [diff] [blame] | 905 | # ensure port server is up |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 906 | waits = 0 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 907 | while True: |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 908 | if waits > 10: |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 909 | print 'killing port server due to excessive start up waits' |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 910 | port_server.kill() |
Craig Tiller | a2f38b0 | 2015-09-24 11:19:17 -0700 | [diff] [blame] | 911 | if port_server.poll() is not None: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 912 | print 'port_server failed to start' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 913 | # try one final time: maybe another build managed to start one |
| 914 | time.sleep(1) |
| 915 | try: |
| 916 | urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
| 917 | timeout=1).read() |
| 918 | print 'last ditch attempt to contact port server succeeded' |
| 919 | break |
| 920 | except: |
| 921 | traceback.print_exc(); |
| 922 | port_log = open(logfile, 'r').read() |
| 923 | print port_log |
| 924 | sys.exit(1) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 925 | try: |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 926 | urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
| 927 | timeout=1).read() |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 928 | print 'port server is up and ready' |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 929 | break |
Craig Tiller | 31fdaa4 | 2015-09-25 13:09:59 -0700 | [diff] [blame] | 930 | except socket.timeout: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 931 | print 'waiting for port_server: timeout' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 932 | traceback.print_exc(); |
| 933 | time.sleep(1) |
Craig Tiller | 31fdaa4 | 2015-09-25 13:09:59 -0700 | [diff] [blame] | 934 | waits += 1 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 935 | except urllib2.URLError: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 936 | print 'waiting for port_server: urlerror' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 937 | traceback.print_exc(); |
| 938 | time.sleep(1) |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 939 | waits += 1 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 940 | except: |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 941 | traceback.print_exc(); |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 942 | port_server.kill() |
| 943 | raise |
| 944 | |
| 945 | |
Adele Zhou | d5fffa5 | 2015-10-23 15:51:42 -0700 | [diff] [blame] | 946 | def _calculate_num_runs_failures(list_of_results): |
| 947 | """Caculate number of runs and failures for a particular test. |
| 948 | |
| 949 | Args: |
| 950 | list_of_results: (List) of JobResult object. |
| 951 | Returns: |
| 952 | A tuple of total number of runs and failures. |
| 953 | """ |
| 954 | num_runs = len(list_of_results) # By default, there is 1 run per JobResult. |
| 955 | num_failures = 0 |
| 956 | for jobresult in list_of_results: |
| 957 | if jobresult.retries > 0: |
| 958 | num_runs += jobresult.retries |
| 959 | if jobresult.num_failures > 0: |
| 960 | num_failures += jobresult.num_failures |
| 961 | return num_runs, num_failures |
| 962 | |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 963 | |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 964 | # _build_and_run results |
| 965 | class BuildAndRunError(object): |
| 966 | |
| 967 | BUILD = object() |
| 968 | TEST = object() |
| 969 | POST_TEST = object() |
| 970 | |
| 971 | |
| 972 | # returns a list of things that failed (or an empty list on success) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 973 | def _build_and_run( |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 974 | check_cancelled, newline_on_success, cache, xml_report=None, build_only=False): |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 975 | """Do one pass of building & running tests.""" |
murgatroid99 | 666450e | 2015-01-26 13:03:31 -0800 | [diff] [blame] | 976 | # build latest sequentially |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 977 | num_failures, _ = jobset.run( |
| 978 | build_steps, maxjobs=1, stop_on_failure=True, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 979 | newline_on_success=newline_on_success, travis=args.travis) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 980 | if num_failures: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 981 | return [BuildAndRunError.BUILD] |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 982 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 983 | if build_only: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 984 | return [] |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 985 | |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 986 | # start antagonists |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 987 | antagonists = [subprocess.Popen(['tools/run_tests/antagonist.py']) |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 988 | for _ in range(0, args.antagonists)] |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 989 | port_server_port = 32767 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 990 | _start_port_server(port_server_port) |
Adele Zhou | 7cf7211 | 2015-11-04 11:18:43 -0800 | [diff] [blame] | 991 | resultset = None |
Adele Zhou | 803af15 | 2015-11-30 15:16:16 -0800 | [diff] [blame] | 992 | num_test_failures = 0 |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 993 | try: |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 994 | infinite_runs = runs_per_test == 0 |
yang-g | 6c1fdc6 | 2015-08-18 11:57:42 -0700 | [diff] [blame] | 995 | one_run = set( |
| 996 | spec |
| 997 | for config in run_configs |
| 998 | for language in languages |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 999 | for spec in language.test_specs(config, args) |
yang-g | 6c1fdc6 | 2015-08-18 11:57:42 -0700 | [diff] [blame] | 1000 | if re.search(args.regex, spec.shortname)) |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1001 | # When running on travis, we want out test runs to be as similar as possible |
| 1002 | # for reproducibility purposes. |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1003 | if args.travis: |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1004 | massaged_one_run = sorted(one_run, key=lambda x: x.shortname) |
| 1005 | else: |
| 1006 | # whereas otherwise, we want to shuffle things up to give all tests a |
| 1007 | # chance to run. |
| 1008 | massaged_one_run = list(one_run) # random.shuffle needs an indexable seq. |
| 1009 | random.shuffle(massaged_one_run) # which it modifies in-place. |
Craig Tiller | f7b7c89 | 2015-06-22 14:33:25 -0700 | [diff] [blame] | 1010 | if infinite_runs: |
| 1011 | assert len(massaged_one_run) > 0, 'Must have at least one test for a -n inf run' |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1012 | runs_sequence = (itertools.repeat(massaged_one_run) if infinite_runs |
| 1013 | else itertools.repeat(massaged_one_run, runs_per_test)) |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 1014 | all_runs = itertools.chain.from_iterable(runs_sequence) |
Nicolas "Pixel" Noble | 5937b5b | 2015-06-26 02:04:12 +0200 | [diff] [blame] | 1015 | |
Adele Zhou | 803af15 | 2015-11-30 15:16:16 -0800 | [diff] [blame] | 1016 | num_test_failures, resultset = jobset.run( |
Adele Zhou | 2271ab5 | 2015-10-28 13:59:14 -0700 | [diff] [blame] | 1017 | all_runs, check_cancelled, newline_on_success=newline_on_success, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1018 | travis=args.travis, infinite_runs=infinite_runs, maxjobs=args.jobs, |
murgatroid99 | 8ae409f | 2015-10-26 16:39:00 -0700 | [diff] [blame] | 1019 | stop_on_failure=args.stop_on_failure, |
Adele Zhou | f2ca7bc | 2015-10-23 15:38:00 -0700 | [diff] [blame] | 1020 | cache=cache if not xml_report else None, |
Adele Zhou | f2ca7bc | 2015-10-23 15:38:00 -0700 | [diff] [blame] | 1021 | add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port}) |
Adele Zhou | d5fffa5 | 2015-10-23 15:51:42 -0700 | [diff] [blame] | 1022 | if resultset: |
| 1023 | for k, v in resultset.iteritems(): |
| 1024 | num_runs, num_failures = _calculate_num_runs_failures(v) |
| 1025 | if num_failures == num_runs: # what about infinite_runs??? |
| 1026 | jobset.message('FAILED', k, do_newline=True) |
| 1027 | elif num_failures > 0: |
| 1028 | jobset.message( |
| 1029 | 'FLAKE', '%s [%d/%d runs flaked]' % (k, num_failures, num_runs), |
| 1030 | do_newline=True) |
| 1031 | else: |
| 1032 | jobset.message('PASSED', k, do_newline=True) |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 1033 | finally: |
| 1034 | for antagonist in antagonists: |
| 1035 | antagonist.kill() |
Adele Zhou | 7cf7211 | 2015-11-04 11:18:43 -0800 | [diff] [blame] | 1036 | if xml_report and resultset: |
Adele Zhou | 3bc7ba4 | 2015-11-05 10:21:58 -0800 | [diff] [blame] | 1037 | report_utils.render_junit_xml_report(resultset, xml_report) |
Craig Tiller | d86a394 | 2015-01-14 12:48:54 -0800 | [diff] [blame] | 1038 | |
Adele Zhou | f2ca7bc | 2015-10-23 15:38:00 -0700 | [diff] [blame] | 1039 | number_failures, _ = jobset.run( |
| 1040 | post_tests_steps, maxjobs=1, stop_on_failure=True, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1041 | newline_on_success=newline_on_success, travis=args.travis) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1042 | |
| 1043 | out = [] |
| 1044 | if number_failures: |
| 1045 | out.append(BuildAndRunError.POST_TEST) |
| 1046 | if num_test_failures: |
| 1047 | out.append(BuildAndRunError.TEST) |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 1048 | |
Craig Tiller | 69cd237 | 2015-06-11 09:38:09 -0700 | [diff] [blame] | 1049 | if cache: cache.save() |
| 1050 | |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1051 | return out |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1052 | |
| 1053 | |
David Klempner | 2573958 | 2015-02-11 15:57:32 -0800 | [diff] [blame] | 1054 | test_cache = TestCache(runs_per_test == 1) |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 1055 | test_cache.maybe_load() |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 1056 | |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1057 | if forever: |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1058 | success = True |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1059 | while True: |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 1060 | dw = watch_dirs.DirWatcher(['src', 'include', 'test', 'examples']) |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1061 | initial_time = dw.most_recent_change() |
| 1062 | have_files_changed = lambda: dw.most_recent_change() != initial_time |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1063 | previous_success = success |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1064 | errors = _build_and_run(check_cancelled=have_files_changed, |
| 1065 | newline_on_success=False, |
| 1066 | cache=test_cache, |
| 1067 | build_only=args.build_only) == 0 |
| 1068 | if not previous_success and not errors: |
Nicolas Noble | b09078f | 2015-01-14 18:06:05 -0800 | [diff] [blame] | 1069 | jobset.message('SUCCESS', |
| 1070 | 'All tests are now passing properly', |
| 1071 | do_newline=True) |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1072 | jobset.message('IDLE', 'No change detected') |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1073 | while not have_files_changed(): |
| 1074 | time.sleep(1) |
| 1075 | else: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1076 | errors = _build_and_run(check_cancelled=lambda: False, |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 1077 | newline_on_success=args.newline_on_success, |
Nicolas "Pixel" Noble | 5937b5b | 2015-06-26 02:04:12 +0200 | [diff] [blame] | 1078 | cache=test_cache, |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 1079 | xml_report=args.xml_report, |
| 1080 | build_only=args.build_only) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1081 | if not errors: |
Nicolas Noble | b09078f | 2015-01-14 18:06:05 -0800 | [diff] [blame] | 1082 | jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
| 1083 | else: |
| 1084 | jobset.message('FAILED', 'Some tests failed', do_newline=True) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1085 | exit_code = 0 |
| 1086 | if BuildAndRunError.BUILD in errors: |
| 1087 | exit_code |= 1 |
Craig Tiller | 4f2be36 | 2016-01-08 08:59:20 -0800 | [diff] [blame^] | 1088 | if BuildAndRunError.TEST in errors and not args.travis: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1089 | exit_code |= 2 |
Craig Tiller | 4f2be36 | 2016-01-08 08:59:20 -0800 | [diff] [blame^] | 1090 | if BuildAndRunError.POST_TEST in errors: |
| 1091 | exit_code |= 4 |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1092 | sys.exit(exit_code) |
Craig Tiller | 4f2be36 | 2016-01-08 08:59:20 -0800 | [diff] [blame^] | 1093 | |