2011-04-21 05:51:31 +08:00
|
|
|
"""
|
|
|
|
Test lldb 'commands regex' command which allows the user to create a regular expression command.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import unittest2
|
|
|
|
import lldb
|
|
|
|
import pexpect
|
|
|
|
from lldbtest import *
|
|
|
|
|
|
|
|
class CommandRegexTestCase(TestBase):
|
|
|
|
|
2011-06-27 05:36:28 +08:00
|
|
|
mydir = os.path.join("functionalities", "command_regex")
|
2011-04-21 05:51:31 +08:00
|
|
|
|
|
|
|
def test_command_regex(self):
|
2011-04-21 08:05:59 +08:00
|
|
|
"""Test a simple scenario of 'command regexp' invocation and subsequent use."""
|
2011-05-04 06:14:19 +08:00
|
|
|
prompt = "(lldb) "
|
2011-04-21 08:05:59 +08:00
|
|
|
regex_prompt = "Enter regular expressions in the form 's/<regex>/<subst>/' and terminate with an empty line:\r\n"
|
2011-04-21 05:51:31 +08:00
|
|
|
regex_prompt1 = "\r\n"
|
|
|
|
|
2011-10-08 03:21:09 +08:00
|
|
|
child = pexpect.spawn('%s %s' % (self.lldbHere, self.lldbOption))
|
2011-04-21 05:51:31 +08:00
|
|
|
# Turn on logging for what the child sends back.
|
2011-04-21 06:01:48 +08:00
|
|
|
if self.TraceOn():
|
2011-04-21 05:51:31 +08:00
|
|
|
child.logfile_read = sys.stdout
|
2011-04-23 05:47:07 +08:00
|
|
|
# So that the spawned lldb session gets shutdown durng teardown.
|
|
|
|
self.child = child
|
2011-04-21 05:51:31 +08:00
|
|
|
|
2011-05-04 06:14:19 +08:00
|
|
|
# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
|
|
|
|
child.expect_exact(prompt)
|
2011-04-21 08:05:59 +08:00
|
|
|
child.sendline("command regex 'Help!'")
|
2011-05-04 06:14:19 +08:00
|
|
|
child.expect_exact(regex_prompt)
|
2011-04-21 05:51:31 +08:00
|
|
|
child.sendline('s/^$/help/')
|
2011-05-04 06:14:19 +08:00
|
|
|
child.expect_exact(regex_prompt1)
|
2011-04-21 05:51:31 +08:00
|
|
|
child.sendline('')
|
|
|
|
# Help!
|
|
|
|
child.sendline('Help!')
|
|
|
|
# If we see the familiar 'help' output, the test is done.
|
2011-04-23 05:47:07 +08:00
|
|
|
child.expect('The following is a list of built-in, permanent debugger commands:')
|
2011-04-21 05:51:31 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
import atexit
|
|
|
|
lldb.SBDebugger.Initialize()
|
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
|
|
|
unittest2.main()
|