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.dirname(inspect.getfile(inspect.currentframe()))
10    while True:
11        parent = os.path.dirname(lldb_root)
12        if parent == lldb_root: # dirname('/') == '/'
13            raise Exception("use_lldb_suite_root.py not found")
14        lldb_root = parent
15
16        test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
17        if os.path.isfile(test_path):
18            return lldb_root
19
20# lldbsuite.lldb_root refers to the root of the git/svn source checkout
21lldb_root = find_lldb_root()
22
23# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
24# (i.e. the actual unit tests).
25lldb_test_root = os.path.join(lldb_root, "test", "API")
26