aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2017-12-11 16:56:44 -0800
committerGravatar ncteisen <ncteisen@gmail.com>2017-12-11 16:56:44 -0800
commit0cd6cfefa0a21ccf8dc28d623c03f3425e9ed72b (patch)
tree2e87bc7e8db658692b79177d1e3d7c09f2c63773 /tools/run_tests
parent05687c3da9848ab79f08417793965de9bbbb52b0 (diff)
yapf tools/run_tests/sanity
Diffstat (limited to 'tools/run_tests')
-rwxr-xr-xtools/run_tests/python_utils/jobset.py7
-rwxr-xr-xtools/run_tests/python_utils/port_server.py11
-rwxr-xr-xtools/run_tests/sanity/check_bazel_workspace.py30
-rwxr-xr-xtools/run_tests/sanity/check_sources_and_headers.py107
-rwxr-xr-xtools/run_tests/sanity/check_test_filtering.py217
-rwxr-xr-xtools/run_tests/sanity/check_tracer_sanity.py21
-rwxr-xr-xtools/run_tests/sanity/check_version.py76
-rwxr-xr-xtools/run_tests/sanity/core_banned_functions.py36
8 files changed, 280 insertions, 225 deletions
diff --git a/tools/run_tests/python_utils/jobset.py b/tools/run_tests/python_utils/jobset.py
index 424b4404a8..454d09bf0d 100755
--- a/tools/run_tests/python_utils/jobset.py
+++ b/tools/run_tests/python_utils/jobset.py
@@ -209,10 +209,9 @@ class JobSpec(object):
self.cmdline)
def __str__(self):
- return '%s: %s %s' % (self.shortname,
- ' '.join('%s=%s' % kv
- for kv in self.environ.items()),
- ' '.join(self.cmdline))
+ return '%s: %s %s' % (self.shortname, ' '.join(
+ '%s=%s' % kv
+ for kv in self.environ.items()), ' '.join(self.cmdline))
class JobResult(object):
diff --git a/tools/run_tests/python_utils/port_server.py b/tools/run_tests/python_utils/port_server.py
index 15f55f46dd..83e09c09d0 100755
--- a/tools/run_tests/python_utils/port_server.py
+++ b/tools/run_tests/python_utils/port_server.py
@@ -185,11 +185,12 @@ class Handler(BaseHTTPRequestHandler):
self.end_headers()
mu.acquire()
now = time.time()
- out = yaml.dump(
- {
- 'pool': pool,
- 'in_use': dict((k, now - v) for k, v in in_use.items())
- })
+ out = yaml.dump({
+ 'pool':
+ pool,
+ 'in_use':
+ dict((k, now - v) for k, v in in_use.items())
+ })
mu.release()
self.wfile.write(out)
elif self.path == '/quitquitquit':
diff --git a/tools/run_tests/sanity/check_bazel_workspace.py b/tools/run_tests/sanity/check_bazel_workspace.py
index 776c78b03f..b5a77f4479 100755
--- a/tools/run_tests/sanity/check_bazel_workspace.py
+++ b/tools/run_tests/sanity/check_bazel_workspace.py
@@ -27,23 +27,37 @@ os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
git_hash_pattern = re.compile('[0-9a-f]{40}')
# Parse git hashes from submodules
-git_submodules = subprocess.check_output('git submodule', shell=True).strip().split('\n')
-git_submodule_hashes = {re.search(git_hash_pattern, s).group() for s in git_submodules}
+git_submodules = subprocess.check_output(
+ 'git submodule', shell=True).strip().split('\n')
+git_submodule_hashes = {
+ re.search(git_hash_pattern, s).group()
+ for s in git_submodules
+}
# Parse git hashes from Bazel WORKSPACE {new_}http_archive rules
with open('WORKSPACE', 'r') as f:
- workspace_rules = [expr.value for expr in ast.parse(f.read()).body]
-
-http_archive_rules = [rule for rule in workspace_rules if rule.func.id.endswith('http_archive')]
-archive_urls = [kw.value.s for rule in http_archive_rules for kw in rule.keywords if kw.arg == 'url']
-workspace_git_hashes = {re.search(git_hash_pattern, url).group() for url in archive_urls}
+ workspace_rules = [expr.value for expr in ast.parse(f.read()).body]
+
+http_archive_rules = [
+ rule for rule in workspace_rules if rule.func.id.endswith('http_archive')
+]
+archive_urls = [
+ kw.value.s for rule in http_archive_rules for kw in rule.keywords
+ if kw.arg == 'url'
+]
+workspace_git_hashes = {
+ re.search(git_hash_pattern, url).group()
+ for url in archive_urls
+}
# Validate the equivalence of the git submodules and Bazel git dependencies. The
# condition we impose is that there is a git submodule for every dependency in
# the workspace, but not necessarily conversely. E.g. Bloaty is a dependency
# not used by any of the targets built by Bazel.
if len(workspace_git_hashes - git_submodule_hashes) > 0:
- print("Found discrepancies between git submodules and Bazel WORKSPACE dependencies")
+ print(
+ "Found discrepancies between git submodules and Bazel WORKSPACE dependencies"
+ )
sys.exit(1)
sys.exit(0)
diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py
index cae175cfc3..7e2465af6d 100755
--- a/tools/run_tests/sanity/check_sources_and_headers.py
+++ b/tools/run_tests/sanity/check_sources_and_headers.py
@@ -21,71 +21,80 @@ import re
import sys
root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
-with open(os.path.join(root, 'tools', 'run_tests', 'generated', 'sources_and_headers.json')) as f:
- js = json.loads(f.read())
+with open(
+ os.path.join(root, 'tools', 'run_tests', 'generated',
+ 'sources_and_headers.json')) as f:
+ js = json.loads(f.read())
re_inc1 = re.compile(r'^#\s*include\s*"([^"]*)"')
assert re_inc1.match('#include "foo"').group(1) == 'foo'
re_inc2 = re.compile(r'^#\s*include\s*<((grpc|grpc\+\+)/[^"]*)>')
assert re_inc2.match('#include <grpc++/foo>').group(1) == 'grpc++/foo'
+
def get_target(name):
- for target in js:
- if target['name'] == name:
- return target
- assert False, 'no target %s' % name
+ for target in js:
+ if target['name'] == name:
+ return target
+ assert False, 'no target %s' % name
+
def target_has_header(target, name):
- if name.startswith('absl/'): return True
- # print target['name'], name
- if name in target['headers']:
- return True
- for dep in target['deps']:
- if target_has_header(get_target(dep), name):
- return True
- if name in ['src/core/lib/profiling/stap_probes.h',
- 'src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h']:
- return True
- return False
+ if name.startswith('absl/'): return True
+ # print target['name'], name
+ if name in target['headers']:
+ return True
+ for dep in target['deps']:
+ if target_has_header(get_target(dep), name):
+ return True
+ if name in [
+ 'src/core/lib/profiling/stap_probes.h',
+ 'src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h'
+ ]:
+ return True
+ return False
+
def produces_object(name):
- return os.path.splitext(name)[1] in ['.c', '.cc']
+ return os.path.splitext(name)[1] in ['.c', '.cc']
+
c_ish = {}
obj_producer_to_source = {'c': c_ish, 'c++': c_ish, 'csharp': {}}
errors = 0
for target in js:
- if not target['third_party']:
- for fn in target['src']:
- with open(os.path.join(root, fn)) as f:
- src = f.read().splitlines()
- for line in src:
- m = re_inc1.match(line)
- if m:
- if not target_has_header(target, m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
- m = re_inc2.match(line)
- if m:
- if not target_has_header(target, 'include/' + m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
- if target['type'] in ['lib', 'filegroup']:
- for fn in target['src']:
- language = target['language']
- if produces_object(fn):
- obj_base = os.path.splitext(os.path.basename(fn))[0]
- if obj_base in obj_producer_to_source[language]:
- if obj_producer_to_source[language][obj_base] != fn:
- print (
- 'target %s (%s) produces an aliased object file with %s' % (
- target['name'], fn, obj_producer_to_source[language][obj_base]))
- else:
- obj_producer_to_source[language][obj_base] = fn
+ if not target['third_party']:
+ for fn in target['src']:
+ with open(os.path.join(root, fn)) as f:
+ src = f.read().splitlines()
+ for line in src:
+ m = re_inc1.match(line)
+ if m:
+ if not target_has_header(target, m.group(1)):
+ print(
+ 'target %s (%s) does not name header %s as a dependency'
+ % (target['name'], fn, m.group(1)))
+ errors += 1
+ m = re_inc2.match(line)
+ if m:
+ if not target_has_header(target, 'include/' + m.group(1)):
+ print(
+ 'target %s (%s) does not name header %s as a dependency'
+ % (target['name'], fn, m.group(1)))
+ errors += 1
+ if target['type'] in ['lib', 'filegroup']:
+ for fn in target['src']:
+ language = target['language']
+ if produces_object(fn):
+ obj_base = os.path.splitext(os.path.basename(fn))[0]
+ if obj_base in obj_producer_to_source[language]:
+ if obj_producer_to_source[language][obj_base] != fn:
+ print(
+ 'target %s (%s) produces an aliased object file with %s'
+ % (target['name'], fn,
+ obj_producer_to_source[language][obj_base]))
+ else:
+ obj_producer_to_source[language][obj_base] = fn
assert errors == 0
diff --git a/tools/run_tests/sanity/check_test_filtering.py b/tools/run_tests/sanity/check_test_filtering.py
index ff4ecba8ab..c2a6399ae8 100755
--- a/tools/run_tests/sanity/check_test_filtering.py
+++ b/tools/run_tests/sanity/check_test_filtering.py
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
import os
import sys
import unittest
@@ -25,108 +24,138 @@ sys.path.insert(0, os.path.abspath('tools/run_tests/'))
from run_tests_matrix import _create_test_jobs, _create_portability_test_jobs
import python_utils.filter_pull_request_tests as filter_pull_request_tests
-_LIST_OF_LANGUAGE_LABELS = ['c', 'c++', 'csharp', 'grpc-node', 'objc', 'php', 'php7', 'python', 'ruby']
+_LIST_OF_LANGUAGE_LABELS = [
+ 'c', 'c++', 'csharp', 'grpc-node', 'objc', 'php', 'php7', 'python', 'ruby'
+]
_LIST_OF_PLATFORM_LABELS = ['linux', 'macos', 'windows']
+
class TestFilteringTest(unittest.TestCase):
- def generate_all_tests(self):
- all_jobs = _create_test_jobs() + _create_portability_test_jobs()
- self.assertIsNotNone(all_jobs)
- return all_jobs
+ def generate_all_tests(self):
+ all_jobs = _create_test_jobs() + _create_portability_test_jobs()
+ self.assertIsNotNone(all_jobs)
+ return all_jobs
- def test_filtering(self, changed_files=[], labels=_LIST_OF_LANGUAGE_LABELS):
- """
+ def test_filtering(self, changed_files=[], labels=_LIST_OF_LANGUAGE_LABELS):
+ """
Default args should filter no tests because changed_files is empty and
default labels should be able to match all jobs
:param changed_files: mock list of changed_files from pull request
:param labels: list of job labels that should be skipped
"""
- all_jobs = self.generate_all_tests()
- # Replacing _get_changed_files function to allow specifying changed files in filter_tests function
- def _get_changed_files(foo):
- return changed_files
- filter_pull_request_tests._get_changed_files = _get_changed_files
- print()
- filtered_jobs = filter_pull_request_tests.filter_tests(all_jobs, "test")
-
- # Make sure sanity tests aren't being filtered out
- sanity_tests_in_all_jobs = 0
- sanity_tests_in_filtered_jobs = 0
- for job in all_jobs:
- if "sanity" in job.labels:
- sanity_tests_in_all_jobs += 1
- all_jobs = [job for job in all_jobs if "sanity" not in job.labels]
- for job in filtered_jobs:
- if "sanity" in job.labels:
- sanity_tests_in_filtered_jobs += 1
- filtered_jobs = [job for job in filtered_jobs if "sanity" not in job.labels]
- self.assertEquals(sanity_tests_in_all_jobs, sanity_tests_in_filtered_jobs)
-
- for label in labels:
- for job in filtered_jobs:
- self.assertNotIn(label, job.labels)
-
- jobs_matching_labels = 0
- for label in labels:
- for job in all_jobs:
- if (label in job.labels):
- jobs_matching_labels += 1
- self.assertEquals(len(filtered_jobs), len(all_jobs) - jobs_matching_labels)
-
- def test_individual_language_filters(self):
- # Changing unlisted file should trigger all languages
- self.test_filtering(['ffffoo/bar.baz'], [_LIST_OF_LANGUAGE_LABELS])
- # Changing core should trigger all tests
- self.test_filtering(['src/core/foo.bar'], [_LIST_OF_LANGUAGE_LABELS])
- # Testing individual languages
- self.test_filtering(['test/core/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CORE_TEST_SUITE.labels +
- filter_pull_request_tests._CPP_TEST_SUITE.labels])
- self.test_filtering(['src/cpp/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels])
- self.test_filtering(['src/csharp/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CSHARP_TEST_SUITE.labels])
- self.test_filtering(['src/objective-c/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._OBJC_TEST_SUITE.labels])
- self.test_filtering(['src/php/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._PHP_TEST_SUITE.labels])
- self.test_filtering(['src/python/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._PYTHON_TEST_SUITE.labels])
- self.test_filtering(['src/ruby/foo.bar'], [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._RUBY_TEST_SUITE.labels])
-
- def test_combined_language_filters(self):
- self.test_filtering(['src/cpp/foo.bar', 'test/core/foo.bar'],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._CORE_TEST_SUITE.labels])
- self.test_filtering(['src/cpp/foo.bar', "src/csharp/foo.bar"],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._CPP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._CSHARP_TEST_SUITE.labels])
- self.test_filtering(['src/objective-c/foo.bar', 'src/php/foo.bar', "src/python/foo.bar", "src/ruby/foo.bar"],
- [label for label in _LIST_OF_LANGUAGE_LABELS if label not in
- filter_pull_request_tests._OBJC_TEST_SUITE.labels and label not in
- filter_pull_request_tests._PHP_TEST_SUITE.labels and label not in
- filter_pull_request_tests._PYTHON_TEST_SUITE.labels and label not in
- filter_pull_request_tests._RUBY_TEST_SUITE.labels])
-
- def test_platform_filter(self):
- self.test_filtering(['vsprojects/foo.bar'], [label for label in _LIST_OF_PLATFORM_LABELS if label not in
- filter_pull_request_tests._WINDOWS_TEST_SUITE.labels])
-
- def test_whitelist(self):
- whitelist = filter_pull_request_tests._WHITELIST_DICT
- files_that_should_trigger_all_tests = ['src/core/foo.bar',
- 'some_file_not_on_the_white_list',
- 'BUILD',
- 'etc/roots.pem',
- 'Makefile',
- 'tools/foo']
- for key in whitelist.keys():
- for file_name in files_that_should_trigger_all_tests:
- self.assertFalse(re.match(key, file_name))
+ all_jobs = self.generate_all_tests()
+
+ # Replacing _get_changed_files function to allow specifying changed files in filter_tests function
+ def _get_changed_files(foo):
+ return changed_files
+
+ filter_pull_request_tests._get_changed_files = _get_changed_files
+ print()
+ filtered_jobs = filter_pull_request_tests.filter_tests(all_jobs, "test")
+
+ # Make sure sanity tests aren't being filtered out
+ sanity_tests_in_all_jobs = 0
+ sanity_tests_in_filtered_jobs = 0
+ for job in all_jobs:
+ if "sanity" in job.labels:
+ sanity_tests_in_all_jobs += 1
+ all_jobs = [job for job in all_jobs if "sanity" not in job.labels]
+ for job in filtered_jobs:
+ if "sanity" in job.labels:
+ sanity_tests_in_filtered_jobs += 1
+ filtered_jobs = [
+ job for job in filtered_jobs if "sanity" not in job.labels
+ ]
+ self.assertEquals(sanity_tests_in_all_jobs,
+ sanity_tests_in_filtered_jobs)
+
+ for label in labels:
+ for job in filtered_jobs:
+ self.assertNotIn(label, job.labels)
+
+ jobs_matching_labels = 0
+ for label in labels:
+ for job in all_jobs:
+ if (label in job.labels):
+ jobs_matching_labels += 1
+ self.assertEquals(
+ len(filtered_jobs), len(all_jobs) - jobs_matching_labels)
+
+ def test_individual_language_filters(self):
+ # Changing unlisted file should trigger all languages
+ self.test_filtering(['ffffoo/bar.baz'], [_LIST_OF_LANGUAGE_LABELS])
+ # Changing core should trigger all tests
+ self.test_filtering(['src/core/foo.bar'], [_LIST_OF_LANGUAGE_LABELS])
+ # Testing individual languages
+ self.test_filtering(['test/core/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CORE_TEST_SUITE.labels +
+ filter_pull_request_tests._CPP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/cpp/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/csharp/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CSHARP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/objective-c/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._OBJC_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/php/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._PHP_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/python/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._PYTHON_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/ruby/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._RUBY_TEST_SUITE.labels
+ ])
+
+ def test_combined_language_filters(self):
+ self.test_filtering(['src/cpp/foo.bar', 'test/core/foo.bar'], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels and
+ label not in filter_pull_request_tests._CORE_TEST_SUITE.labels
+ ])
+ self.test_filtering(['src/cpp/foo.bar', "src/csharp/foo.bar"], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._CPP_TEST_SUITE.labels and
+ label not in filter_pull_request_tests._CSHARP_TEST_SUITE.labels
+ ])
+ self.test_filtering([
+ 'src/objective-c/foo.bar', 'src/php/foo.bar', "src/python/foo.bar",
+ "src/ruby/foo.bar"
+ ], [
+ label for label in _LIST_OF_LANGUAGE_LABELS
+ if label not in filter_pull_request_tests._OBJC_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._PHP_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._PYTHON_TEST_SUITE.labels
+ and label not in filter_pull_request_tests._RUBY_TEST_SUITE.labels
+ ])
+
+ def test_platform_filter(self):
+ self.test_filtering(['vsprojects/foo.bar'], [
+ label for label in _LIST_OF_PLATFORM_LABELS
+ if label not in filter_pull_request_tests._WINDOWS_TEST_SUITE.labels
+ ])
+
+ def test_whitelist(self):
+ whitelist = filter_pull_request_tests._WHITELIST_DICT
+ files_that_should_trigger_all_tests = [
+ 'src/core/foo.bar', 'some_file_not_on_the_white_list', 'BUILD',
+ 'etc/roots.pem', 'Makefile', 'tools/foo'
+ ]
+ for key in whitelist.keys():
+ for file_name in files_that_should_trigger_all_tests:
+ self.assertFalse(re.match(key, file_name))
+
if __name__ == '__main__':
- unittest.main(verbosity=2)
+ unittest.main(verbosity=2)
diff --git a/tools/run_tests/sanity/check_tracer_sanity.py b/tools/run_tests/sanity/check_tracer_sanity.py
index 997ec79d02..c4c76530de 100755
--- a/tools/run_tests/sanity/check_tracer_sanity.py
+++ b/tools/run_tests/sanity/check_tracer_sanity.py
@@ -26,21 +26,22 @@ errors = 0
tracers = []
pattern = re.compile("GRPC_TRACER_INITIALIZER\((true|false), \"(.*)\"\)")
for root, dirs, files in os.walk('src/core'):
- for filename in files:
- path = os.path.join(root, filename)
- if os.path.splitext(path)[1] != '.c': continue
- with open(path) as f:
- text = f.read()
- for o in pattern.findall(text):
- tracers.append(o[1])
+ for filename in files:
+ path = os.path.join(root, filename)
+ if os.path.splitext(path)[1] != '.c': continue
+ with open(path) as f:
+ text = f.read()
+ for o in pattern.findall(text):
+ tracers.append(o[1])
with open('doc/environment_variables.md') as f:
- text = f.read()
+ text = f.read()
for t in tracers:
if t not in text:
- print("ERROR: tracer \"%s\" is not mentioned in doc/environment_variables.md" % t)
+ print(
+ "ERROR: tracer \"%s\" is not mentioned in doc/environment_variables.md"
+ % t)
errors += 1
-
assert errors == 0
diff --git a/tools/run_tests/sanity/check_version.py b/tools/run_tests/sanity/check_version.py
index b9b6bab26d..6154b2603e 100755
--- a/tools/run_tests/sanity/check_version.py
+++ b/tools/run_tests/sanity/check_version.py
@@ -31,56 +31,56 @@ sys.path.insert(0, os.path.abspath('tools/buildgen/plugins'))
from expand_version import Version
try:
- branch_name = subprocess.check_output(
- 'git rev-parse --abbrev-ref HEAD',
- shell=True)
+ branch_name = subprocess.check_output(
+ 'git rev-parse --abbrev-ref HEAD', shell=True)
except:
- print('WARNING: not a git repository')
- branch_name = None
+ print('WARNING: not a git repository')
+ branch_name = None
if branch_name is not None:
- m = re.match(r'^release-([0-9]+)_([0-9]+)$', branch_name)
- if m:
- print('RELEASE branch')
- # version number should align with the branched version
- check_version = lambda version: (
- version.major == int(m.group(1)) and
- version.minor == int(m.group(2)))
- warning = 'Version key "%%s" value "%%s" should have a major version %s and minor version %s' % (m.group(1), m.group(2))
- elif re.match(r'^debian/.*$', branch_name):
- # no additional version checks for debian branches
- check_version = lambda version: True
- else:
- # all other branches should have a -dev tag
- check_version = lambda version: version.tag == 'dev'
- warning = 'Version key "%s" value "%s" should have a -dev tag'
+ m = re.match(r'^release-([0-9]+)_([0-9]+)$', branch_name)
+ if m:
+ print('RELEASE branch')
+ # version number should align with the branched version
+ check_version = lambda version: (
+ version.major == int(m.group(1)) and
+ version.minor == int(m.group(2)))
+ warning = 'Version key "%%s" value "%%s" should have a major version %s and minor version %s' % (
+ m.group(1), m.group(2))
+ elif re.match(r'^debian/.*$', branch_name):
+ # no additional version checks for debian branches
+ check_version = lambda version: True
+ else:
+ # all other branches should have a -dev tag
+ check_version = lambda version: version.tag == 'dev'
+ warning = 'Version key "%s" value "%s" should have a -dev tag'
else:
- check_version = lambda version: True
+ check_version = lambda version: True
with open('build.yaml', 'r') as f:
- build_yaml = yaml.load(f.read())
+ build_yaml = yaml.load(f.read())
settings = build_yaml['settings']
top_version = Version(settings['version'])
if not check_version(top_version):
- errors += 1
- print(warning % ('version', top_version))
+ errors += 1
+ print(warning % ('version', top_version))
for tag, value in settings.iteritems():
- if re.match(r'^[a-z]+_version$', tag):
- value = Version(value)
- if tag != 'core_version':
- if value.major != top_version.major:
- errors += 1
- print('major version mismatch on %s: %d vs %d' % (tag, value.major,
- top_version.major))
- if value.minor != top_version.minor:
- errors += 1
- print('minor version mismatch on %s: %d vs %d' % (tag, value.minor,
- top_version.minor))
- if not check_version(value):
- errors += 1
- print(warning % (tag, value))
+ if re.match(r'^[a-z]+_version$', tag):
+ value = Version(value)
+ if tag != 'core_version':
+ if value.major != top_version.major:
+ errors += 1
+ print('major version mismatch on %s: %d vs %d' %
+ (tag, value.major, top_version.major))
+ if value.minor != top_version.minor:
+ errors += 1
+ print('minor version mismatch on %s: %d vs %d' %
+ (tag, value.minor, top_version.minor))
+ if not check_version(value):
+ errors += 1
+ print(warning % (tag, value))
sys.exit(errors)
diff --git a/tools/run_tests/sanity/core_banned_functions.py b/tools/run_tests/sanity/core_banned_functions.py
index 1f13905484..9ee28964a5 100755
--- a/tools/run_tests/sanity/core_banned_functions.py
+++ b/tools/run_tests/sanity/core_banned_functions.py
@@ -36,26 +36,28 @@ BANNED_EXCEPT = {
'grpc_wsa_error(': ['src/core/lib/iomgr/error.c'],
'grpc_log_if_error(': ['src/core/lib/iomgr/error.c'],
'grpc_slice_malloc(': ['src/core/lib/slice/slice.c'],
- 'grpc_closure_create(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_init(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_sched(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_run(' : ['src/core/lib/iomgr/closure.c'],
- 'grpc_closure_list_sched(' : ['src/core/lib/iomgr/closure.c'],
- 'gpr_getenv_silent(' : ['src/core/lib/support/log.c', 'src/core/lib/support/env_linux.c',
- 'src/core/lib/support/env_posix.c', 'src/core/lib/support/env_windows.c'],
+ 'grpc_closure_create(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_init(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_sched(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_run(': ['src/core/lib/iomgr/closure.c'],
+ 'grpc_closure_list_sched(': ['src/core/lib/iomgr/closure.c'],
+ 'gpr_getenv_silent(': [
+ 'src/core/lib/support/log.c', 'src/core/lib/support/env_linux.c',
+ 'src/core/lib/support/env_posix.c', 'src/core/lib/support/env_windows.c'
+ ],
}
errors = 0
for root, dirs, files in os.walk('src/core'):
- for filename in files:
- path = os.path.join(root, filename)
- if os.path.splitext(path)[1] != '.c': continue
- with open(path) as f:
- text = f.read()
- for banned, exceptions in BANNED_EXCEPT.items():
- if path in exceptions: continue
- if banned in text:
- print('Illegal use of "%s" in %s' % (banned, path))
- errors += 1
+ for filename in files:
+ path = os.path.join(root, filename)
+ if os.path.splitext(path)[1] != '.c': continue
+ with open(path) as f:
+ text = f.read()
+ for banned, exceptions in BANNED_EXCEPT.items():
+ if path in exceptions: continue
+ if banned in text:
+ print('Illegal use of "%s" in %s' % (banned, path))
+ errors += 1
assert errors == 0