bt_test.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2013-2018, The Tor Project, Inc
  2. # See LICENSE for licensing information
  3. """
  4. bt_test.py
  5. This file tests the output from test-bt-cl to make sure it's as expected.
  6. Example usage:
  7. $ ./src/test/test-bt-cl crash | ./src/test/bt_test.py
  8. OK
  9. $ ./src/test/test-bt-cl assert | ./src/test/bt_test.py
  10. OK
  11. """
  12. from __future__ import print_function
  13. import sys
  14. def matches(lines, funcs):
  15. if len(lines) < len(funcs):
  16. return False
  17. try:
  18. for l, f in zip(lines, funcs):
  19. l.index(f)
  20. except ValueError:
  21. return False
  22. else:
  23. return True
  24. FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split()
  25. LINES = sys.stdin.readlines()
  26. for I in range(len(LINES)):
  27. if matches(LINES[I:], FUNCNAMES):
  28. print("OK")
  29. sys.exit(0)
  30. print("BAD")
  31. for l in LINES:
  32. print("{}".format(l), end="")
  33. if (sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd') or
  34. sys.platform.startswith('openbsd') or sys.platform.startswith('darwin')):
  35. # See bug #17808 if you know how to fix backtraces on BSD-derived systems
  36. print("Test failed; but {} is known to have backtrace problems."
  37. .format(sys.platform))
  38. print("Treating as 'SKIP'.")
  39. sys.exit(77)
  40. sys.exit(1)