[Lldb-commits] [lldb] r251460 - Preparation for turning lldbsuite into a Python package.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 27 15:33:47 PDT 2015
Author: zturner
Date: Tue Oct 27 17:33:47 2015
New Revision: 251460
URL: http://llvm.org/viewvc/llvm-project?rev=251460&view=rev
Log:
Preparation for turning lldbsuite into a Python package.
The idea behind this patch is to expose the meat of
LLDB's Python infrastructure (test suite, scripts, etc)
as a single package. This makes reusability and code
sharing among sub-packages easy.
Differential Revision: http://reviews.llvm.org/D14131
Added:
lldb/trunk/packages/
lldb/trunk/packages/Python/
lldb/trunk/packages/Python/lldbsuite/
lldb/trunk/packages/Python/lldbsuite/__init__.py
- copied, changed from r251457, lldb/trunk/test/use_lldb_suite.py
lldb/trunk/packages/Python/lldbsuite/test/
lldb/trunk/packages/Python/lldbsuite/test/__init__.py
lldb/trunk/third_party/Python/module/progress/
lldb/trunk/third_party/Python/module/progress/progress.py (contents, props changed)
- copied, changed from r251457, lldb/trunk/test/progress.py
Removed:
lldb/trunk/test/progress.py
Modified:
lldb/trunk/test/dosep.py
lldb/trunk/test/dotest.py
lldb/trunk/test/use_lldb_suite.py
lldb/trunk/use_lldb_suite_root.py
Copied: lldb/trunk/packages/Python/lldbsuite/__init__.py (from r251457, lldb/trunk/test/use_lldb_suite.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/__init__.py?p2=lldb/trunk/packages/Python/lldbsuite/__init__.py&p1=lldb/trunk/test/use_lldb_suite.py&r1=251457&r2=251460&rev=251460&view=diff
==============================================================================
--- lldb/trunk/test/use_lldb_suite.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/__init__.py Tue Oct 27 17:33:47 2015
@@ -1,22 +1,20 @@
-import inspect
-import os
-import sys
-
-def find_lldb_root():
- lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
- while True:
- lldb_root = os.path.dirname(lldb_root)
- if lldb_root is None:
- return None
-
- test_path = os.path.join(lldb_root, "lldb.root")
- if os.path.isfile(test_path):
- return lldb_root
- return None
-
-lldb_root = find_lldb_root()
-if lldb_root is not None:
- import imp
- module = imp.find_module("use_lldb_suite_root", [lldb_root])
- if module is not None:
- imp.load_module("use_lldb_suite_root", *module)
\ No newline at end of file
+# Module level initialization for the `lldbsuite` module.
+
+import inspect
+import os
+import sys
+
+def find_lldb_root():
+ lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+ while True:
+ lldb_root = os.path.dirname(lldb_root)
+ if lldb_root is None:
+ return None
+
+ test_path = os.path.join(lldb_root, "lldb.root")
+ if os.path.isfile(test_path):
+ return lldb_root
+ return None
+
+# lldbsuite.lldb_root refers to the root of the git/svn source checkout
+lldb_root = find_lldb_root()
Added: lldb/trunk/packages/Python/lldbsuite/test/__init__.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/__init__.py?rev=251460&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/__init__.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/__init__.py Tue Oct 27 17:33:47 2015
@@ -0,0 +1 @@
+# Module level initialization for the `lldbsuite.test` module.
Modified: lldb/trunk/test/dosep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=251460&r1=251459&r2=251460&view=diff
==============================================================================
--- lldb/trunk/test/dosep.py (original)
+++ lldb/trunk/test/dosep.py Tue Oct 27 17:33:47 2015
@@ -1205,7 +1205,7 @@ def adjust_inferior_options(dotest_argv)
# every dotest invocation from creating its own directory
import datetime
# The windows platforms don't like ':' in the pathname.
- timestamp_started = datetime.datetime.now().strftime("%F-%H_%M_%S")
+ timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
dotest_argv.append('-s')
dotest_argv.append(timestamp_started)
dotest_options.s = timestamp_started
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=251460&r1=251459&r2=251460&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Tue Oct 27 17:33:47 2015
@@ -1048,6 +1048,8 @@ def setupSysPath():
# Set up the LLDB_SRC environment variable, so that the tests can locate
# the LLDB source code.
+ # When this changes over to a package instead of a standalone script, this
+ # will be `lldbsuite.lldb_root`
os.environ["LLDB_SRC"] = os.path.join(scriptPath, os.pardir)
pluginPath = os.path.join(scriptPath, 'plugins')
@@ -1063,6 +1065,8 @@ def setupSysPath():
# to "import lldbgdbserverutils" from the lldb-server tests
# This is the root of the lldb git/svn checkout
+ # When this changes over to a package instead of a standalone script, this
+ # will be `lldbsuite.lldb_root`
lldbRootDirectory = os.path.abspath(os.path.join(scriptPath, os.pardir))
# Some of the tests can invoke the 'lldb' command directly.
@@ -1294,6 +1298,7 @@ def visit(prefix, dir, names):
def disabledynamics():
+ import lldb
ci = lldb.DBG.GetCommandInterpreter()
res = lldb.SBCommandReturnObject()
ci.HandleCommand("setting set target.prefer-dynamic-value no-dynamic-values", res, False)
@@ -1301,6 +1306,7 @@ def disabledynamics():
raise Exception('disabling dynamic type support failed')
def lldbLoggings():
+ import lldb
"""Check and do lldb loggings if necessary."""
# Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is
@@ -1366,6 +1372,7 @@ def checkDsymForUUIDIsNotOn():
sys.exit(0)
def exitTestSuite(exitCode = None):
+ import lldb
lldb.SBDebugger.Terminate()
if exitCode:
sys.exit(exitCode)
@@ -1378,7 +1385,58 @@ def isMultiprocessTestRunner():
# test runner
return not (is_inferior_test_runner or no_multiprocess_test_runner)
-if __name__ == "__main__":
+def run_suite():
+ global just_do_benchmarks_test
+ global dont_do_dsym_test
+ global dont_do_dwarf_test
+ global dont_do_dwo_test
+ global blacklist
+ global blacklistConfig
+ global categoriesList
+ global validCategories
+ global useCategories
+ global skipCategories
+ global lldbFrameworkPath
+ global configFile
+ global archs
+ global compilers
+ global count
+ global dumpSysPath
+ global bmExecutable
+ global bmBreakpointSpec
+ global bmIterationCount
+ global failed
+ global failfast
+ global filters
+ global fs4all
+ global ignore
+ global progress_bar
+ global runHooks
+ global skip_build_and_cleanup
+ global skip_long_running_test
+ global noHeaders
+ global parsable
+ global regexp
+ global rdir
+ global sdir_name
+ global svn_silent
+ global verbose
+ global testdirs
+ global lldb_platform_name
+ global lldb_platform_url
+ global lldb_platform_working_dir
+ global setCrashInfoHook
+ global is_inferior_test_runner
+ global multiprocess_test_subdir
+ global num_threads
+ global output_on_success
+ global no_multiprocess_test_runner
+ global test_runner_name
+ global results_filename
+ global results_formatter_name
+ global results_formatter_options
+ global results_port
+
# On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
# does not exist before proceeding to running the test suite.
if sys.platform.startswith("darwin"):
@@ -1976,3 +2034,6 @@ if __name__ == "__main__":
# Exiting.
exitTestSuite(failed)
+
+if __name__ == "__main__":
+ run_suite()
\ No newline at end of file
Removed: lldb/trunk/test/progress.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/progress.py?rev=251459&view=auto
==============================================================================
--- lldb/trunk/test/progress.py (original)
+++ lldb/trunk/test/progress.py (removed)
@@ -1,154 +0,0 @@
-#!/usr/bin/python
-
-from __future__ import print_function
-
-import use_lldb_suite
-import six
-
-import sys
-import time
-
-class ProgressBar(object):
- """ProgressBar class holds the options of the progress bar.
- The options are:
- start State from which start the progress. For example, if start is
- 5 and the end is 10, the progress of this state is 50%
- end State in which the progress has terminated.
- width --
- fill String to use for "filled" used to represent the progress
- blank String to use for "filled" used to represent remaining space.
- format Format
- incremental
- """
- light_block = six.unichr(0x2591).encode("utf-8")
- solid_block = six.unichr(0x2588).encode("utf-8")
- solid_right_arrow = six.unichr(0x25BA).encode("utf-8")
-
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
- incremental=True):
- super(ProgressBar, self).__init__()
-
- self.start = start
- self.end = end
- self.width = width
- self.fill = fill
- self.blank = blank
- self.marker = marker
- self.format = format
- self.incremental = incremental
- self.step = 100 / float(width) #fix
- self.reset()
-
- def __add__(self, increment):
- increment = self._get_progress(increment)
- if 100 > self.progress + increment:
- self.progress += increment
- else:
- self.progress = 100
- return self
-
- def complete(self):
- self.progress = 100
- return self
-
- def __str__(self):
- progressed = int(self.progress / self.step) #fix
- fill = progressed * self.fill
- blank = (self.width - progressed) * self.blank
- return self.format % {'fill': fill, 'blank': blank, 'marker': self.marker, 'progress': int(self.progress)}
-
- __repr__ = __str__
-
- def _get_progress(self, increment):
- return float(increment * 100) / self.end
-
- def reset(self):
- """Resets the current progress to the start point"""
- self.progress = self._get_progress(self.start)
- return self
-
-
-class AnimatedProgressBar(ProgressBar):
- """Extends ProgressBar to allow you to use it straighforward on a script.
- Accepts an extra keyword argument named `stdout` (by default use sys.stdout)
- and may be any file-object to which send the progress status.
- """
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
- incremental=True,
- stdout=sys.stdout):
- super(AnimatedProgressBar, self).__init__(start,end,width,fill,blank,marker,format,incremental)
- self.stdout = stdout
-
- def show_progress(self):
- if hasattr(self.stdout, 'isatty') and self.stdout.isatty():
- self.stdout.write('\r')
- else:
- self.stdout.write('\n')
- self.stdout.write(str(self))
- self.stdout.flush()
-
-class ProgressWithEvents(AnimatedProgressBar):
- """Extends AnimatedProgressBar to allow you to track a set of events that
- cause the progress to move. For instance, in a deletion progress bar, you
- can track files that were nuked and files that the user doesn't have access to
- """
- def __init__(self,
- start=0,
- end=10,
- width=12,
- fill=six.unichr(0x25C9).encode("utf-8"),
- blank=six.unichr(0x25CC).encode("utf-8"),
- marker=six.unichr(0x25CE).encode("utf-8"),
- format='[%(fill)s%(marker)s%(blank)s] %(progress)s%%',
- incremental=True,
- stdout=sys.stdout):
- super(ProgressWithEvents, self).__init__(start,end,width,fill,blank,marker,format,incremental,stdout)
- self.events = {}
-
- def add_event(self,event):
- if event in self.events:
- self.events[event] += 1
- else:
- self.events[event] = 1
-
- def show_progress(self):
- isatty = hasattr(self.stdout, 'isatty') and self.stdout.isatty()
- if isatty:
- self.stdout.write('\r')
- else:
- self.stdout.write('\n')
- self.stdout.write(str(self))
- if len(self.events) == 0:
- return
- self.stdout.write('\n')
- for key in list(self.events.keys()):
- self.stdout.write(str(key) + ' = ' + str(self.events[key]) + ' ')
- if isatty:
- self.stdout.write('\033[1A')
- self.stdout.flush()
-
-
-if __name__ == '__main__':
- p = AnimatedProgressBar(end=200, width=200)
-
- while True:
- p + 5
- p.show_progress()
- time.sleep(0.3)
- if p.progress == 100:
- break
- print() #new line
\ No newline at end of file
Modified: lldb/trunk/test/use_lldb_suite.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/use_lldb_suite.py?rev=251460&r1=251459&r2=251460&view=diff
==============================================================================
--- lldb/trunk/test/use_lldb_suite.py (original)
+++ lldb/trunk/test/use_lldb_suite.py Tue Oct 27 17:33:47 2015
@@ -19,4 +19,4 @@ if lldb_root is not None:
import imp
module = imp.find_module("use_lldb_suite_root", [lldb_root])
if module is not None:
- imp.load_module("use_lldb_suite_root", *module)
\ No newline at end of file
+ imp.load_module("use_lldb_suite_root", *module)
Copied: lldb/trunk/third_party/Python/module/progress/progress.py (from r251457, lldb/trunk/test/progress.py)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/third_party/Python/module/progress/progress.py?p2=lldb/trunk/third_party/Python/module/progress/progress.py&p1=lldb/trunk/test/progress.py&r1=251457&r2=251460&rev=251460&view=diff
==============================================================================
(empty)
Modified: lldb/trunk/use_lldb_suite_root.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/use_lldb_suite_root.py?rev=251460&r1=251459&r2=251460&view=diff
==============================================================================
--- lldb/trunk/use_lldb_suite_root.py (original)
+++ lldb/trunk/use_lldb_suite_root.py Tue Oct 27 17:33:47 2015
@@ -11,5 +11,12 @@ def add_third_party_module_dirs(lldb_roo
for module_dir in module_dirs:
module_dir = os.path.join(third_party_modules_dir, module_dir)
sys.path.insert(0, module_dir)
+
+def add_lldbsuite_packages_dir(lldb_root):
+ packages_dir = os.path.join(lldb_root, "packages", "Python")
+ sys.path.insert(0, packages_dir)
+
lldb_root = os.path.dirname(inspect.getfile(inspect.currentframe()))
+
add_third_party_module_dirs(lldb_root)
+add_lldbsuite_packages_dir(lldb_root)
More information about the lldb-commits
mailing list