check_tracer_sanity.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # Copyright 2017 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import os
  16. import re
  17. import sys
  18. os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
  19. errors = 0
  20. tracers = []
  21. pattern = re.compile("GRPC_TRACER_INITIALIZER\((true|false), \"(.*)\"\)")
  22. for root, dirs, files in os.walk('src/core'):
  23. for filename in files:
  24. path = os.path.join(root, filename)
  25. if os.path.splitext(path)[1] != '.c':
  26. continue
  27. with open(path) as f:
  28. text = f.read()
  29. for o in pattern.findall(text):
  30. tracers.append(o[1])
  31. with open('doc/environment_variables.md') as f:
  32. text = f.read()
  33. for t in tracers:
  34. if t not in text:
  35. print((
  36. "ERROR: tracer \"%s\" is not mentioned in doc/environment_variables.md"
  37. % t))
  38. errors += 1
  39. assert errors == 0