brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 750cdb3 Raw
49 lines · python
1"""2Test lldb command aliases.3"""4 5import unittest6import os7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12 13class LaunchInTerminalTestCase(TestBase):14    # Darwin is the only platform that I know of that supports optionally launching15    # a program in a separate terminal window. It would be great if other platforms16    # added support for this.17    @skipUnlessDarwin18    # If the test is being run under sudo, the spawned terminal won't retain that elevated19    # privilege so it can't open the socket to talk back to the test case20    @unittest.skipIf(21        hasattr(os, "geteuid") and os.geteuid() == 0, "test cannot be run as root"22    )23    # Do we need to disable this test if the testsuite is being run on a remote system?24    # This env var is only defined when the shell is running in a local mac25    # terminal window26    @unittest.skipUnless(27        "TERM_PROGRAM" in os.environ, "test must be run on local system"28    )29    @no_debug_info_test30    def test_launch_in_terminal(self):31        self.build()32        exe = self.getBuildArtifact("a.out")33 34        target = self.dbg.CreateTarget(exe)35        launch_info = lldb.SBLaunchInfo(["-lAF", "/tmp/"])36        launch_info.SetLaunchFlags(37            lldb.eLaunchFlagLaunchInTTY | lldb.eLaunchFlagCloseTTYOnExit38        )39        error = lldb.SBError()40        process = target.Launch(launch_info, error)41        print("Error was: %s." % (error.GetCString()))42        self.assertTrue(43            error.Success(),44            "Make sure launch happened successfully in a terminal window",45        )46        # Running in synchronous mode our process should have run and already47        # exited by the time target.Launch() returns48        self.assertState(process.GetState(), lldb.eStateExited)49