TOR_VEGAS: Implement Prop#324 TOR_VEGAS.
[tor.git] / src / test / bt_test.py
blobd728f13596368668b21109cada122778a393607b
1 # Copyright 2013-2019, The Tor Project, Inc
2 # See LICENSE for licensing information
4 """
5 bt_test.py
7 This file tests the output from test-bt-cl to make sure it's as expected.
9 Example usage:
11 $ ./src/test/test-bt-cl crash | ./src/test/bt_test.py
13 $ ./src/test/test-bt-cl assert | ./src/test/bt_test.py
16 """
18 # Future imports for Python 2.7, mandatory in 3.0
19 from __future__ import division
20 from __future__ import print_function
21 from __future__ import unicode_literals
23 import sys
26 def matches(lines, funcs):
27 if len(lines) < len(funcs):
28 return False
29 try:
30 for l, f in zip(lines, funcs):
31 l.index(f)
32 except ValueError:
33 return False
34 else:
35 return True
37 FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split()
39 LINES = sys.stdin.readlines()
41 for I in range(len(LINES)):
42 if matches(LINES[I:], FUNCNAMES):
43 print("OK")
44 sys.exit(0)
46 print("BAD")
48 for l in LINES:
49 print("{}".format(l), end="")
51 if (sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd') or
52 sys.platform.startswith('openbsd') or sys.platform.startswith('darwin')):
53 # See bug #17808 if you know how to fix backtraces on BSD-derived systems
54 print("Test failed; but {} is known to have backtrace problems."
55 .format(sys.platform))
56 print("Treating as 'SKIP'.")
57 sys.exit(77)
59 sys.exit(1)