1import gdbremote_testcase
2import lldbgdbserverutils
3import os
4import select
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9class TestStubSetSIDTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
10
11    mydir = TestBase.compute_mydir(__file__)
12
13    def get_stub_sid(self, extra_stub_args=None):
14        # Launch debugserver
15        if extra_stub_args:
16            self.debug_monitor_extra_args += extra_stub_args
17
18        server = self.launch_debug_monitor()
19        self.assertIsNotNone(server)
20        self.assertTrue(
21            lldbgdbserverutils.process_is_running(
22                server.pid, True))
23
24        # Get the process id for the stub.
25        return os.getsid(server.pid)
26
27    @skipIfWindows
28    @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
29    def test_sid_is_same_without_setsid(self):
30        self.set_inferior_startup_launch()
31
32        stub_sid = self.get_stub_sid()
33        self.assertEqual(stub_sid, os.getsid(0))
34
35    @skipIfWindows
36    @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
37    def test_sid_is_different_with_setsid(self):
38        self.set_inferior_startup_launch()
39
40        stub_sid = self.get_stub_sid(["--setsid"])
41        self.assertNotEqual(stub_sid, os.getsid(0))
42
43    @skipIfWindows
44    @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
45    def test_sid_is_different_with_S_llgs(self):
46        self.set_inferior_startup_launch()
47
48        stub_sid = self.get_stub_sid(["-S"])
49        self.assertNotEqual(stub_sid, os.getsid(0))
50