bt_test.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright 2013-2015, 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'):
  34. # See bug #17808 if you know how to fix this.
  35. print("Test failed; but FreeBSD is known to have backtrace problems.\n"
  36. "Treating as 'SKIP'.")
  37. sys.exit(77)
  38. sys.exit(1)