NFC test if rosetta is installed before running x86 binary on AS
authorJason Molenda <jason@molenda.com>
Tue, 15 Nov 2022 22:43:20 +0000 (14:43 -0800)
committerJason Molenda <jason@molenda.com>
Tue, 15 Nov 2022 22:44:35 +0000 (14:44 -0800)
Rosetta 2 is not installed by default in a fresh macOS installation
on Apple Silicon, so x86 binaries cannot be run.  CI bots are often
in this state.  Update this test to check for the rosetta debugserver,
which our debugserver also hardcodes the path of, before trying to
run an x86 process on AS systems.

lldb/test/API/macosx/posix_spawn/TestLaunchProcessPosixSpawn.py

index 1c25dc0..166b4df 100644 (file)
@@ -1,5 +1,6 @@
 import contextlib
 import os
+from os.path import exists
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -16,6 +17,9 @@ def apple_silicon():
     return "Apple M" in features.decode('utf-8')
 
 
+def rosetta_debugserver_installed():
+    return exists("/Library/Apple/usr/libexec/oah/debugserver")
+
 class TestLaunchProcessPosixSpawn(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
 
@@ -56,5 +60,6 @@ class TestLaunchProcessPosixSpawn(TestBase):
     def test_apple_silicon(self):
         self.build()
         exe = self.getBuildArtifact("fat.out")
-        self.run_arch(exe, 'x86_64')
+        if rosetta_debugserver_installed():
+            self.run_arch(exe, 'x86_64')
         self.run_arch(exe, 'arm64')