bt_test.py 767 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright 2013, 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. import sys
  13. def matches(lines, funcs):
  14. if len(lines) < len(funcs):
  15. return False
  16. try:
  17. for l, f in zip(lines, funcs):
  18. l.index(f)
  19. except ValueError:
  20. return False
  21. else:
  22. return True
  23. FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split()
  24. LINES = sys.stdin.readlines()
  25. for I in range(len(LINES)):
  26. if matches(LINES[I:], FUNCNAMES):
  27. print("OK")
  28. break
  29. else:
  30. print("BAD")