43 lines · python
1"""2Test denied process attach.3"""4 5 6import time7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12exe_name = "AttachDenied" # Must match Makefile13 14 15class AttachDeniedTestCase(TestBase):16 NO_DEBUG_INFO_TESTCASE = True17 18 @skipIfWindows19 @skipIfiOSSimulator20 @skipIfDarwinEmbedded # ptrace(ATTACH_REQUEST...) won't work on ios/tvos/etc21 @skipIfAsan # Times out inconsistently under asan22 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 process36 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=True42 )43