Skip to content

Commit df3f18b

Browse files
authored
[lldb] Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host (#115337)
Fixed the @skipUnlessAArch64MTELinuxCompiler decorator in case of Windows host.
1 parent 0a7e5e3 commit df3f18b

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -989,13 +989,16 @@ def skipUnlessAArch64MTELinuxCompiler(func):
989989

990990
def is_toolchain_with_mte():
991991
compiler_path = lldbplatformutil.getCompiler()
992-
compiler = os.path.basename(compiler_path)
993-
f = tempfile.NamedTemporaryFile()
992+
f = tempfile.NamedTemporaryFile(delete=False)
994993
if lldbplatformutil.getPlatform() == "windows":
995994
return "MTE tests are not compatible with 'windows'"
996995

997-
cmd = "echo 'int main() {}' | %s -x c -o %s -" % (compiler_path, f.name)
998-
if os.popen(cmd).close() is not None:
996+
# Note hostos may be Windows.
997+
f.close()
998+
999+
cmd = f"{compiler_path} -x c -o {f.name} -"
1000+
if subprocess.run(cmd, input="int main() {}".encode()).returncode != 0:
1001+
os.remove(f.name)
9991002
# Cannot compile at all, don't skip the test
10001003
# so that we report the broken compiler normally.
10011004
return None
@@ -1010,12 +1013,10 @@ def is_toolchain_with_mte():
10101013
int main() {
10111014
void* ptr = __arm_mte_create_random_tag((void*)(0), 0);
10121015
}"""
1013-
cmd = "echo '%s' | %s -march=armv8.5-a+memtag -x c -o %s -" % (
1014-
test_src,
1015-
compiler_path,
1016-
f.name,
1017-
)
1018-
if os.popen(cmd).close() is not None:
1016+
cmd = f"{compiler_path} -march=armv8.5-a+memtag -x c -o {f.name} -"
1017+
res = subprocess.run(cmd, input=test_src.encode())
1018+
os.remove(f.name)
1019+
if res.returncode != 0:
10191020
return "Toolchain does not support MTE"
10201021
return None
10211022

0 commit comments

Comments
 (0)