2015-10-28 06:54:46 +08:00
|
|
|
# Module level initialization for the `lldbsuite` module.
|
|
|
|
|
|
|
|
import inspect
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-10-28 06:54:46 +08:00
|
|
|
def find_lldb_root():
|
|
|
|
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
|
|
|
|
while True:
|
[lldb][test] Prevent infinite loop while looking for use_lldb_suite_root.py.
Several scripts (two copies of use_lldb_suite.py, and an __init__.py) look for use_lldb_suite_root.py by checking parent directories. If for some reason it doesn't exist, it keeps checking parent directories until it finds it.
However, this only breaks when the parent directory is None, but at least on Linux, dirname('/') == '/', so this will never be None.
This changes the lookup to stop if the dirname(lldb_root) is unchanged. This was previously fixed in 67f6d842fab6d3ac8c949721be8e131cf6b17578, but only in one copy of this script.
Additionally, this makes the failure mode more visible -- if the root is not found, it complains loudly instead of silently failing, and having later modules that need lldb_root fail.
Differential Revision: https://reviews.llvm.org/D83840
2020-07-16 00:16:30 +08:00
|
|
|
parent = os.path.dirname(lldb_root)
|
|
|
|
if parent == lldb_root: # dirname('/') == '/'
|
|
|
|
raise Exception("use_lldb_suite_root.py not found")
|
|
|
|
lldb_root = parent
|
2015-10-28 06:54:46 +08:00
|
|
|
|
2015-11-21 01:40:57 +08:00
|
|
|
test_path = os.path.join(lldb_root, "use_lldb_suite_root.py")
|
2015-10-28 06:54:46 +08:00
|
|
|
if os.path.isfile(test_path):
|
|
|
|
return lldb_root
|
|
|
|
|
|
|
|
# lldbsuite.lldb_root refers to the root of the git/svn source checkout
|
|
|
|
lldb_root = find_lldb_root()
|
2015-12-07 14:19:48 +08:00
|
|
|
|
2020-02-08 07:13:38 +08:00
|
|
|
# lldbsuite.lldb_test_src_root refers to the root of the python test case tree
|
|
|
|
# (i.e. the actual unit tests).
|
2020-02-12 02:01:16 +08:00
|
|
|
lldb_test_root = os.path.join(lldb_root, "test", "API")
|