1# Module level initialization for the `lldbsuite` module.
2
3import inspect
4import os
5import sys
6
7
8def find_lldb_root():
9    lldb_root = os.path.realpath(
10        os.path.dirname(inspect.getfile(inspect.currentframe())))
11    while True:
12        parent = os.path.dirname(lldb_root)
13        if parent == lldb_root: # dirname('/') == '/'
14            raise Exception("use_lldb_suite_root.py not found")
15        lldb_root = parent
16
17        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
18        if os.path.isfile(test_path):
19            return lldb_root
20
21# lldbsuite.lldb_root refers to the root of the git/svn source checkout
22lldb_root = find_lldb_root()
23
24# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
25# (i.e. the actual unit tests).
26lldb_test_root = os.path.join(lldb_root, "test", "API")
27