Skip to content

[lldb] Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host #115337

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

Conversation

slydiman
Copy link
Contributor

@slydiman slydiman commented Nov 7, 2024

Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host.

… of Windows host

Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host.
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2024

@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)

Changes

Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host.


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

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+31-8)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 34319e203a3177..d4c5e61a8fd95a 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -989,13 +989,27 @@ def skipUnlessAArch64MTELinuxCompiler(func):
 
     def is_toolchain_with_mte():
         compiler_path = lldbplatformutil.getCompiler()
-        compiler = os.path.basename(compiler_path)
-        f = tempfile.NamedTemporaryFile()
+        f_src = tempfile.NamedTemporaryFile(delete=False)
+        f_out = tempfile.NamedTemporaryFile(delete=False)
         if lldbplatformutil.getPlatform() == "windows":
             return "MTE tests are not compatible with 'windows'"
 
-        cmd = "echo 'int main() {}' | %s -x c -o %s -" % (compiler_path, f.name)
+        # Note hostos may be Windows.
+        f_src.close()
+        f_out.close()
+
+        with open(f_src.name, "w") as f:
+            f.write("int main() {}")
+        cmd = f"{compiler_path} -x c -o {f_out.name} {f_src.name}"
         if os.popen(cmd).close() is not None:
+            try:
+                os.remove(f_src.name)
+            except OSError:
+                pass
+            try:
+                os.remove(f_out.name)
+            except OSError:
+                pass
             # Cannot compile at all, don't skip the test
             # so that we report the broken compiler normally.
             return None
@@ -1010,12 +1024,21 @@ def is_toolchain_with_mte():
             int main() {
                 void* ptr = __arm_mte_create_random_tag((void*)(0), 0);
             }"""
-        cmd = "echo '%s' | %s -march=armv8.5-a+memtag -x c -o %s -" % (
-            test_src,
-            compiler_path,
-            f.name,
+        with open(f_src.name, "w") as f:
+            f.write(test_src)
+        cmd = (
+            f"{compiler_path} -march=armv8.5-a+memtag -x c -o {f_out.name} {f_src.name}"
         )
-        if os.popen(cmd).close() is not None:
+        res = os.popen(cmd).close()
+        try:
+            os.remove(f_src.name)
+        except OSError:
+            pass
+        try:
+            os.remove(f_out.name)
+        except OSError:
+            pass
+        if res is not None:
             return "Toolchain does not support MTE"
         return None
 

Comment on lines 1027 to 1028
with open(f_src.name, "w") as f:
f.write(test_src)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Considered using the subprocess module and passing the contents through the input argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks.

@slydiman slydiman merged commit df3f18b into llvm:main Nov 8, 2024
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 8, 2024

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building lldb at step 16 "test-check-lldb-api".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/794

Here is the relevant piece of the build log for the reference
Step 16 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
UNSUPPORTED: lldb-api :: lang/objcxx/class-name-clash/TestNameClash.py (938 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/conflicting-names-class-update-utility-expr/TestObjCConflictingNamesForClassUpdateExpr.py (939 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/cpp_keywords_enabled/TestObjCppKeywordsEnabled.py (940 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/cxx-bridged-po/TestObjCXXBridgedPO.py (941 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/hide-runtime-values/TestObjCXXHideRuntimeValues.py (942 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/objc-builtin-types/TestObjCBuiltinTypes.py (943 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/objc-from-cpp-frames-without-debuginfo/TestObjCFromCppFramesWithoutDebugInfo.py (944 of 1209)
UNSUPPORTED: lldb-api :: lang/objcxx/objcxx-ivar-vector/TestIvarVector.py (945 of 1209)
UNSUPPORTED: lldb-api :: linux/aarch64/fpmr/TestAArch64LinuxFPMR.py (946 of 1209)
UNRESOLVED: lldb-api :: linux/aarch64/mte_memory_region/TestAArch64LinuxMTEMemoryRegion.py (947 of 1209)
******************** TEST 'lldb-api :: linux/aarch64/mte_memory_region/TestAArch64LinuxMTEMemoryRegion.py' FAILED ********************
Script:
--
/usr/bin/python3.12 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --libcxx-include-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1 --libcxx-include-target-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb --compiler /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang --dsymutil /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil --make /usr/bin/make --llvm-tools-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --lldb-obj-root /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb --lldb-libs-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --platform-url connect://jetson-agx-2198.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot /mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/linux/aarch64/mte_memory_region -p TestAArch64LinuxMTEMemoryRegion.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision df3f18b071d853896318d2d37186fc6289ffdb2b)
  clang revision df3f18b071d853896318d2d37186fc6289ffdb2b
  llvm revision df3f18b071d853896318d2d37186fc6289ffdb2b
Setting up remote platform 'remote-linux'
Connecting to remote platform 'remote-linux' at 'connect://jetson-agx-2198.lab.llvm.org:1234'...
Connected.
Setting remote platform working directory to '/home/ubuntu/lldb-tests'...
Skipping the following test categories: ['dsym', 'gmodules', 'debugserver', 'objc', 'lldb-dap']

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx arguments
FAIL: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_mte_regions (TestAArch64LinuxMTEMemoryRegion.AArch64LinuxMTEMemoryRegionTestCase.test_mte_regions)
======================================================================
ERROR: test_mte_regions (TestAArch64LinuxMTEMemoryRegion.AArch64LinuxMTEMemoryRegionTestCase.test_mte_regions)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 148, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 143, in wrapper
    reason = expected_fn()
             ^^^^^^^^^^^^^
  File "/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 1000, in is_toolchain_with_mte
    if subprocess.run(cmd, input="int main() {}".encode()).returncode != 0:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
… of Windows host (llvm#115337)

Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of
Windows host.
@slydiman slydiman deleted the lldb-fix-skipUnlessAArch64MTELinuxCompiler branch April 18, 2025 15:01
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.

4 participants