bt_test.py 856 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. for l in LINES:
  31. print("{}".format(l), end="")
  32. sys.exit(1)