@@ -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