1""" 2Test lldb command aliases. 3""" 4 5from __future__ import print_function 6 7 8import unittest2 9import os 10import lldb 11from lldbsuite.test.decorators import * 12from lldbsuite.test.lldbtest import * 13from lldbsuite.test import lldbutil 14 15 16class LaunchInTerminalTestCase(TestBase): 17 18 # Darwin is the only platform that I know of that supports optionally launching 19 # a program in a separate terminal window. It would be great if other platforms 20 # added support for this. 21 @skipUnlessDarwin 22 # If the test is being run under sudo, the spawned terminal won't retain that elevated 23 # privilege so it can't open the socket to talk back to the test case 24 @unittest2.skipIf(hasattr(os, 'geteuid') and os.geteuid() 25 == 0, "test cannot be run as root") 26 # Do we need to disable this test if the testsuite is being run on a remote system? 27 # This env var is only defined when the shell is running in a local mac 28 # terminal window 29 @unittest2.skipUnless( 30 'TERM_PROGRAM' in os.environ, 31 "test must be run on local system") 32 @no_debug_info_test 33 def test_launch_in_terminal(self): 34 self.build() 35 exe = self.getBuildArtifact("a.out") 36 37 target = self.dbg.CreateTarget(exe) 38 launch_info = lldb.SBLaunchInfo(["-lAF", "/tmp/"]) 39 launch_info.SetLaunchFlags( 40 lldb.eLaunchFlagLaunchInTTY | lldb.eLaunchFlagCloseTTYOnExit) 41 error = lldb.SBError() 42 process = target.Launch(launch_info, error) 43 print("Error was: %s."%(error.GetCString())) 44 self.assertTrue( 45 error.Success(), 46 "Make sure launch happened successfully in a terminal window") 47 # Running in synchronous mode our process should have run and already 48 # exited by the time target.Launch() returns 49 self.assertState(process.GetState(), lldb.eStateExited) 50