[gdb/testsuite] Don't expect gdb_prompt in mi_skip_python_test
authorTom de Vries <tdevries@suse.de>
Mon, 29 Jul 2019 09:24:04 +0000 (11:24 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 29 Jul 2019 09:24:04 +0000 (11:24 +0200)
commitd17725d72f25812acc8bd16a368c0e889c4b4d1e
tree262277fed5a43ed94d43eda883f2f1e16865f0c2
parentcc5277b173701364c10204f316db28198f2c683b
[gdb/testsuite] Don't expect gdb_prompt in mi_skip_python_test

When running gdb.python/py-mi-events.exp with make check-read1, we get:
...
(gdb) ^M
python print ('test')^M
&"python print ('test')\n"^M
~"test\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: verify python support
^M
python print (sys.version_info[0])^M
&"python print (sys.version_info[0])\n"^M
~"2\n"^M
^done^M
(gdb) FAIL: gdb.python/py-mi-events.exp: check if python 3
^M
...

The FAILs happen as follows.

On one hand, skip_python_tests_prompt uses the prompt_regexp parameter for the
user_code argument of gdb_test_multiple:
...
proc skip_python_tests_prompt { prompt_regexp } {
    global gdb_py_is_py3k

    gdb_test_multiple "python print ('test')" "verify python support" {
-re "not supported.*$prompt_regexp" {
    unsupported "Python support is disabled."
    return 1
}
-re "$prompt_regexp" {}
    }

    gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
-re "3.*$prompt_regexp" {
            set gdb_py_is_py3k 1
        }
-re ".*$prompt_regexp" {
            set gdb_py_is_py3k 0
        }
    }
...

On the other hand, gdb_test_multiple itself uses $gdb_prompt:
...
         -re "\r\n$gdb_prompt $" {
            if ![string match "" $message] then {
                fail "$message"
            }
            set result 1
        }
...

So when mi_skip_python_test calls skip_python_tests_prompt with prompt_regexp
set to $mi_gdb_prompt:
...
proc mi_skip_python_tests {} {
    global mi_gdb_prompt
    return [skip_python_tests_prompt "$mi_gdb_prompt$"]
}
...
and expect reads "(gdb) " and tries to match it (due to the READ1=1 setting),
the user_code regexps using $prompt_regexp (set to $mi_gdb_prompt) don't match,
but the $gdb_prompt regexp in gdb_test_multiple does match.

Fix this by adding a prompt_regexp parameter to gdb_test_multiple, and using the
parameter in skip_python_tests_prompt.

Tested gdb.python/py-mi-events.exp with make check READ1=1 x86_64-linux.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-07-29  Tom de Vries  <tdevries@suse.de>

PR gdb/24855
* lib/gdb.exp (gdb_test_multiple): Add prompt_regexp parameter.
(skip_python_tests_prompt): Add prompt_regexp argument to
gdb_test_multiple calls.
gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdb.exp