diff --git a/lldb/test/API/use_lldb_suite.py b/lldb/test/API/use_lldb_suite.py --- a/lldb/test/API/use_lldb_suite.py +++ b/lldb/test/API/use_lldb_suite.py @@ -7,22 +7,25 @@ lldb_root = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe())) ) + # On Linux, dirname('/') == '/', so we keep looking in parent directories + # until the parent directory doesn't change. + prev_lldb_root = None while True: + prev_lldb_root = lldb_root lldb_root = os.path.dirname(lldb_root) - if lldb_root is None: - return None + if lldb_root is None or lldb_root == prev_lldb_root: + raise Exception("use_lldb_suite_root.py not found") test_path = os.path.join(lldb_root, "use_lldb_suite_root.py") if os.path.isfile(test_path): return lldb_root - return None lldb_root = find_lldb_root() -if lldb_root is not None: - import imp - fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) - try: - imp.load_module("use_lldb_suite_root", fp, pathname, desc) - finally: - if fp: - fp.close() + +import imp +fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root]) +try: + imp.load_module("use_lldb_suite_root", fp, pathname, desc) +finally: + if fp: + fp.close()