Skip to content

[lldb][test] Add flags useful for remote cross-platform testing to dotest.py #93800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lldb/packages/Python/lldbsuite/test/builders/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ def getArchCFlags(self, architecture):
"""Returns the ARCH_CFLAGS for the make system."""
return []

def getTargetOsFlag(self, target_os):
if target_os is None:
target_os = configuration.target_os
if target_os is None:
return []
return ["OS=%s" % target_os]

def getMake(self, test_subdir, test_name):
"""Returns the invocation for GNU make.
The first argument is a tuple of the relative path to the testcase
and its filename stem."""
if platform.system() == "FreeBSD" or platform.system() == "NetBSD":
if configuration.make_path is not None:
make = configuration.make_path
elif platform.system() == "FreeBSD" or platform.system() == "NetBSD":
make = "gmake"
else:
make = "make"
Expand Down Expand Up @@ -171,6 +180,7 @@ def getBuildCommand(
testdir=None,
testname=None,
make_targets=None,
target_os=None,
):
debug_info_args = self._getDebugInfoArgs(debug_info)
if debug_info_args is None:
Expand All @@ -182,6 +192,7 @@ def getBuildCommand(
debug_info_args,
make_targets,
self.getArchCFlags(architecture),
self.getTargetOsFlag(target_os),
self.getArchSpec(architecture),
self.getCCSpec(compiler),
self.getExtraMakeArgs(),
Expand Down
2 changes: 2 additions & 0 deletions lldb/packages/Python/lldbsuite/test/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
count = 1

# The 'arch' and 'compiler' can be specified via command line.
target_os = None
arch = None
compiler = None
dsymutil = None
sdkroot = None
make_path = None

# The overriden dwarf verison.
dwarf_version = 0
Expand Down
9 changes: 8 additions & 1 deletion lldb/packages/Python/lldbsuite/test/dotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ def parseOptionsAndInitTestdirs():
configuration.compiler = candidate
break

if args.make:
configuration.make_path = args.make
if args.dsymutil:
configuration.dsymutil = args.dsymutil
elif platform_system == "Darwin":
Expand Down Expand Up @@ -304,14 +306,19 @@ def parseOptionsAndInitTestdirs():
lldbtest_config.out_of_tree_debugserver = args.out_of_tree_debugserver

# Set SDKROOT if we are using an Apple SDK
if platform_system == "Darwin" and args.apple_sdk:
if args.sysroot is not None:
configuration.sdkroot = args.sysroot
elif platform_system == "Darwin" and args.apple_sdk:
configuration.sdkroot = seven.get_command_output(
'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' % (args.apple_sdk)
)
if not configuration.sdkroot:
logging.error("No SDK found with the name %s; aborting...", args.apple_sdk)
sys.exit(-1)

if args.target_os:
configuration.target_os = args.target_os

if args.arch:
configuration.arch = args.arch
else:
Expand Down
24 changes: 24 additions & 0 deletions lldb/packages/Python/lldbsuite/test/dotest_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def create_parser():

# C and Python toolchain options
group = parser.add_argument_group("Toolchain options")
group.add_argument(
"--target-os",
metavar="target_os",
dest="target_os",
default="",
help=textwrap.dedent(
"""Specify target os for test compilation. This is useful for cross-compilation."""
),
)
group.add_argument(
"-A",
"--arch",
Expand All @@ -49,6 +58,15 @@ def create_parser():
"""Specify the compiler(s) used to build the inferior executables. The compiler path can be an executable basename or a full path to a compiler executable. This option can be specified multiple times."""
),
)
group.add_argument(
"--sysroot",
metavar="sysroot",
dest="sysroot",
default="",
help=textwrap.dedent(
"""Specify the path to sysroot. This overrides apple_sdk sysroot."""
),
)
if sys.platform == "darwin":
group.add_argument(
"--apple-sdk",
Expand Down Expand Up @@ -87,6 +105,12 @@ def create_parser():
),
)

group.add_argument(
"--make",
metavar="make",
dest="make",
help=textwrap.dedent("Specify which make to use."),
)
group.add_argument(
"--dsymutil",
metavar="dsymutil",
Expand Down
4 changes: 4 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,11 +1454,15 @@ def getDebugInfo(self):
def build(
self,
debug_info=None,
target_os=None,
architecture=None,
compiler=None,
dictionary=None,
make_targets=None,
):
if not target_os and configuration.target_os:
target_os = configuration.target_os

"""Platform specific way to build binaries."""
if not architecture and configuration.arch:
architecture = configuration.arch
Expand Down
Loading