2015-01-07 03:17:58 +08:00
|
|
|
"""
|
|
|
|
Test lldb command aliases.
|
|
|
|
"""
|
|
|
|
|
2015-10-24 01:04:29 +08:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-04 03:20:39 +08:00
|
|
|
|
2015-01-07 03:17:58 +08:00
|
|
|
import unittest2
|
2016-09-07 04:57:50 +08:00
|
|
|
import os
|
|
|
|
import time
|
2015-01-07 03:17:58 +08:00
|
|
|
import lldb
|
2016-02-05 07:04:17 +08:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 10:06:18 +08:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-05 07:04:17 +08:00
|
|
|
from lldbsuite.test import lldbutil
|
2015-01-07 03:17:58 +08:00
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2015-01-07 03:17:58 +08:00
|
|
|
class LaunchInTerminalTestCase(TestBase):
|
|
|
|
|
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
|
|
|
|
|
|
|
# Darwin is the only platform that I know of that supports optionally launching
|
|
|
|
# a program in a separate terminal window. It would be great if other platforms
|
|
|
|
# added support for this.
|
2015-03-30 22:12:17 +08:00
|
|
|
@skipUnlessDarwin
|
2015-01-13 08:54:59 +08:00
|
|
|
# If the test is being run under sudo, the spawned terminal won't retain that elevated
|
|
|
|
# privilege so it can't open the socket to talk back to the test case
|
2016-09-07 04:57:50 +08:00
|
|
|
@unittest2.skipIf(hasattr(os, 'geteuid') and os.geteuid()
|
|
|
|
== 0, "test cannot be run as root")
|
2015-02-28 03:14:12 +08:00
|
|
|
# Do we need to disable this test if the testsuite is being run on a remote system?
|
2016-09-07 04:57:50 +08:00
|
|
|
# This env var is only defined when the shell is running in a local mac
|
|
|
|
# terminal window
|
|
|
|
@unittest2.skipUnless(
|
|
|
|
'TERM_PROGRAM' in os.environ,
|
|
|
|
"test must be run on local system")
|
2015-09-30 18:12:40 +08:00
|
|
|
@no_debug_info_test
|
2016-09-07 04:57:50 +08:00
|
|
|
def test_launch_in_terminal(self):
|
2016-10-11 08:35:41 +08:00
|
|
|
self.build()
|
2018-01-20 07:24:35 +08:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2016-10-11 08:35:41 +08:00
|
|
|
|
2015-01-07 03:17:58 +08:00
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
launch_info = lldb.SBLaunchInfo(["-lAF", "/tmp/"])
|
2016-09-07 04:57:50 +08:00
|
|
|
launch_info.SetLaunchFlags(
|
|
|
|
lldb.eLaunchFlagLaunchInTTY | lldb.eLaunchFlagCloseTTYOnExit)
|
2015-01-07 03:17:58 +08:00
|
|
|
error = lldb.SBError()
|
2016-09-07 04:57:50 +08:00
|
|
|
process = target.Launch(launch_info, error)
|
2016-10-11 08:35:41 +08:00
|
|
|
print("Error was: %s."%(error.GetCString()))
|
2016-09-07 04:57:50 +08:00
|
|
|
self.assertTrue(
|
|
|
|
error.Success(),
|
|
|
|
"Make sure launch happened successfully in a terminal window")
|
|
|
|
# Running in synchronous mode our process should have run and already
|
|
|
|
# exited by the time target.Launch() returns
|
2015-01-07 03:17:58 +08:00
|
|
|
self.assertTrue(process.GetState() == lldb.eStateExited)
|