-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
Conversation
@llvm/pr-subscribers-lldb Author: Vladislav Dzhidzhoev (dzhidzhoev) ChangesThis commit adds dotest.py flags that come in handy for setting up cross-platform remote runs of API tests.
These arguments can be passed to dotest.py from cmake command line through
Full diff: https://github.com/llvm/llvm-project/pull/93800.diff 5 Files Affected:
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 823a982e67438..d63845a884d2f 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -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"
@@ -168,6 +177,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:
@@ -179,6 +189,7 @@ def getBuildCommand(
debug_info_args,
make_targets,
self.getArchCFlags(architecture),
+ self.getTargetOsFlag(target_os),
self.getArchSpec(architecture),
self.getCCSpec(compiler),
self.getExtraMakeArgs(),
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index 685f491c85fe1..4789f04582fdd 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -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
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 8c29145ecc527..9e3414a807420 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -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":
@@ -304,7 +306,9 @@ 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)
)
@@ -312,6 +316,9 @@ def parseOptionsAndInitTestdirs():
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:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index e4de786ec0548..bed62cc787b4c 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -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",
@@ -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",
@@ -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",
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index c28a78a2c4a27..9808f9fd1c373 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1387,11 +1387,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
|
✅ With the latest revision this PR passed the Python code formatter. |
…test.py This commit adds dotest.py flags that come in handy for setting up cross-platform remote run of API tests. `--make` argument allows to specify the path to make executable which is used by LLDB API tests to compile test programs. `--sysroot` and `--target-os` arguments allow to pass OS and SDKROOT variables to the make invocation. These variables are used in Makefile rules for tests. These arguments can be passed to dotest.py from cmake command line through `LLDB_TEST_USER_ARGS` as follows: ``` cmake ... \ -DLLDB_TEST_USER_ARGS="...;--make;/mymake;--sysroot;/sysroot/path/;--target-os;Linux;..." \ ... ```
771344c
to
b6c6238
Compare
It might be better to split this up per flag. For example, I don't see any issues with the --make flag, but I would like to understand more about why you need the --os flag (like, how it differs/why can't that be deduced from the platform name?) The sysroot arg is probably also fine, but it'd be better viewed in isolation. |
|
This commit adds dotest.py flags that come in handy for setting up cross-platform remote runs of API tests.
--make
argument allows to specify the path to the make executable used by LLDB API tests to compile test programs.--sysroot
and--target-os
arguments allow to pass OS and SDKROOT variables to the make invocation. These variables are used in Makefile rules for tests.These arguments can be passed to dotest.py from cmake command line through
LLDB_TEST_USER_ARGS
as follows: