4 from lldbsuite.test.lldbtest import *
5 from lldbsuite.test.decorators import *
6 from gdbclientutils import *
9 return binascii.hexlify(string.encode()).decode()
11 class TestPlatformClient(GDBRemoteTestBase):
13 def test_process_list_with_all_users(self):
14 """Test connecting to a remote linux platform"""
16 class MyResponder(MockGDBServerResponder):
18 MockGDBServerResponder.__init__(self)
19 self.currentQsProc = 0
20 self.all_users = False
22 def qfProcessInfo(self, packet):
23 if "all_users:1" in packet:
25 name = hexlify("/a/test_process")
26 args = "-".join(map(hexlify,
27 ["/system/bin/sh", "-c", "/data/local/tmp/lldb-server"]))
28 return "pid:10;ppid:1;uid:2;gid:3;euid:4;egid:5;name:" + name + ";args:" + args + ";"
30 self.all_users = False
33 def qsProcessInfo(self):
35 if self.currentQsProc == 0:
36 self.currentQsProc = 1
37 name = hexlify("/b/another_test_process")
38 # This intentionally has a badly encoded argument
39 args = "X".join(map(hexlify,
40 ["/system/bin/ls", "--help"]))
41 return "pid:11;ppid:2;uid:3;gid:4;euid:5;egid:6;name:" + name + ";args:" + args + ";"
42 elif self.currentQsProc == 1:
43 self.currentQsProc = 0
48 self.server.responder = MyResponder()
51 self.runCmd("platform select remote-linux")
52 self.runCmd("platform connect connect://localhost:%d" %
54 self.assertTrue(self.dbg.GetSelectedPlatform().IsConnected())
55 self.expect("platform process list -x",
56 substrs=["2 matching processes were found", "test_process", "another_test_process"])
57 self.expect("platform process list -xv",
59 "PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE ARGUMENTS",
60 "10 1 2 3 4 5 /system/bin/sh -c /data/local/tmp/lldb-server",
62 self.expect("platform process list -xv", substrs=["/system/bin/ls"], matching=False)
63 self.expect("platform process list",
65 substrs=["error: no processes were found on the \"remote-linux\" platform"])
67 self.dbg.GetSelectedPlatform().DisconnectRemote()