Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / macosx / posix_spawn / TestLaunchProcessPosixSpawn.py
blobffb6ef0fe4a18f443f53f1f475df4026df571b27
1 import contextlib
2 import os
3 from os.path import exists
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 def haswell():
11 features = subprocess.check_output(["sysctl", "machdep.cpu"])
12 return "AVX2" in features.decode("utf-8")
15 def apple_silicon():
16 features = subprocess.check_output(["sysctl", "machdep.cpu"])
17 return "Apple M" in features.decode("utf-8")
20 def rosetta_debugserver_installed():
21 return exists("/Library/Apple/usr/libexec/oah/debugserver")
24 class TestLaunchProcessPosixSpawn(TestBase):
25 NO_DEBUG_INFO_TESTCASE = True
27 def no_haswell(self):
28 if not haswell():
29 return "Current CPU is not Haswell"
30 return None
32 def no_apple_silicon(self):
33 if not apple_silicon():
34 return "Current CPU is not Apple Silicon"
35 return None
37 def run_arch(self, exe, arch):
38 self.runCmd("target create -arch {} {}".format(arch, exe))
39 self.runCmd("run")
41 process = self.dbg.GetSelectedTarget().process
42 self.assertState(process.GetState(), lldb.eStateExited)
43 self.assertIn("slice: {}".format(arch), process.GetSTDOUT(1000))
45 @skipUnlessDarwin
46 @skipIfDarwinEmbedded
47 @skipIfLLVMTargetMissing("AArch64")
48 @skipIfLLVMTargetMissing("X86")
49 @skipTestIfFn(no_haswell)
50 def test_haswell(self):
51 self.build()
52 exe = self.getBuildArtifact("fat.out")
53 self.run_arch(exe, "x86_64")
54 self.run_arch(exe, "x86_64h")
56 @skipUnlessDarwin
57 @skipIfDarwinEmbedded
58 @skipIfLLVMTargetMissing("AArch64")
59 @skipIfLLVMTargetMissing("X86")
60 @skipTestIfFn(no_apple_silicon)
61 def test_apple_silicon(self):
62 self.build()
63 exe = self.getBuildArtifact("fat.out")
64 if rosetta_debugserver_installed():
65 self.run_arch(exe, "x86_64")
66 self.run_arch(exe, "arm64")