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    def get_stub_sid(self, extra_stub_args=None):
12        # Launch debugserver
13        if extra_stub_args:
14            self.debug_monitor_extra_args += extra_stub_args
15
16        server = self.launch_debug_monitor()
17        self.assertIsNotNone(server)
18        self.assertTrue(
19            lldbgdbserverutils.process_is_running(
20                server.pid, True))
21
22        # Get the process id for the stub.
23        return os.getsid(server.pid)
24
25    @skipIfWindows
26    @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
27    def test_sid_is_same_without_setsid(self):
28        self.set_inferior_startup_launch()
29
30        stub_sid = self.get_stub_sid()
31        self.assertEqual(stub_sid, os.getsid(0))
32
33    @skipIfWindows
34    @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
35    def test_sid_is_different_with_setsid(self):
36        self.set_inferior_startup_launch()
37
38        stub_sid = self.get_stub_sid(["--setsid"])
39        self.assertNotEqual(stub_sid, os.getsid(0))
40
41    @skipIfWindows
42    @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
43    def test_sid_is_different_with_S_llgs(self):
44        self.set_inferior_startup_launch()
45
46        stub_sid = self.get_stub_sid(["-S"])
47        self.assertNotEqual(stub_sid, os.getsid(0))
48