bt_test.py (1381B)
1 # Copyright 2013-2019, The Tor Project, Inc 2 # See LICENSE for licensing information 3 4 """ 5 bt_test.py 6 7 This file tests the output from test-bt-cl to make sure it's as expected. 8 9 Example usage: 10 11 $ ./src/test/test-bt-cl crash | ./src/test/bt_test.py 12 OK 13 $ ./src/test/test-bt-cl assert | ./src/test/bt_test.py 14 OK 15 16 """ 17 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 22 23 import sys 24 25 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 36 37 FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split() 38 39 LINES = sys.stdin.readlines() 40 41 for I in range(len(LINES)): 42 if matches(LINES[I:], FUNCNAMES): 43 print("OK") 44 sys.exit(0) 45 46 print("BAD") 47 48 for l in LINES: 49 print("{}".format(l), end="") 50 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) 58 59 sys.exit(1)