1
2
3import gdbremote_testcase
4import lldbgdbserverutils
5import os
6import select
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    def get_stub_sid(self, extra_stub_args=None):
17        # Launch debugserver
18        if extra_stub_args:
19            self.debug_monitor_extra_args += extra_stub_args
20
21        server = self.launch_debug_monitor()
22        self.assertIsNotNone(server)
23        self.assertTrue(
24            lldbgdbserverutils.process_is_running(
25                server.pid, True))
26
27        # Get the process id for the stub.
28        return os.getsid(server.pid)
29
30    def sid_is_same_without_setsid(self):
31        stub_sid = self.get_stub_sid()
32        self.assertEqual(stub_sid, os.getsid(0))
33
34    def sid_is_different_with_setsid(self):
35        stub_sid = self.get_stub_sid(["--setsid"])
36        self.assertNotEqual(stub_sid, os.getsid(0))
37
38    def sid_is_different_with_S(self):
39        stub_sid = self.get_stub_sid(["-S"])
40        self.assertNotEqual(stub_sid, os.getsid(0))
41
42    @debugserver_test
43    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
44    def test_sid_is_same_without_setsid_debugserver(self):
45        self.set_inferior_startup_launch()
46        self.sid_is_same_without_setsid()
47
48    @skipIfWindows
49    @llgs_test
50    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
51    def test_sid_is_same_without_setsid_llgs(self):
52        self.set_inferior_startup_launch()
53        self.sid_is_same_without_setsid()
54
55    @debugserver_test
56    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
57    def test_sid_is_different_with_setsid_debugserver(self):
58        self.set_inferior_startup_launch()
59        self.sid_is_different_with_setsid()
60
61    @skipIfWindows
62    @llgs_test
63    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
64    def test_sid_is_different_with_setsid_llgs(self):
65        self.set_inferior_startup_launch()
66        self.sid_is_different_with_setsid()
67
68    @debugserver_test
69    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
70    def test_sid_is_different_with_S_debugserver(self):
71        self.set_inferior_startup_launch()
72        self.sid_is_different_with_S()
73
74    @skipIfWindows
75    @llgs_test
76    @skipIfRemote  # --setsid not used on remote platform and currently it is also impossible to get the sid of lldb-platform running on a remote target
77    def test_sid_is_different_with_S_llgs(self):
78        self.set_inferior_startup_launch()
79        self.sid_is_different_with_S()
80