[Lldb-commits] [lldb] [lldb] Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host (PR #115337)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 8 02:55:56 PST 2024
https://github.com/slydiman updated https://github.com/llvm/llvm-project/pull/115337
>From d9f799f02fb47804d4e35c5fd73433280b650257 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Thu, 7 Nov 2024 20:22:57 +0400
Subject: [PATCH 1/2] [lldb] Fixed the @skipUnlessAArch64MTELinuxCompiler
decorator in case of Windows host
Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host.
---
.../Python/lldbsuite/test/decorators.py | 39 +++++++++++++++----
1 file changed, 31 insertions(+), 8 deletions(-)
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
>From d54ea2ab1df3543ec66a41cead686b129cbf63a9 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Fri, 8 Nov 2024 14:50:16 +0400
Subject: [PATCH 2/2] Updated with subprocess.run(cmd, input=...)
---
.../Python/lldbsuite/test/decorators.py | 40 +++++--------------
1 file changed, 9 insertions(+), 31 deletions(-)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index d4c5e61a8fd95a..0bb9ab9f5f8929 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -989,27 +989,16 @@ def skipUnlessAArch64MTELinuxCompiler(func):
def is_toolchain_with_mte():
compiler_path = lldbplatformutil.getCompiler()
- f_src = tempfile.NamedTemporaryFile(delete=False)
- f_out = tempfile.NamedTemporaryFile(delete=False)
+ f = tempfile.NamedTemporaryFile(delete=False)
if lldbplatformutil.getPlatform() == "windows":
return "MTE tests are not compatible with 'windows'"
# Note hostos may be Windows.
- f_src.close()
- f_out.close()
+ f.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
+ cmd = f"{compiler_path} -x c -o {f.name} -"
+ if subprocess.run(cmd, input="int main() {}".encode()).returncode != 0:
+ os.remove(f.name)
# Cannot compile at all, don't skip the test
# so that we report the broken compiler normally.
return None
@@ -1024,21 +1013,10 @@ def is_toolchain_with_mte():
int main() {
void* ptr = __arm_mte_create_random_tag((void*)(0), 0);
}"""
- 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}"
- )
- 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:
+ cmd = f"{compiler_path} -march=armv8.5-a+memtag -x c -o {f.name} -"
+ res = subprocess.run(cmd, input=test_src.encode())
+ os.remove(f.name)
+ if res.returncode != 0:
return "Toolchain does not support MTE"
return None
More information about the lldb-commits
mailing list