[Lldb-commits] [lldb] [LLDB] Fix tests windows (PR #131600)

Aleksandr Korepanov via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 17 03:40:05 PDT 2025


https://github.com/AlexK0 created https://github.com/llvm/llvm-project/pull/131600

Hello,

I'm working on LLDB on Windows and have encountered some issues with the tests.

1) Many tests fail to start on Windows due to an import exception:
```
Traceback (most recent call last):
  File "D:\Projects\github\llvm-project-fork\lldb\test\API\dotest.py", line 8, in <module>
    lldbsuite.test.run_suite()
  File "D:\Projects\github\llvm-project-fork\lldb\packages\Python\lldbsuite\test\dotest.py", line 1042, in run_suite
    checkLibcxxSupport()
  File "D:\Projects\github\llvm-project-fork\lldb\packages\Python\lldbsuite\test\dotest.py", line 799, in checkLibcxxSupport
    result, reason = canRunLibcxxTests()
  File "D:\Projects\github\llvm-project-fork\lldb\packages\Python\lldbsuite\test\dotest.py", line 770, in canRunLibcxxTests
    from lldbsuite.test import lldbplatformutil
  File "D:\Projects\github\llvm-project-fork\lldb\packages\Python\lldbsuite\test\lldbplatformutil.py", line 11, in <module>
    from packaging import version
ModuleNotFoundError: No module named 'packaging'
```

I think this exception occurs due to missing environment variables. I fixed the test setup to use the original environment variables.

2) `file` utility is not available on Windows, so I fixed the test to use `test -d` instead.

3) There is a minor difference in the watchpoint error message on Windows.

Please take a look.

Thanks!

>From 9734adfcca5d1d5cfdba85dc0bfe76d230106c11 Mon Sep 17 00:00:00 2001
From: Aleksandr Korepanov <alexander.korepanov at jetbrains.com>
Date: Mon, 17 Mar 2025 11:03:57 +0100
Subject: [PATCH 1/2] [LLDB][tests] Use original env for running tests

On Windows without the original environment,
the test framework cannot import the 'packaging' module.
---
 lldb/test/API/lldbtest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index d6b79ebc2c434..f32c2ac61537f 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -63,7 +63,7 @@ def execute(self, test, litConfig):
         try:
             out, err, exitCode = lit.util.executeCommand(
                 cmd,
-                env=test.config.environment,
+                env={**os.environ, **test.config.environment},
                 timeout=litConfig.maxIndividualTestTime,
             )
         except lit.util.ExecuteCommandTimeoutException as e:

>From 959c86f9cee6bedadc32bb99574b4fdfac37f0fd Mon Sep 17 00:00:00 2001
From: Aleksandr Korepanov <alexander.korepanov at jetbrains.com>
Date: Mon, 17 Mar 2025 11:06:46 +0100
Subject: [PATCH 2/2] [LLDB][tests] Fix tests for Windows

- On Windows there is different error message on setting watchpoint.

- Use 'test -d' to check for a directory instead of 'file' because
  Windows does not have the 'file' utility.
---
 .../watchlocation/TestTargetWatchAddress.py     | 17 ++++++++++++-----
 lldb/test/Shell/Diagnostics/TestDump.test       |  4 ++--
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
index 7a0e42a4fc278..5f7be87322b02 100644
--- a/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
+++ b/lldb/test/API/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
@@ -201,8 +201,15 @@ def test_watch_address_with_invalid_watch_size(self):
                 value.GetValueAsUnsigned(), 365, wp_opts, error
             )
             self.assertFalse(watchpoint)
-            self.expect(
-                error.GetCString(),
-                exe=False,
-                substrs=["Setting one of the watchpoint resources failed"],
-            )
+            if self.getPlatform() == 'windows':
+                self.expect(
+                    error.GetCString(),
+                    exe=False,
+                    substrs=["Can't enable watchpoint"],
+                )
+            else:
+                self.expect(
+                    error.GetCString(),
+                    exe=False,
+                    substrs=["Setting one of the watchpoint resources failed"],
+                )
diff --git a/lldb/test/Shell/Diagnostics/TestDump.test b/lldb/test/Shell/Diagnostics/TestDump.test
index 2adde6b86d35a..ae29bbbb8eeb4 100644
--- a/lldb/test/Shell/Diagnostics/TestDump.test
+++ b/lldb/test/Shell/Diagnostics/TestDump.test
@@ -5,11 +5,11 @@
 # RUN: rm -rf %t.existing
 # RUN: mkdir -p %t.existing
 # RUN: %lldb -o 'diagnostics dump -d %t.existing'
-# RUN: file %t.existing | FileCheck %s
+# RUN: test -d %t.existing && echo "directory" | FileCheck %s
 
 # Dump to a non-existing directory.
 # RUN: rm -rf %t.nonexisting
 # RUN: %lldb -o 'diagnostics dump -d %t.nonexisting'
-# RUN: file %t.nonexisting | FileCheck %s
+# RUN: test -d %t.nonexisting && echo "directory" | FileCheck %s
 
 # CHECK: directory



More information about the lldb-commits mailing list