2011-04-20 21:51:31 +00:00
"""
Test lldb ' commands regex ' command which allows the user to create a regular expression command.
"""
2015-10-23 17:04:29 +00:00
from __future__ import print_function
2015-11-03 19:20:39 +00:00
2011-04-20 21:51:31 +00:00
import os
import lldb
2016-02-04 23:04:17 +00:00
from lldbsuite . test . decorators import *
2015-11-03 02:06:18 +00:00
from lldbsuite . test . lldbtest import *
2016-02-04 23:04:17 +00:00
from lldbsuite . test import lldbutil
2011-04-20 21:51:31 +00:00
2016-09-06 20:57:50 +00:00
2011-04-20 21:51:31 +00:00
class CommandRegexTestCase ( TestBase ) :
2013-12-10 23:19:29 +00:00
mydir = TestBase . compute_mydir ( __file__ )
2011-04-20 21:51:31 +00:00
2016-09-06 20:57:50 +00:00
@expectedFailureAll (
hostoslist = [ " windows " ] ,
bugnumber = " llvm.org/pr22274: need a pexpect replacement for windows " )
2015-09-30 10:12:40 +00:00
@no_debug_info_test
2011-04-20 21:51:31 +00:00
def test_command_regex ( self ) :
2014-01-27 23:43:24 +00:00
""" Test a simple scenario of ' command regex ' invocation and subsequent use. """
2014-07-18 01:02:02 +00:00
import pexpect
2011-05-03 22:14:19 +00:00
prompt = " (lldb) "
2014-01-27 23:43:24 +00:00
regex_prompt = " Enter one of more sed substitution commands in the form: ' s/<regex>/<subst>/ ' . \r \n Terminate the substitution list with an empty line. \r \n "
2011-04-20 21:51:31 +00:00
regex_prompt1 = " \r \n "
2016-09-06 20:57:50 +00:00
child = pexpect . spawn ( ' %s %s ' %
( lldbtest_config . lldbExec , self . lldbOption ) )
2011-04-20 21:51:31 +00:00
# Turn on logging for what the child sends back.
2011-04-20 22:01:48 +00:00
if self . TraceOn ( ) :
2011-04-20 21:51:31 +00:00
child . logfile_read = sys . stdout
2011-04-22 21:47:07 +00:00
# So that the spawned lldb session gets shutdown durng teardown.
self . child = child
2011-04-20 21:51:31 +00:00
2011-05-03 22:14:19 +00:00
# Substitute 'Help!' for 'help' using the 'commands regex' mechanism.
child . expect_exact ( prompt )
2011-10-31 22:22:06 +00:00
child . sendline ( " command regex ' Help__ ' " )
2011-05-03 22:14:19 +00:00
child . expect_exact ( regex_prompt )
2011-04-20 21:51:31 +00:00
child . sendline ( ' s/^$/help/ ' )
2011-05-03 22:14:19 +00:00
child . expect_exact ( regex_prompt1 )
2011-04-20 21:51:31 +00:00
child . sendline ( ' ' )
2014-11-18 00:39:31 +00:00
child . expect_exact ( prompt )
2011-04-20 21:51:31 +00:00
# Help!
2011-10-31 22:22:06 +00:00
child . sendline ( ' Help__ ' )
2011-04-20 21:51:31 +00:00
# If we see the familiar 'help' output, the test is done.
2015-01-15 22:52:17 +00:00
child . expect ( ' Debugger commands: ' )
2016-09-06 20:57:50 +00:00
# Try and incorrectly remove "Help__" using "command unalias" and
# verify we fail
2015-01-09 19:08:20 +00:00
child . sendline ( ' command unalias Help__ ' )
2016-09-06 20:57:50 +00:00
child . expect_exact (
" error: ' Help__ ' is not an alias, it is a debugger command which can be removed using the ' command delete ' command " )
2015-01-09 19:08:20 +00:00
child . expect_exact ( prompt )
2016-09-06 20:57:50 +00:00
2015-01-09 19:08:20 +00:00
# Delete the regex command using "command delete"
child . sendline ( ' command delete Help__ ' )
child . expect_exact ( prompt )
# Verify the command was removed
child . sendline ( ' Help__ ' )
child . expect_exact ( " error: ' Help__ ' is not a valid command " )
child . expect_exact ( prompt )