Skip to content

[lldb][test] Remove compiler version check and use regex #123393

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
Jan 18, 2025

Conversation

kusmour
Copy link
Contributor

@kusmour kusmour commented Jan 17, 2025

The test checks specific compiler version to determine the output. However, the compiler version string is always set to 15.0.0 for our local build. Remove this check and use regex match instead.

Test Plan

./bin/llvm-lit -sva /home/wanyi/llvm-sand/external/llvm-project/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
...
Skipping the following test categories: ['dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/wanyi/llvm-sand/build/Release+Distribution/fbcode-x86_64/toolchain/bin/clang-x86_64) :: test_dsym (TestVectorOfVectorsFromStdModule.TestVectorOfVectors) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/wanyi/llvm-sand/build/Release+Distribution/fbcode-x86_64/toolchain/bin/clang-x86_64) :: test_dwarf (TestVectorOfVectorsFromStdModule.TestVectorOfVectors)
PASS: LLDB (/home/wanyi/llvm-sand/build/Release+Distribution/fbcode-x86_64/toolchain/bin/clang-x86_64) :: test_dwo (TestVectorOfVectorsFromStdModule.TestVectorOfVectors)
----------------------------------------------------------------------
Ran 3 tests in 4.636s

OK (skipped=1)

--

********************

Testing Time: 4.97s

Total Discovered Tests: 1
  Passed: 1 (100.00%)

@llvmbot
Copy link
Member

llvmbot commented Jan 17, 2025

@llvm/pr-subscribers-lldb

Author: Wanyi (kusmour)

Changes

The test checks specific compiler version to determine the output. However, the compiler version string is always set to 15.0.0 for our local build. Remove this check and use regex match instead.


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

2 Files Affected:

  • (modified) lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py (+7-15)
  • (modified) lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py (+14-32)
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 1c32222e64f14c..30e56f18a83d67 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -23,13 +23,6 @@ def test(self):
 
         self.runCmd("settings set target.import-std-module true")
 
-        if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-            [">", "16.0"]
-        ):
-            vector_type = "std::vector<Foo>"
-        else:
-            vector_type = "std::vector<Foo, std::allocator<Foo> >"
-
         size_type = "size_type"
         value_type = "value_type"
         iterator = "iterator"
@@ -41,14 +34,13 @@ def test(self):
             ValueCheck(name="current"),
         ]
 
-        self.expect_expr(
-            "a",
-            result_type=vector_type,
-            result_children=[
-                ValueCheck(children=[ValueCheck(value="3")]),
-                ValueCheck(children=[ValueCheck(value="1")]),
-                ValueCheck(children=[ValueCheck(value="2")]),
-            ],
+        self.expect(
+            "expr a",
+            patterns=["""\(std::vector<Foo(, std::allocator<Foo> )*>\) \$0 = size=3 \{
+  \[0\] = \(a = 3\)
+  \[1\] = \(a = 1\)
+  \[2\] = \(a = 2\)
+\}"""]
         )
 
         self.expect_expr("a.size()", result_type=size_type, result_value="3")
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index a1f33271f39d2f..df9ff9316d549b 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -17,43 +17,25 @@ def test(self):
             self, "// Set break point at this line.", lldb.SBFileSpec("main.cpp")
         )
 
-        if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-            [">", "16.0"]
-        ):
-            vector_type = "std::vector<int>"
-            vector_of_vector_type = "std::vector<std::vector<int> >"
-        else:
-            vector_type = "std::vector<int>"
-            vector_of_vector_type = (
-                "std::vector<std::vector<int>, std::allocator<std::vector<int> > >"
-            )
-
         size_type = "size_type"
         value_type = "value_type"
 
         self.runCmd("settings set target.import-std-module true")
 
-        self.expect_expr(
-            "a",
-            result_type=vector_of_vector_type,
-            result_children=[
-                ValueCheck(
-                    type=vector_type,
-                    children=[
-                        ValueCheck(value="1"),
-                        ValueCheck(value="2"),
-                        ValueCheck(value="3"),
-                    ],
-                ),
-                ValueCheck(
-                    type=vector_type,
-                    children=[
-                        ValueCheck(value="3"),
-                        ValueCheck(value="2"),
-                        ValueCheck(value="1"),
-                    ],
-                ),
-            ],
+        self.expect(
+            "expr a",
+            patterns=["""\(std::vector<std::vector<int>(, std::allocator<std::vector<int> )* >\) \$0 = size=2 \{
+  \[0\] = size=3 \{
+    \[0\] = 1
+    \[1\] = 2
+    \[2\] = 3
+  \}
+  \[1\] = size=3 \{
+    \[0\] = 3
+    \[1\] = 2
+    \[2\] = 1
+  \}
+\}"""],
         )
         self.expect_expr("a.size()", result_type=size_type, result_value="2")
         front = self.expect_expr(

Copy link

github-actions bot commented Jan 17, 2025

✅ With the latest revision this PR passed the Python code formatter.

@kusmour kusmour force-pushed the fix_lldb_vector_test branch from 1d4160e to 944e3c8 Compare January 17, 2025 20:21
@kusmour kusmour merged commit b62e558 into llvm:main Jan 18, 2025
7 checks passed
@kusmour kusmour deleted the fix_lldb_vector_test branch January 18, 2025 06:47
@Michael137
Copy link
Member

This is failing on the macOS matrix bots: https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/lldb-cmake-matrix which test with older compiler versions

Looks like the regex might be incorrect.

Mind fixing this? Or revert if it isn't an easy fix?

@adrian-prantl
Copy link
Collaborator

Got output:
(std::vector<std::vector<int>, std::allocator<std::vector<int> > >) $0 = size=2 {
  [0] = size=3 {
    [0] = 1
    [1] = 2
    [2] = 3
  }
  [1] = size=3 {
    [0] = 3
    [1] = 2
    [2] = 1
  }
}

Expecting regex pattern: "\(std::vector<std::vector<int>(, std::allocator<std::vector<int> )* >\) \$0 = size=2 \{
  \[0\] = size=3 \{
    \[0\] = 1
    \[1\] = 2
    \[2\] = 3
  \}
  \[1\] = size=3 \{
    \[0\] = 3
    \[1\] = 2
    \[2\] = 1
  \}
\}" (was not found)

@adrian-prantl
Copy link
Collaborator

Generally speaking, it would be a lot more robust to not try and write a regex for the output, but individually check the summary/type for main node and children.

@kusmour
Copy link
Contributor Author

kusmour commented Jan 22, 2025

Generally speaking, it would be a lot more robust to not try and write a regex for the output, but individually check the summary/type for main node and children.

@adrian-prantl Thank you for the info! I will try to see if I can fix it with regex check on the type only and keep the children value checks!

@Michael137
Copy link
Member

Reverting for now to get CI green again

Michael137 added a commit that referenced this pull request Jan 23, 2025
Michael137 added a commit that referenced this pull request Jan 23, 2025
…24101)

Reverts #123393

This is causing `TestVectorOfVectorsFromStdModule.py` to fail on the the
macOS clang-15 matrix bot.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 23, 2025
… regex" (#124101)

Reverts llvm/llvm-project#123393

This is causing `TestVectorOfVectorsFromStdModule.py` to fail on the the
macOS clang-15 matrix bot.
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