Skip to content

[lldb] Correct documentation of LLDB_TEST_USER_ARGS #89042

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

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

DavidSpickett
Copy link
Collaborator

https://discourse.llvm.org/t/running-lldb-in-a-container/76801/4 found that the obvious way to use this variable doesn't work, despite what our docs and examples say.

Perhaps in the past it did but now you need to use ";" as a separator to make sure the final command line works properly.

For example "-A foo" becomes "-A foo" when python goes to run the runner script. The script sees this as one command line element, not two. What you actually want is "-A;foo" which we convert to "-A" "foo" which the script sees as one option and one value for that option.

The "Script:" printout from dotest is misleading here because it does " ".join(cmd) so it looks like it's ok but in fact it's not.

I'm not changing that format though because printing the command as a Python list is not useful outside of this specific situation.

https://discourse.llvm.org/t/running-lldb-in-a-container/76801/4 found
that the obvious way to use this variable doesn't work, despite
what our docs and examples say.

Perhaps in the past it did but now you need to use ";" as a separator
to make sure the final command line works properly.

For example "-A foo" becomes "-A foo" when python goes to run the
runner script. The script sees this as one command line element,
not two. What you actually want is "-A;foo" which we convert
to "-A" "foo" which the script sees as one option and one value
for that option.

The "Script:" printout from dotest is misleading here because
it does `" ".join(cmd)` so it looks like it's ok but in fact it's not.

I'm not changing that format though because printing the command as a
Python list is not useful outside of this specific situation.
@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2024

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

https://discourse.llvm.org/t/running-lldb-in-a-container/76801/4 found that the obvious way to use this variable doesn't work, despite what our docs and examples say.

Perhaps in the past it did but now you need to use ";" as a separator to make sure the final command line works properly.

For example "-A foo" becomes "-A foo" when python goes to run the runner script. The script sees this as one command line element, not two. What you actually want is "-A;foo" which we convert to "-A" "foo" which the script sees as one option and one value for that option.

The "Script:" printout from dotest is misleading here because it does " ".join(cmd) so it looks like it's ok but in fact it's not.

I'm not changing that format though because printing the command as a Python list is not useful outside of this specific situation.


Full diff: https://github.com/llvm/llvm-project/pull/89042.diff

2 Files Affected:

  • (modified) lldb/docs/resources/test.rst (+21-4)
  • (modified) lldb/test/API/CMakeLists.txt (+2-1)
diff --git a/lldb/docs/resources/test.rst b/lldb/docs/resources/test.rst
index 2b0e9010fe280a..094fde8b1b5a0a 100644
--- a/lldb/docs/resources/test.rst
+++ b/lldb/docs/resources/test.rst
@@ -441,23 +441,40 @@ Running the Full Test Suite
 The easiest way to run the LLDB test suite is to use the ``check-lldb`` build
 target.
 
+::
+
+   $ ninja check-lldb
+
+Changing Test Suite Options
+```````````````````````````
+
 By default, the ``check-lldb`` target builds the test programs with the same
 compiler that was used to build LLDB. To build the tests with a different
 compiler, you can set the ``LLDB_TEST_COMPILER`` CMake variable.
 
+You can also add to the test runner options by setting the
+``LLDB_TEST_USER_ARGS`` CMake variable. This variable uses ``;`` to separate
+items which must be separate parts of the runner's command line.
+
 It is possible to customize the architecture of the test binaries and compiler
-used by appending ``-A`` and ``-C`` options respectively to the CMake variable
-``LLDB_TEST_USER_ARGS``. For example, to test LLDB against 32-bit binaries
-built with a custom version of clang, do:
+used by appending ``-A`` and ``-C`` options respectively. For example, to test
+LLDB against 32-bit binaries built with a custom version of clang, do:
 
 ::
 
-   $ cmake -DLLDB_TEST_USER_ARGS="-A i386 -C /path/to/custom/clang" -G Ninja
+   $ cmake -DLLDB_TEST_USER_ARGS="-A;i386;-C;/path/to/custom/clang" -G Ninja
    $ ninja check-lldb
 
 Note that multiple ``-A`` and ``-C`` flags can be specified to
 ``LLDB_TEST_USER_ARGS``.
 
+If you want to change the LLDB settings that tests run with then you can set
+the ``--setting`` option of the test runner via this same variable. For example
+``--setting;target.disable-aslr=true``.
+
+For a full list of test runner options, see
+``<build-dir>/bin/lldb-dotest --help``.
+
 Running a Single Test Suite

diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 4e02112c29e4cd..9196f54ce1ae32 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -35,7 +35,8 @@ set(LLDB_TEST_ARCH

Users can override LLDB_TEST_USER_ARGS to specify arbitrary arguments to pass to the script

set(LLDB_TEST_USER_ARGS
""

  • CACHE STRING "Specify additional arguments to pass to test runner. For example: '-C gcc -C clang -A i386 -A x86_64'")
  • CACHE STRING "Specify additional arguments to pass to test runner. Seperate
    +items with ";". For example: '-C;gcc;-C;clang;-A;i386;-A;x86_64'")

set(LLDB_TEST_COMMON_ARGS_VAR
-u CXXFLAGS


</details>

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The changes LGTM, but I haven't verified the commands work as described.

Copy link

@tedwoodward tedwoodward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, David. One of my guys is working on RISC-V tests, and wanted to use LLDB_TEST_USER_ARGS, but as you said it doesn't work as documented. This will help a lot!

@DavidSpickett DavidSpickett merged commit 03e841c into llvm:main Apr 18, 2024
@DavidSpickett DavidSpickett deleted the lldb-cmake branch April 18, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants