[Lldb-commits] [lldb] r285542 - [Test Suite] Pull generateSource into lldbtest
Author: cbieneman Date: Sun Oct 30 23:48:19 2016 New Revision: 285542 URL: http://llvm.org/viewvc/llvm-project?rev=285542&view=rev Log: [Test Suite] Pull generateSource into lldbtest Summary: Convert tests using LLDB headers to use generateSource to put the right include paths in place regardless of whether or not you're building a framework. This also abstracted generateSource out of TestPublicAPIHeaders.py into lldbtest.py. Reviewers: tfiala, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D25887 Added: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template - copied, changed from r285541, lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp Removed: lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/listener_test.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/lldb-headers.h lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_breakpoint_callback.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_description.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_event_process_state.cpp lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/test_listener_resume.cpp lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/plugins/commands/TestPluginCommands.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Modified: lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py?rev=285542&r1=285541&r2=285542&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/api/check_public_api_headers/TestPublicAPIHeaders.py Sun Oct 30 23:48:19 2016 @@ -19,9 +19,9 @@ class SBDirCheckerCase(TestBase): def setUp(self): TestBase.setUp(self) -self.template = 'main.cpp.template' self.source = 'main.cpp' self.exe_name = 'a.out' +self.generateSource(self.source) @skipIfNoSBHeaders def test_sb_api_directory(self): @@ -34,40 +34,9 @@ class SBDirCheckerCase(TestBase): self.skipTest( "LLDB is 64-bit and cannot be linked to 32-bit test program.") -# Generate main.cpp, build it, and execute. -self.generate_main_cpp() self.buildDriver(self.source, self.exe_name) self.sanity_check_executable(self.exe_name) -def generate_main_cpp(self): -"""Generate main.cpp from main.cpp.template.""" -temp = os.path.join(os.getcwd(), self.template) -with open(temp, 'r') as f: -content = f.read() - -public_api_dir = os.path.join( -os.environ["LLDB_SRC"], "include", "lldb", "API") - -# Look under the include/lldb/API directory and add #include statements -# for all the SB API headers. -public_headers = os.listdir(public_api_dir) -
[Lldb-commits] [lldb] r285541 - [Test Suite] Properly respect --framework option
Author: cbieneman Date: Sun Oct 30 23:48:10 2016 New Revision: 285541 URL: http://llvm.org/viewvc/llvm-project?rev=285541&view=rev Log: [Test Suite] Properly respect --framework option Summary: dotest.py has a framework option that is not respected. This patch makes the framework path properly configurable via the --framework option. This patch also adds a function to the lldbtest.Base class named "hasDarwinFramework" which allows us to not rely on the host platform to determine if a framework is present. If running on Darwin, and not building a framework, this will follow the *nix code paths which are appropriate for Darwin. Reviewers: tfiala Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D25886 Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/test/CMakeLists.txt Modified: lldb/trunk/packages/Python/lldbsuite/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/dotest.py?rev=285541&r1=285540&r2=285541&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/dotest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/dotest.py Sun Oct 30 23:48:10 2016 @@ -688,7 +688,10 @@ def setupSysPath(): configuration.skipCategories.append("lldb-mi") lldbPythonDir = None # The directory that contains 'lldb/__init__.py' +if os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")): +configuration.lldbFrameworkPath = lldbLibDir if configuration.lldbFrameworkPath: +lldbtest_config.lldbFrameworkPath = configuration.lldbFrameworkPath candidatePath = os.path.join( configuration.lldbFrameworkPath, 'Resources', 'Python') if os.path.isfile(os.path.join(candidatePath, 'lldb/__init__.py')): Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=285541&r1=285540&r2=285541&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Sun Oct 30 23:48:10 2016 @@ -829,6 +829,29 @@ class Base(unittest2.TestCase): # Initialize debug_info self.debug_info = None +lib_dir = os.environ["LLDB_LIB_DIR"] +self.dsym = None +self.framework_dir = None +self.darwinWithFramework = self.platformIsDarwin() +if sys.platform.startswith("darwin"): +# Handle the framework environment variable if it is set +if hasattr(lldbtest_config, 'lldbFrameworkPath'): +framework_path = lldbtest_config.lldbFrameworkPath +# Framework dir should be the directory containing the framework +self.framework_dir = framework_path[:framework_path.rfind('LLDB.framework')] +# If a framework dir was not specified assume the Xcode build +# directory layout where the framework is in LLDB_LIB_DIR. +else: +self.framework_dir = lib_dir +self.dsym = os.path.join(self.framework_dir, 'LLDB.framework', 'LLDB') +# If the framework binary doesn't exist, assume we didn't actually +# build a framework, and fallback to standard *nix behavior by +# setting framework_dir and dsym to None. +if not os.path.exists(self.dsym): +self.framework_dir = None +self.dsym = None +self.darwinWithFramework = False + def setAsync(self, value): """ Sets async mode to True/False and ensures it is reset after the testcase completes.""" old_async = self.dbg.GetAsync() @@ -1276,6 +1299,9 @@ class Base(unittest2.TestCase): """Returns true if the OS triple for the selected platform is any valid apple OS""" return lldbplatformutil.platformIsDarwin() +def hasDarwinFramework(self): +return self.darwinWithFramework + def getPlatform(self): """Returns the target platform the test suite is running on.""" return lldbplatformutil.getPlatform() @@ -1373,15 +1399,14 @@ class Base(unittest2.TestCase): stdlibflag = self.getstdlibFlag() lib_dir = os.environ["LLDB_LIB_DIR"] -if sys.platform.startswith("darwin"): -dsym = os.path.join(lib_dir, 'LLDB.framework', 'LLDB') +if self.hasDarwinFramework(): d = {'CXX_SOURCES': sources, 'EXE': exe_name, 'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag), - 'FRAMEWORK_INCLUDES': "-F%s" % lib_dir, - 'LD_EXTRAS': "%s -Wl,-rpath,%s" % (dsym, lib_dir), + 'FRAMEWORK_INCLUDES': "-F%s" % sel
[Lldb-commits] [PATCH] D25886: [Test Suite] Properly respect --framework option
This revision was automatically updated to reflect the committed changes. Closed by commit rL285541: [Test Suite] Properly respect --framework option (authored by cbieneman). Changed prior to commit: https://reviews.llvm.org/D25886?vs=75505&id=76351#toc Repository: rL LLVM https://reviews.llvm.org/D25886 Files: lldb/trunk/packages/Python/lldbsuite/test/dotest.py lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/test/CMakeLists.txt Index: lldb/trunk/test/CMakeLists.txt === --- lldb/trunk/test/CMakeLists.txt +++ lldb/trunk/test/CMakeLists.txt @@ -89,6 +89,10 @@ list(APPEND LLDB_TEST_COMMON_ARGS --codesign-identity "${LLDB_CODESIGN_IDENTITY}") endif() +if(LLDB_BUILD_FRAMEWORK) + list(APPEND LLDB_TEST_COMMON_ARGS --framework $) +endif() + add_python_test_target(check-lldb-single ${LLDB_SOURCE_DIR}/test/dotest.py "--no-multiprocess;${LLDB_TEST_COMMON_ARGS};${LLDB_TEST_USER_ARGS}" Index: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py === --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py @@ -829,6 +829,29 @@ # Initialize debug_info self.debug_info = None +lib_dir = os.environ["LLDB_LIB_DIR"] +self.dsym = None +self.framework_dir = None +self.darwinWithFramework = self.platformIsDarwin() +if sys.platform.startswith("darwin"): +# Handle the framework environment variable if it is set +if hasattr(lldbtest_config, 'lldbFrameworkPath'): +framework_path = lldbtest_config.lldbFrameworkPath +# Framework dir should be the directory containing the framework +self.framework_dir = framework_path[:framework_path.rfind('LLDB.framework')] +# If a framework dir was not specified assume the Xcode build +# directory layout where the framework is in LLDB_LIB_DIR. +else: +self.framework_dir = lib_dir +self.dsym = os.path.join(self.framework_dir, 'LLDB.framework', 'LLDB') +# If the framework binary doesn't exist, assume we didn't actually +# build a framework, and fallback to standard *nix behavior by +# setting framework_dir and dsym to None. +if not os.path.exists(self.dsym): +self.framework_dir = None +self.dsym = None +self.darwinWithFramework = False + def setAsync(self, value): """ Sets async mode to True/False and ensures it is reset after the testcase completes.""" old_async = self.dbg.GetAsync() @@ -1276,6 +1299,9 @@ """Returns true if the OS triple for the selected platform is any valid apple OS""" return lldbplatformutil.platformIsDarwin() +def hasDarwinFramework(self): +return self.darwinWithFramework + def getPlatform(self): """Returns the target platform the test suite is running on.""" return lldbplatformutil.getPlatform() @@ -1373,24 +1399,23 @@ stdlibflag = self.getstdlibFlag() lib_dir = os.environ["LLDB_LIB_DIR"] -if sys.platform.startswith("darwin"): -dsym = os.path.join(lib_dir, 'LLDB.framework', 'LLDB') +if self.hasDarwinFramework(): d = {'CXX_SOURCES': sources, 'EXE': exe_name, 'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag), - 'FRAMEWORK_INCLUDES': "-F%s" % lib_dir, - 'LD_EXTRAS': "%s -Wl,-rpath,%s" % (dsym, lib_dir), + 'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir, + 'LD_EXTRAS': "%s -Wl,-rpath,%s" % (self.dsym, self.framework_dir), } -elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': +elif sys.platform.rstrip('0123456789') in ('freebsd', 'linux', 'netbsd', 'darwin') or os.environ.get('LLDB_BUILD_TYPE') == 'Makefile': d = { 'CXX_SOURCES': sources, 'EXE': exe_name, 'CFLAGS_EXTRAS': "%s %s -I%s" % (stdflag, stdlibflag, os.path.join( os.environ["LLDB_SRC"], "include")), -'LD_EXTRAS': "-L%s -llldb" % lib_dir} +'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} elif sys.platform.startswith('win'): d = { 'CXX_SOURCES': sources, @@ -1414,23 +1439,22 @@ stdflag = self.getstdFlag() lib_dir = os.environ["LLDB_LIB_DIR"] -if self.platformIsDarwin(): -