Files
clang-p2996/lldb/test/functionalities/command_history/TestCommandHistory.py
Zachary Turner 045fde58d1 Fixes a number of issue related to test portability on Windows.
99% of this CL is simply moving calls to "import pexpect" to a more
narrow scope - i.e. the function that actually runs a particular
test.  This way the test suite can run on Windows, which doesn't have
pexpect, and the individual tests that use pexpect can be disabled on
a platform-specific basis.

Additionally, this CL fixes a few other cases of non-portability.
Notably, using "ps" to get the command line, and os.uname() to
determine the architecture don't work on Windows.  Finally, this
also adds a stubbed out builder_win32 module.

The full test suite runs correctly on Windows after this CL, although
there is still some work remaining on the C++ side to fix one-shot
script commands from LLDB (e.g. script print "foo"), which currently
deadlock.

Reviewed by: Todd Fiala

Differential Revision: http://reviews.llvm.org/D4573

llvm-svn: 213343
2014-07-18 01:02:02 +00:00

72 lines
3.1 KiB
Python

"""
Test the command history mechanism
"""
import os
import unittest2
import lldb
from lldbtest import *
class CommandHistoryTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def test_history(self):
self.runCmd('command history --clear', inHistory=False)
self.runCmd('breakpoint list', check=False, inHistory=True) #0
self.runCmd('register read', check=False, inHistory=True) #1
self.runCmd('apropos hello', check=False, inHistory=True) #2
self.runCmd('memory write', check=False, inHistory=True) #3
self.runCmd('log list', check=False, inHistory=True) #4
self.runCmd('disassemble', check=False, inHistory=True) #5
self.runCmd('expression 1', check=False, inHistory=True) #6
self.runCmd('type summary list -w default', check=False, inHistory=True) #7
self.runCmd('version', check=False, inHistory=True) #8
self.runCmd('frame select 1', check=False, inHistory=True) #9
self.expect ("command history -s 3 -c 3", inHistory=True,
substrs = ['3: memory write','4: log list','5: disassemble'])
self.expect ("command history -s 3 -e 3", inHistory=True,
substrs = ['3: memory write'])
self.expect ("command history -s 6 -e 7", inHistory=True,
substrs = ['6: expression 1','7: type summary list -w default'])
self.expect ("command history -c 2", inHistory=True,
substrs = ['0: breakpoint list','1: register read'])
self.expect ("command history -e 3 -c 1", inHistory=True,
substrs = ['3: memory write'])
self.expect ("command history -e 2", inHistory=True,
substrs = ['0: breakpoint list','1: register read','2: apropos hello'])
self.expect ("command history -s 12", inHistory=True,
substrs = ['12: command history -s 6 -e 7','13: command history -c 2','14: command history -e 3 -c 1','15: command history -e 2','16: command history -s 12'])
self.expect ("command history -s end -c 3", inHistory=True,
substrs = ['15: command history -e 2','16: command history -s 12','17: command history -s end -c 3'])
self.expect ("command history -s end -e 15", inHistory=True,
substrs = ['15: command history -e 2','16: command history -s 12','17: command history -s end -c 3','command history -s end -e 15'])
self.expect ("command history -s 5 -c 1", inHistory=True,
substrs = ['5: disassemble'])
self.expect ("command history -c 1 -s 5", inHistory=True,
substrs = ['5: disassemble'])
self.expect ("command history -c 1 -e 3", inHistory=True,
substrs = ['3: memory write'])
self.expect ("command history -c 1 -e 3 -s 5",error=True, inHistory=True,
substrs = ['error: --count, --start-index and --end-index cannot be all specified in the same invocation'])
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()