1""" 2Test denied process attach. 3""" 4 5 6import time 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12exe_name = "AttachDenied" # Must match Makefile 13 14 15class AttachDeniedTestCase(TestBase): 16 NO_DEBUG_INFO_TESTCASE = True 17 18 @skipIfWindows 19 @skipIfiOSSimulator 20 @skipIfDarwinEmbedded # ptrace(ATTACH_REQUEST...) won't work on ios/tvos/etc 21 @skipIfAsan # Times out inconsistently under asan 22 def test_attach_to_process_by_id_denied(self): 23 """Test attach by process id denied""" 24 self.build() 25 exe = self.getBuildArtifact(exe_name) 26 27 # Use a file as a synchronization point between test and inferior. 28 pid_file_path = lldbutil.append_to_process_working_directory( 29 self, "pid_file_%d" % (int(time.time())) 30 ) 31 self.addTearDownHook( 32 lambda: self.run_platform_command("rm %s" % (pid_file_path)) 33 ) 34 35 # Spawn a new process 36 popen = self.spawnSubprocess(exe, [pid_file_path]) 37 38 pid = lldbutil.wait_for_file_on_target(self, pid_file_path) 39 40 self.expect( 41 "process attach -p " + pid, startstr="error: attach failed:", error=True 42 ) 43