NFC test if rosetta debugserver exists before testing rosetta

A fresh install of macOS does not have Rosetta 2 installed by
default; the CI bots are often in this state, resulting in a
test failure.  debugserver already hardcodes the filepath of
the Rosetta 2 debugserver; test if that file exists before
running the Rosetta test.
This commit is contained in:
Jason Molenda 2022-11-15 14:33:50 -08:00
parent d7816057d7
commit 0869a69917
1 changed files with 15 additions and 11 deletions

View File

@ -3,6 +3,7 @@ import lldb
import lldbsuite.test.lldbutil as lldbutil import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import * from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import * from lldbsuite.test.decorators import *
from os.path import exists
def get_os_version(): def get_os_version():
@ -16,6 +17,8 @@ def get_os_version():
return m.group(1) return m.group(1)
return None return None
def rosetta_debugserver_installed():
return exists("/Library/Apple/usr/libexec/oah/debugserver")
def has_rosetta_shared_cache(os_version): def has_rosetta_shared_cache(os_version):
if not os_version: if not os_version:
@ -41,6 +44,7 @@ class TestRosetta(TestBase):
self.build() self.build()
self.main_source_file = lldb.SBFileSpec("main.c") self.main_source_file = lldb.SBFileSpec("main.c")
if rosetta_debugserver_installed():
broadcaster = self.dbg.GetBroadcaster() broadcaster = self.dbg.GetBroadcaster()
listener = lldbutil.start_listening_from( listener = lldbutil.start_listening_from(
broadcaster, lldb.SBDebugger.eBroadcastBitWarning) broadcaster, lldb.SBDebugger.eBroadcastBitWarning)