"""Test the SB API directory and make sure there's no unwanted stuff."""
# Only proceed if this is an Apple OS, "x86_64", and local platform.
- if not (self.platformIsDarwin() and self.getArchitecture() == "x86_64" and not configuration.test_remote):
- self.skipTest("This test is only for LLDB.framework built 64-bit and !configuration.test_remote")
+ if not (self.platformIsDarwin() and self.getArchitecture() == "x86_64"):
+ self.skipTest("This test is only for LLDB.framework built 64-bit")
if self.getArchitecture() == "i386":
self.skipTest("LLDB is 64-bit and cannot be linked to 32-bit test program.")
# The path to LLDB.framework is optional.
lldbFrameworkPath = None
-# The config file is optional.
-configFile = None
-
# Test suite repeat count. Can be overwritten with '-# count'.
count = 1
-# The dictionary as a result of sourcing configFile.
-config = {}
-# The pre_flight and post_flight functions come from reading a config file.
-pre_flight = None
-post_flight = None
-# So do the lldbtest_remote_sandbox and lldbtest_remote_shell_template variables.
-test_remote = False
-lldbtest_remote_sandbox = None
-lldbtest_remote_shell_template = None
-
-# The 'archs' and 'compilers' can be specified via either command line or configFile,
-# with the command line overriding the configFile. The corresponding options can be
-# specified more than once. For example, "-A x86_64 -A i386" => archs=['x86_64', 'i386']
-# and "-C gcc -C clang" => compilers=['gcc', 'clang'].
+# The 'archs' and 'compilers' can be specified via command line. The corresponding
+# options can be specified more than once. For example, "-A x86_64 -A i386"
+# => archs=['x86_64', 'i386'] and "-C gcc -C clang" => compilers=['gcc', 'clang'].
archs = None # Must be initialized after option parsing
compilers = None # Must be initialized after option parsing
"functionality (-G lldb-mi, --skip-category lldb-mi) instead.")
sys.exit(1)
- if args.c:
- if args.c.startswith('-'):
- usage(parser)
- configuration.configFile = args.c
- if not os.path.isfile(configuration.configFile):
- print('Config file:', configuration.configFile, 'does not exist!')
- usage(parser)
-
if args.d:
sys.stdout.write("Suspending the process %d to wait for debugger to attach...\n" % os.getpid())
sys.stdout.flush()
#print("testdirs:", testdirs)
- # Source the configFile if specified.
- # The side effect, if any, will be felt from this point on. An example
- # config file may be these simple two lines:
- #
- # sys.stderr = open("/tmp/lldbtest-stderr", "w")
- # sys.stdout = open("/tmp/lldbtest-stdout", "w")
- #
- # which will reassign the two file objects to sys.stderr and sys.stdout,
- # respectively.
- #
- # See also lldb-trunk/examples/test/usage-config.
- if configuration.configFile:
- # Pass config (a dictionary) as the locals namespace for side-effect.
- execfile(configuration.configFile, globals(), configuration.config)
- #print("config:", config)
- if "pre_flight" in configuration.config:
- configuration.pre_flight = configuration.config["pre_flight"]
- if not six.callable(configuration.pre_flight):
- print("fatal error: pre_flight is not callable, exiting.")
- sys.exit(1)
- if "post_flight" in configuration.config:
- configuration.post_flight = configuration.config["post_flight"]
- if not six.callable(configuration.post_flight):
- print("fatal error: post_flight is not callable, exiting.")
- sys.exit(1)
- if "lldbtest_remote_sandbox" in configuration.config:
- configuration.lldbtest_remote_sandbox = configuration.config["lldbtest_remote_sandbox"]
- if "lldbtest_remote_shell_template" in configuration.config:
- configuration.lldbtest_remote_shell_template = configuration.config["lldbtest_remote_shell_template"]
- #print("sys.stderr:", sys.stderr)
- #print("sys.stdout:", sys.stdout)
-
def getXcodeOutputPaths(lldbRootDirectory):
result = []
# Now that we have loaded all the test cases, run the whole test suite.
#
- # The pre_flight and post_flight come from reading a config file.
- def getsource_if_available(obj):
- """
- Return the text of the source code for an object if available. Otherwise,
- a print representation is returned.
- """
- import inspect
- try:
- return inspect.getsource(obj)
- except:
- return repr(obj)
-
- if not configuration.noHeaders:
- print("configuration.pre_flight:", getsource_if_available(configuration.pre_flight))
- print("configuration.post_flight:", getsource_if_available(configuration.post_flight))
-
- # If either pre_flight or post_flight is defined, set configuration.test_remote to True.
- configuration.test_remote = configuration.pre_flight or configuration.post_flight
-
# Turn on lldb loggings if necessary.
lldbLoggings()
iterArchs = False
iterCompilers = False
- if not configuration.archs and "archs" in configuration.config:
- configuration.archs = configuration.config["archs"]
-
if isinstance(configuration.archs, list) and len(configuration.archs) >= 1:
iterArchs = True
- if not configuration.compilers and "compilers" in configuration.config:
- configuration.compilers = configuration.config["compilers"]
-
#
# Add some intervention here to sanity check that the compilers requested are sane.
# If found not to be an executable program, the invalid one is dropped from the list.
tbl = str.maketrans(' ', '-')
configPostfix = configString.translate(tbl)
- # Check whether we need to split stderr/stdout into configuration
- # specific files.
- if old_stderr.name != '<stderr>' and configuration.config.get('split_stderr'):
- if new_stderr:
- new_stderr.close()
- new_stderr = open("%s.%s" % (old_stderr.name, configPostfix), "w")
- sys.stderr = new_stderr
- if old_stdout.name != '<stdout>' and configuration.config.get('split_stdout'):
- if new_stdout:
- new_stdout.close()
- new_stdout = open("%s.%s" % (old_stdout.name, configPostfix), "w")
- sys.stdout = new_stdout
-
# If we specified a relocated directory to run the test suite, do
# the extra housekeeping to copy the testdirs to a configStringified
# directory and to update sys.path before invoking the test runner.
# Configuration options
group = parser.add_argument_group('Configuration options')
- group.add_argument('-c', metavar='config-file', help='Read a config file specified after this option') # FIXME: additional doc.
group.add_argument('--framework', metavar='framework-path', help='The path to LLDB.framework')
group.add_argument('--executable', metavar='executable-path', help='The path to the lldb executable')
group.add_argument('--libcxx', metavar='directory', help='The path to custom libc++ library')
def inferior_not_crashing(self):
"""Test lldb reloads the inferior after it was changed during the session."""
self.runCmd("process kill")
- # Prod the lldb-platform that we have a newly built inferior ready.
- if configuration.lldbtest_remote_sandbox:
- self.runCmd("file " + self.exe, CURRENT_EXECUTABLE_SET)
self.runCmd("run", RUN_SUCCEEDED)
self.runCmd("process status")
raise Exception("@not_remote_testsuite_ready can only be used to decorate a test method")
@wraps(func)
def wrapper(self, *args, **kwargs):
- if configuration.lldbtest_remote_sandbox or lldb.remote_platform:
+ if lldb.remote_platform:
self.skipTest("not ready for remote testsuite")
return func(self, *args, **kwargs)
if "LLDB_TIME_WAIT_NEXT_LAUNCH" in os.environ:
self.timeWaitNextLaunch = float(os.environ["LLDB_TIME_WAIT_NEXT_LAUNCH"])
- #
- # Warning: MAJOR HACK AHEAD!
- # If we are running testsuite remotely (by checking lldb.lldbtest_remote_sandbox),
- # redefine the self.dbg.CreateTarget(filename) method to execute a "file filename"
- # command, instead. See also runCmd() where it decorates the "file filename" call
- # with additional functionality when running testsuite remotely.
- #
- if configuration.lldbtest_remote_sandbox:
- def DecoratedCreateTarget(arg):
- self.runCmd("file %s" % arg)
- target = self.dbg.GetSelectedTarget()
- #
- # SBtarget.LaunchSimple () currently not working for remote platform?
- # johnny @ 04/23/2012
- #
- def DecoratedLaunchSimple(argv, envp, wd):
- self.runCmd("run")
- return target.GetProcess()
- target.LaunchSimple = DecoratedLaunchSimple
-
- return target
- self.dbg.CreateTarget = DecoratedCreateTarget
- if self.TraceOn():
- print("self.dbg.Create is redefined to:\n%s" % getsource_if_available(DecoratedCreateTarget))
-
# We want our debugger to be synchronous.
self.dbg.SetAsync(False)
# And the result object.
self.res = lldb.SBCommandReturnObject()
- # Run global pre-flight code, if defined via the config file.
- if configuration.pre_flight:
- configuration.pre_flight(self)
-
if lldb.remote_platform and configuration.lldb_platform_working_dir:
remote_test_dir = lldbutil.join_remote_paths(
configuration.lldb_platform_working_dir,
for target in targets:
self.dbg.DeleteTarget(target)
- # Run global post-flight code, if defined via the config file.
- if configuration.post_flight:
- configuration.post_flight(self)
-
# Do this last, to make sure it's in reverse order from how we setup.
Base.tearDown(self)
trace = (True if traceAlways else trace)
- # This is an opportunity to insert the 'platform target-install' command if we are told so
- # via the settig of lldb.lldbtest_remote_sandbox.
if cmd.startswith("target create "):
cmd = cmd.replace("target create ", "file ")
- if cmd.startswith("file ") and configuration.lldbtest_remote_sandbox:
- with recording(self, trace) as sbuf:
- the_rest = cmd.split("file ")[1]
- # Split the rest of the command line.
- atoms = the_rest.split()
- #
- # NOTE: This assumes that the options, if any, follow the file command,
- # instead of follow the specified target.
- #
- target = atoms[-1]
- # Now let's get the absolute pathname of our target.
- abs_target = os.path.abspath(target)
- print("Found a file command, target (with absolute pathname)=%s" % abs_target, file=sbuf)
- fpath, fname = os.path.split(abs_target)
- parent_dir = os.path.split(fpath)[0]
- platform_target_install_command = 'platform target-install %s %s' % (fpath, configuration.lldbtest_remote_sandbox)
- print("Insert this command to be run first: %s" % platform_target_install_command, file=sbuf)
- self.ci.HandleCommand(platform_target_install_command, self.res)
- # And this is the file command we want to execute, instead.
- #
- # Warning: SIDE EFFECT AHEAD!!!
- # Populate the remote executable pathname into the lldb namespace,
- # so that test cases can grab this thing out of the namespace.
- #
- remote_sandboxed_executable = abs_target.replace(parent_dir, configuration.lldbtest_remote_sandbox)
- cmd = "file -P %s %s %s" % (remote_sandboxed_executable, the_rest.replace(target, ''), abs_target)
- print("And this is the replaced file command: %s" % cmd, file=sbuf)
running = (cmd.startswith("run") or cmd.startswith("process launch"))