@@ -989,13 +989,16 @@ def skipUnlessAArch64MTELinuxCompiler(func):
989
989
990
990
def is_toolchain_with_mte ():
991
991
compiler_path = lldbplatformutil .getCompiler ()
992
- compiler = os .path .basename (compiler_path )
993
- f = tempfile .NamedTemporaryFile ()
992
+ f = tempfile .NamedTemporaryFile (delete = False )
994
993
if lldbplatformutil .getPlatform () == "windows" :
995
994
return "MTE tests are not compatible with 'windows'"
996
995
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 )
999
1002
# Cannot compile at all, don't skip the test
1000
1003
# so that we report the broken compiler normally.
1001
1004
return None
@@ -1010,12 +1013,10 @@ def is_toolchain_with_mte():
1010
1013
int main() {
1011
1014
void* ptr = __arm_mte_create_random_tag((void*)(0), 0);
1012
1015
}"""
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 :
1019
1020
return "Toolchain does not support MTE"
1020
1021
return None
1021
1022
0 commit comments