bt_test.py 1.23 KB
Newer Older
1
# Copyright 2013-2015, The Tor Project, Inc
Nick Mathewson's avatar
Nick Mathewson committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# See LICENSE for licensing information

"""
bt_test.py

This file tests the output from test-bt-cl to make sure it's as expected.

Example usage:

$ ./src/test/test-bt-cl crash | ./src/test/bt_test.py
OK
$ ./src/test/test-bt-cl assert | ./src/test/bt_test.py
OK

"""

18
from __future__ import print_function
Nick Mathewson's avatar
Nick Mathewson committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys


def matches(lines, funcs):
    if len(lines) < len(funcs):
        return False
    try:
        for l, f in zip(lines, funcs):
            l.index(f)
    except ValueError:
        return False
    else:
        return True

FUNCNAMES = "crash oh_what a_tangled_web we_weave main".split()

LINES = sys.stdin.readlines()

for I in range(len(LINES)):
    if matches(LINES[I:], FUNCNAMES):
39
        print("OK")
40
        sys.exit(0)
41

42
43
print("BAD")

44
45
46
for l in LINES:
    print("{}".format(l), end="")

47
48
49
50
51
52
if (sys.platform.startswith('freebsd') or sys.platform.startswith('netbsd') or
    sys.platform.startswith('openbsd') or sys.platform.startswith('darwin')):
    # See bug #17808 if you know how to fix backtraces on BSD-derived systems
    print("Test failed; but {} is known to have backtrace problems."
          .format(sys.platform))
    print("Treating as 'SKIP'.")
53
54
    sys.exit(77)

55
sys.exit(1)